moved docker files to sub directory and cleaned up task file
parent
1cb29899b9
commit
5085500786
@ -1 +1 @@
|
||||
b43ecff1fe53e18c4c9b756b32d38078
|
||||
fe0b33dbcc236558952eb8f9f91422c9
|
||||
|
@ -1,149 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# adding commands
|
||||
usage() {
|
||||
# how to use this build script
|
||||
cat <<EOF
|
||||
usage: $0 [-c][-l][-i s] s1 [s2....]
|
||||
s1, s2, etc. the systems to build for (see -l)
|
||||
Options:
|
||||
-c, --clean cleans the bin folder of any existing builds
|
||||
-f, --force same as clean but skips prompt
|
||||
-l, --list list available systems to build for
|
||||
-s, --scp will attempt to scp to aplicable devices
|
||||
-h, --help display this message
|
||||
EOF
|
||||
}
|
||||
|
||||
list_systems() {
|
||||
# list available systems to build for
|
||||
cat <<EOF
|
||||
Name (shorthand) SCP available? (y/n)
|
||||
$0 Name or $0 (shorthand) will build for the device
|
||||
|
||||
RaspberryPi (rpi) y
|
||||
BeagleBone (bb) y
|
||||
Desktop (d) n
|
||||
Server (s) n
|
||||
EOF
|
||||
}
|
||||
|
||||
clean_builds() {
|
||||
# cleans old builds
|
||||
if [[ "$FORCE"=true ]] ; then
|
||||
printf 'Cleaning old builds... \n'
|
||||
rm -v bin/* 2>/dev/null
|
||||
else
|
||||
read -p "Clean old builds?(y/n) " -n 1 -r
|
||||
if [[ $REPLY =~ ^[Yy]$ ]] ; then
|
||||
rm -v bin/* 2>/dev/null
|
||||
fi
|
||||
fi
|
||||
printf 'Clean!\n'
|
||||
}
|
||||
|
||||
create_build() {
|
||||
# create build for $1
|
||||
case $1 in
|
||||
'rpi' )
|
||||
printf 'Building for Raspberry Pi!\n'
|
||||
GARCH="arm64"
|
||||
PLATFORM="reactor"
|
||||
;;
|
||||
'bb')
|
||||
printf 'Building for BeagleBone!\n'
|
||||
GARCH="arm"
|
||||
GARM="GOARM=7"
|
||||
PLATFORM="reactor"
|
||||
;;
|
||||
's')
|
||||
printf 'Building for Server!\n'
|
||||
GARCH="amd64"
|
||||
PLATFORM="server"
|
||||
;;
|
||||
'd')
|
||||
printf 'Building for Desktop!\n'
|
||||
GARCH="amd64"
|
||||
PLATFORM="server"
|
||||
;;
|
||||
* )
|
||||
printf 'ERROR: %s type unrecognized!\n' "$1"
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
# setting up build
|
||||
OUTFILE=$(printf '%s_linux_%s' "$PLATFORM" "$GARCH")
|
||||
INFILE=$(printf '%s/main.go' "$PLATFORM")
|
||||
# building
|
||||
env GOOS=linux GOARCH="$GARCH" $GARM go build -o bin/"$OUTFILE" cmd/"$INFILE"
|
||||
echo "Finished"
|
||||
if [[ "$SCP"=true ]] ; then
|
||||
printf 'Attempting to transfer to %s\n' "$2"
|
||||
if [[ "$1" == "bb" ]] ; then
|
||||
printf 'Copying to %s\n' "192.168.100.90"
|
||||
scp "$HOME/FRMS/bin/$OUTFILE" debian:~/
|
||||
else
|
||||
printf 'SCP Not available!\n'
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# handle long form
|
||||
for arg in "$@"; do
|
||||
shift
|
||||
case "$arg" in
|
||||
'--help') set -- "$@" "-h" ;;
|
||||
'--list') set -- "$@" "-l" ;;
|
||||
'--scp') set -- "$@" "-s" ;;
|
||||
'--clean') set -- "$@" "-c" ;;
|
||||
'--force') set -- "$@" "-f" ;;
|
||||
*) set -- "$@" "$arg" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# handle args
|
||||
while getopts "lcsfh" opt ; do
|
||||
case "$opt" in
|
||||
'h' )
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
'c' )
|
||||
clean_builds
|
||||
;;
|
||||
'f' )
|
||||
FORCE=true
|
||||
clean_builds
|
||||
;;
|
||||
's' )
|
||||
SCP=true
|
||||
;;
|
||||
'l')
|
||||
list_systems
|
||||
;;
|
||||
'?' )
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $(($OPTIND - 1))
|
||||
|
||||
for dev in "$@"; do
|
||||
case "$dev" in
|
||||
'RaspberryPi') dev='rpi' ;;
|
||||
'BeagleBone') dev='bb' ;;
|
||||
'Server') dev='s' ;;
|
||||
'Desktop') dev='d' ;;
|
||||
esac
|
||||
create_build "$dev"
|
||||
done
|
||||
printf 'Nothing else to do!\n'
|
||||
|
||||
# echo "Compressing binaries for distrubution"
|
||||
# tar -czf pireactor.tar.gz -C bin reactor_linux_arm64
|
||||
# tar -czf bbreactor.tar.gz -C bin reactor_linux_arm
|
||||
# tar -czf server.tar.gz -C bin server_linux_amd64
|
||||
# tar -czf tui.tar.gz -C bin tui_linux_amd64 tui_linux_arm tui_linux_arm64
|
@ -1,89 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
import json
|
||||
import subprocess
|
||||
|
||||
class PackageTest:
|
||||
def __init__(self):
|
||||
self.status = ""
|
||||
self.tests = []
|
||||
self.totaltime = 0
|
||||
|
||||
res = {}
|
||||
|
||||
output = subprocess.run(["go","test","-count=1","-json","./..."], capture_output=True, text=True)
|
||||
|
||||
output = str(output.stdout)
|
||||
output = output.split('\n')
|
||||
|
||||
for line in output[:-1]:
|
||||
# parse the json
|
||||
parsed = json.loads(line)
|
||||
action = parsed["Action"]
|
||||
|
||||
# skip
|
||||
if action in ["start", "output", "run"]:
|
||||
continue
|
||||
|
||||
# create blank if doesn't exist
|
||||
if parsed["Package"] not in res:
|
||||
res[parsed["Package"]] = PackageTest()
|
||||
|
||||
pkg = res[parsed["Package"]]
|
||||
|
||||
if "Test" not in parsed:
|
||||
# top level package result
|
||||
pkg.status = action
|
||||
if "Elapsed" in parsed:
|
||||
pkg.totaltime = parsed["Elapsed"]
|
||||
else:
|
||||
# individual test
|
||||
pkg.tests.append((parsed["Test"],parsed["Action"],parsed["Elapsed"]))
|
||||
|
||||
totalRan = 0
|
||||
totalPassed = 0
|
||||
totalTime = 0
|
||||
# generating output from parsed json
|
||||
for name, info in res.items():
|
||||
pkgname = name.split('/')
|
||||
pkgname = '/'.join(name.split('/')[1:])
|
||||
if info.status == "skip":
|
||||
print("Skipped %s" % (pkgname))
|
||||
continue
|
||||
|
||||
print("\nTesting %s:" % (pkgname))
|
||||
|
||||
passed = 0
|
||||
total = 0
|
||||
|
||||
for test in info.tests:
|
||||
total += 1
|
||||
out = []
|
||||
if test[1] == "pass":
|
||||
passed += 1
|
||||
out = [" " + test[0] + ":",'\033[32mpass\033[0m ',str(test[2]) + 's']
|
||||
elif test[1] == "fail":
|
||||
out = [" " + test[0] + ":",'\033[31mfail\033[0m ',str(test[2]) + 's']
|
||||
|
||||
print(f"{out[0] : <30}{out[1] : >5}{out[2] : >8}")
|
||||
|
||||
result = ""
|
||||
if info.status == "pass":
|
||||
result = "\033[32mPASSED\033[0m"
|
||||
else:
|
||||
result = "\033[31mFAILED\033[0m"
|
||||
|
||||
# keep track of grand totals
|
||||
totalRan += total
|
||||
totalPassed += passed
|
||||
totalTime += info.totaltime
|
||||
|
||||
print(" %s %d/%d in %.3fs/n" % (result, passed, total, info.totaltime))
|
||||
|
||||
|
||||
# output overall test statistics
|
||||
if totalRan == totalPassed:
|
||||
result = "\033[32mPASSED\033[0m"
|
||||
else:
|
||||
result = "\033[31mFAILED\033[0m"
|
||||
|
||||
print("\nSUMMARY:\n\t%s %d/%d in %.3fs" % (result, totalPassed, totalRan, totalTime))
|
@ -1,44 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
display_usage() {
|
||||
echo "Usage: $0 reactor_type"
|
||||
}
|
||||
|
||||
# checking for help options
|
||||
if [[ $@ == "--help" || $@ == "-h" ]]
|
||||
then
|
||||
display_usage
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# checking that arguements are not empty
|
||||
if [[ -z $1 ]]
|
||||
then
|
||||
echo "Type of reactor not specified!"
|
||||
display_usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# checking for valid reactor types
|
||||
if [[ $1 == "pi" ]]
|
||||
then
|
||||
platform="linux/arm64"
|
||||
elif [[ $1 == "bb" ]]
|
||||
then
|
||||
platform="linux/arm/v7"
|
||||
else
|
||||
echo "Reactor type $1 not supported!"
|
||||
echo "Supported reactors include: pi, bb"
|
||||
display_usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# building reactor image
|
||||
|
||||
echo "Building Reactor image for $1 platform=$platform"
|
||||
|
||||
docker buildx build --rm --platform=$platform -f Dockerfile.reactor --tag localhost:5000/reactor .
|
||||
|
||||
echo "Cleaning local images"
|
||||
|
||||
docker image remove localhost:5000/reactor
|
@ -1,2 +0,0 @@
|
||||
#!/bin/bash
|
||||
echo $(git ls-files | grep .go | awk '!/pb/' | xargs wc -l | tail -n 1)
|
Loading…
Reference in New Issue