Skip to content

Commit

Permalink
ci: move fake ship boot & test step bash scripts to separate files
Browse files Browse the repository at this point in the history
  • Loading branch information
ripperi committed Oct 1, 2024
1 parent 65b8354 commit 72e668a
Show file tree
Hide file tree
Showing 3 changed files with 229 additions and 222 deletions.
228 changes: 6 additions & 222 deletions .github/workflows/shared.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,231 +112,15 @@ jobs:
- name: Boot fake ship
if: ${{ inputs.fake_tests }}
run: |
urbit_binary=${{ github.workspace }}/zig-out/x86_64-linux-musl/urbit-test
solid_pill=${{ github.workspace }}/solid.pill
curl -LJ -o $solid_pill https://github.com/urbit/urbit/raw/84ebb321314b3fbc08253de5213f19450ffbfb3e/bin/solid.pill
curl -LJ -o urbit.tar.gz https://github.com/urbit/urbit/archive/84ebb321314b3fbc08253de5213f19450ffbfb3e.tar.gz
mkdir ./urbit
tar xfz urbit.tar.gz -C ./urbit --strip-components=1
cp -RL ./urbit/tests ./urbit/pkg/arvo/tests
set -xeuo pipefail
$urbit_binary --lite-boot --daemon --fake bus \
--bootstrap $solid_pill \
--arvo ./urbit/pkg/arvo \
--pier ./pier
cleanup() {
if [ -f ./pier/.vere.lock ]; then
kill $(< ./pier/.vere.lock) || true
fi
set +x
}
trap cleanup EXIT
port=$(grep loopback ./pier/.http.ports | awk -F ' ' '{print $1}')
lensd() {
curl -s \
--data "{\"source\":{\"dojo\":\"$1\"},\"sink\":{\"stdout\":null}}" \
"http://localhost:$port" | xargs printf %s | sed 's/\\n/\n/g'
}
lensa() {
curl -s \
--data "{\"source\":{\"dojo\":\"$2\"},\"sink\":{\"app\":\"$1\"}}" \
"http://localhost:$port" | xargs printf %s | sed 's/\\n/\n/g'
}
check() {
[ 3 -eq $(lensd 3) ]
}
lensd '+vat %base'
if check && sleep 10 && check; then
echo "boot success"
lensa hood '+hood/exit'
while [ -f ./pier/.vere.lock ]; do
echo "waiting for pier to shut down"
sleep 5
done
else
echo "boot failure"
kill $(< ./pier/.vere.lock) || true
set +x
exit 1
fi
env:
URBIT_BINARY: "zig-out/x86_64-linux-musl/urbit-test"
run: ./boot-fake-ship.sh

