Skip to content

Commit

Permalink
buildomat: build tests in AWS and run them in the lab
Browse files Browse the repository at this point in the history
  • Loading branch information
jclulow committed Apr 20, 2022
1 parent abd372d commit fc09089
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 0 deletions.
57 changes: 57 additions & 0 deletions .github/buildomat/jobs/tests-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash
#:
#: name = "tests-build"
#: variety = "basic"
#: target = "helios"
#: rust_toolchain = "nightly-2021-11-24"
#: output_rules = [
#: "/work/bins/*.gz",
#: "/work/tests/*.gz",
#: ]
#:

set -o errexit
set -o pipefail
set -o xtrace

/opt/ooce/bin/jq --version
cargo --version
rustc --version

#banner 'BuildBins'
#ptime -m cargo build --verbose --bins \
# --message-format json-render-diagnostics >/tmp/output.build.json

banner 'BuildTests'
ptime -m cargo build --verbose --tests \
--message-format json-render-diagnostics >/tmp/output.tests.json

function artifacts_from {
/opt/ooce/bin/jq -r -s "
map(
select(.reason == \"compiler-artifact\")
| select(
.target.kind
| map_values(. == \"$2\")
| any
)
| .filenames
)
| flatten
| .[]" "$1"
}

#banner 'SaveBins'
#mkdir -p /work/bins
#artifacts_from /tmp/output.build.json bin | while read a; do
# ptime -m gzip < "$a" > "/work/bins/$(basename "$a").gz"
#done

banner 'SaveTests'
mkdir -p /work/tests
artifacts_from /tmp/output.tests.json test | while read a; do
ptime -m gzip < "$a" > "/work/tests/$(basename "$a").gz"
done

banner 'Done'
ls -lh /work/*/*
60 changes: 60 additions & 0 deletions .github/buildomat/jobs/tests-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash
#:
#: name = "tests-run"
#: variety = "basic"
#: target = "lab"
#: output_rules = [
#: "/tmp/*.log",
#: ]
#: skip_clone = true
#:
#: [dependencies.build]
#: job = "tests-build"
#:

set -o errexit
set -o pipefail
set -o xtrace

banner 'Inputs'
find /input -ls

testdir="$PWD/tests"
rm -rf "$testdir"
mkdir "$testdir"

for p in /input/build/work/tests/*.gz; do
f="$testdir/$(basename "$p")"
f="${f%.gz}"
rm -f "$f"
gunzip < "$p" > "$f"
chmod +x "$f"
done

fail=no

banner 'Tests'
for f in "$testdir"/*; do
#
# Tests generally need to run as root in order to have access to the
# hypervisor device.
#
if ! ptime -m pfexec "$f" --show-output --test-threads 1; then
echo
echo "TEST $f FAILED"
echo
fail=yes
else
echo
echo "TEST $f PASSED"
echo
fi
done

if [[ $fail == yes ]]; then
echo "SOME TESTS FAILED"
exit 1
else
echo "ALL TESTS PASSED"
exit 0
fi

0 comments on commit fc09089

Please sign in to comment.