Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buildomat: build tests in AWS and run them in the lab #116

Merged
merged 1 commit into from
Apr 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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