- name: Run fake ship tests
if: ${{ inputs.fake_tests }}
run: |
urbit_binary=${{ github.workspace }}/zig-out/x86_64-linux-musl/urbit-test
set -x
$urbit_binary --lite-boot --daemon --gc ./pier 2> urbit-output
port=$(grep loopback ./pier/.http.ports | awk -F ' ' '{print $1}')
lensd() {
curl -s \
--data "{\"source\":{\"dojo\":\"$1\"},\"sink\":{\"stdout\":null}}" \
"http://localhost:$port" | xargs printf %s | sed 's/\\n/\n/g'
}
lensa() {
curl -s \
--data "{\"source\":{\"dojo\":\"$2\"},\"sink\":{\"app\":\"$1\"}}" \
"http://localhost:$port" | xargs printf %s | sed 's/\\n/\n/g'
}
tail -F urbit-output >&2 &
tailproc=$!
cleanup () {
kill $(cat ./pier/.vere.lock) || true
kill "$tailproc" 2>/dev/null || true
set +x
}
trap cleanup EXIT
# print the arvo version
#
lensd '+vat %base'
# measure initial memory usage
#
lensd '~& ~ ~& %init-mass-start ~'
lensa hood '+hood/mass'
lensd '~& ~ ~& %init-mass-end ~'
# run the unit tests
#
lensd '~& ~ ~& %test-unit-start ~'
lensd '-test %/tests ~'
lensd '~& ~ ~& %test-unit-end ~'
# use the :test app to build all agents, generators, and marks
#
lensa hood '+hood/start %test'
lensd '~& ~ ~& %test-agents-start ~'
lensa test '%agents'
lensd '~& ~ ~& %test-agents-end ~'
lensd '~& ~ ~& %test-generators-start ~'
lensa test '%generators'
lensd '~& ~ ~& %test-generators-end ~'
lensd '~& ~ ~& %test-marks-start ~'
lensa test '%marks'
lensd '~& ~ ~& %test-marks-end ~'
# measure memory usage post tests
#
lensd '~& ~ ~& %test-mass-start ~'
lensa hood '+hood/mass'
lensd '~& ~ ~& %test-mass-end ~'
# defragment the loom
#
lensd '~& ~ ~& %pack-start ~'
lensa hood '+hood/pack'
lensd '~& ~ ~& %pack-end ~'
# reclaim space within arvo
#
lensd '~& ~ ~& %trim-start ~'
lensa hood '+hood/trim'
lensd '~& ~ ~& %trim-end ~'
# measure memory usage pre |meld
#
lensd '~& ~ ~& %trim-mass-start ~'
lensa hood '+hood/mass'
lensd '~& ~ ~& %trim-mass-end ~'
# globally deduplicate
#
lensd '~& ~ ~& %meld-start ~'
lensa hood '+hood/meld'
lensd '~& ~ ~& %meld-end ~'
# measure memory usage post |meld
#
lensd '~& ~ ~& %meld-mass-start ~'
lensa hood '+hood/mass'
lensd '~& ~ ~& %meld-mass-end ~'
lensa hood '+hood/exit'
cleanup
# Collect output
cp urbit-output test-output-unit
cp urbit-output test-output-agents
cp urbit-output test-output-generators
cp urbit-output test-output-marks
# TODO: when re-enabling fake ship tests on macOS, use `sed -i ''`
# instead of `sed -i`.
sed -i '0,/test-unit-start/d' test-output-unit
sed -i '/test-unit-end/,$d' test-output-unit
sed -i '0,/test-agents-start/d' test-output-agents
sed -i '/test-agents-end/,$d' test-output-agents
sed -i '0,/test-generators-start/d' test-output-generators
sed -i '/test-generators-end/,$d' test-output-generators
sed -i '0,/test-marks-start/d' test-output-marks
sed -i '/test-marks-end/,$d' test-output-marks
OUTDIR="$(pwd)/test-fake-ship-output"
mkdir -p $OUTDIR
cp test-output-* $OUTDIR
set +x
hdr () {
echo =====$(sed 's/./=/g' <<< "$1")=====
echo ==== $1 ====
echo =====$(sed 's/./=/g' <<< "$1")=====
}
for f in $(find "$OUTDIR" -type f); do
hdr "$(basename $f)"
cat "$f"
done
fail=0
for f in $(find "$OUTDIR" -type f); do
if egrep "((FAILED|CRASHED)|warn:) " $f >/dev/null; then
if [[ $fail -eq 0 ]]; then
hdr "Test Failures"
fi
echo "ERROR Test failure in $(basename $f)"
((fail++))
fi
done
if [[ $fail -eq 0 ]]; then
hdr "Success"
fi
exit "$fail"
env:
URBIT_BINARY: "zig-out/x86_64-linux-musl/urbit-test"
run: ./test-fake-ship.sh

#
# UPLOAD TO GCP
Expand Down
60 changes: 60 additions & 0 deletions boot-fake-ship.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash

set -xeuo pipefail

urbit_binary=$GITHUB_WORKSPACE/$URBIT_BINARY
solid_pill=$GITHUB_WORKSPACE/solid.pill

curl -LJ -o $solid_pill https://github.com/urbit/urbit/raw/84ebb321314b3fbc08253de5213f19450ffbfb3e/bin/solid.pill
curl -LJ -o urbit.tar.gz https://github.com/urbit/urbit/archive/84ebb321314b3fbc08253de5213f19450ffbfb3e.tar.gz

mkdir ./urbit
tar xfz urbit.tar.gz -C ./urbit --strip-components=1
cp -RL ./urbit/tests ./urbit/pkg/arvo/tests

$urbit_binary --lite-boot --daemon --fake bus \
--bootstrap $solid_pill \
--arvo ./urbit/pkg/arvo \
--pier ./pier

cleanup() {
if [ -f ./pier/.vere.lock ]; then
kill $(< ./pier/.vere.lock) || true
fi
set +x
}

trap cleanup EXIT
port=$(grep loopback ./pier/.http.ports | awk -F ' ' '{print $1}')

lensd() {
curl -s \
--data "{\"source\":{\"dojo\":\"$1\"},\"sink\":{\"stdout\":null}}" \
"http://localhost:$port" | xargs printf %s | sed 's/\\n/\n/g'
}

lensa() {
curl -s \
--data "{\"source\":{\"dojo\":\"$2\"},\"sink\":{\"app\":\"$1\"}}" \
"http://localhost:$port" | xargs printf %s | sed 's/\\n/\n/g'
}

check() {
[ 3 -eq $(lensd 3) ]
}

lensd '+vat %base'

if check && sleep 10 && check; then
echo "boot success"
lensa hood '+hood/exit'
while [ -f ./pier/.vere.lock ]; do
echo "waiting for pier to shut down"
sleep 5
done
else
echo "boot failure"
kill $(< ./pier/.vere.lock) || true
set +x
exit 1
fi
Loading

0 comments on commit 72e668a

Please sign in to comment.