From 6cf84dfee38943049dbc8ef67d07ee06eaba16cd Mon Sep 17 00:00:00 2001 From: Alex Shelkovnykov Date: Sat, 4 Mar 2023 17:24:08 +0900 Subject: [PATCH] build: add CI for Hoon code --- .github/scripts/hoon/boot-ship.sh | 34 +++++++++++++++ .github/scripts/hoon/setup-ship.sh | 66 ++++++++++++++++++++++++++++++ .github/scripts/hoon/test-ship.sh | 13 ++++++ .github/workflows/hoon-feature.yml | 13 ++++++ .github/workflows/hoon-shared.yml | 23 +++++++++++ .github/workflows/hoon-status.yml | 15 +++++++ 6 files changed, 164 insertions(+) create mode 100755 .github/scripts/hoon/boot-ship.sh create mode 100755 .github/scripts/hoon/setup-ship.sh create mode 100755 .github/scripts/hoon/test-ship.sh create mode 100644 .github/workflows/hoon-feature.yml create mode 100644 .github/workflows/hoon-shared.yml create mode 100644 .github/workflows/hoon-status.yml diff --git a/.github/scripts/hoon/boot-ship.sh b/.github/scripts/hoon/boot-ship.sh new file mode 100755 index 0000000..210bddf --- /dev/null +++ b/.github/scripts/hoon/boot-ship.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +set -xeuo pipefail + +PILL_NAME='solid.pill' + +curl -L $URBIT_URL | tar xzk --transform='s/.*/urbit/g' +curl -L $PILL_URL -o $PILL_NAME + +./urbit \ + --bootstrap $PILL_NAME \ + --local \ + --lite-boot \ + --daemon \ + --fake bus \ + -c $URBIT_PIER + +LENS_PORT=$(grep 'loopback' $URBIT_PIER/.http.ports | awk -F ' ' '{print $1}') +lensecho() { + curl -s \ + --data '{"source":{"data":"'"$1"'"},"sink":{"stdout":null}}' \ + "http://localhost:$LENS_PORT" | xargs printf %s | sed 's/\\n//g' +} + +check() { + [ "'3'" == "$(lensecho 3)" ] +} + +if check; then + echo "boot success" +else + echo "boot failure" + exit 1 +fi diff --git a/.github/scripts/hoon/setup-ship.sh b/.github/scripts/hoon/setup-ship.sh new file mode 100755 index 0000000..5bb682c --- /dev/null +++ b/.github/scripts/hoon/setup-ship.sh @@ -0,0 +1,66 @@ +#!/bin/bash + +set -xeuo pipefail + +DESK_DIR="$URBIT_PIER/$DESK" +DESK_LIB_DIR="$DESK_DIR/lib" +DESK_TST_DIR="$DESK_DIR/tests" + +LENS_PORT=$(grep 'loopback' $URBIT_PIER/.http.ports | awk -F ' ' '{print $1}') +lensapp() { + curl -s --max-time 10 \ + --data '{"source":{"dojo":"'"$2"'"},"sink":{"app":"'"$1"'"}}' \ + "http://localhost:$LENS_PORT" +} + +lensdojo() { + curl -s --max-time 10 \ + --data '{"source":{"dojo":"'"$1"'"},"sink":{"stdout":null}}' \ + "http://localhost:$LENS_PORT" +} + +# XX: temporary; eventually should actually load files as pills +lensapp 'hood' "+hood/merge %$DESK our %base" + +lensapp 'hood' "+hood/rm /=$DESK=/desk/bill" +lensapp 'hood' "+hood/rm /=$DESK=/sys/hoon/hoon" +lensapp 'hood' "+hood/rm /=$DESK=/sys/arvo/hoon" +lensapp 'hood' "+hood/rm /=$DESK=/sys/lull/hoon" +lensapp 'hood' "+hood/rm /=$DESK=/sys/zuse/hoon" +lensapp 'hood' "+hood/rm /=$DESK=/sys/vane/ames/hoon" +lensapp 'hood' "+hood/rm /=$DESK=/sys/vane/behn/hoon" +lensapp 'hood' "+hood/rm /=$DESK=/sys/vane/clay/hoon" +lensapp 'hood' "+hood/rm /=$DESK=/sys/vane/dill/hoon" +lensapp 'hood' "+hood/rm /=$DESK=/sys/vane/eyre/hoon" +lensapp 'hood' "+hood/rm /=$DESK=/sys/vane/gall/hoon" +lensapp 'hood' "+hood/rm /=$DESK=/sys/vane/iris/hoon" +lensapp 'hood' "+hood/rm /=$DESK=/sys/vane/jael/hoon" +lensapp 'hood' "+hood/rm /=$DESK=/sys/vane/khan/hoon" + +lensapp 'hood' "+hood/mount %$DESK" + +cp -rfL ./hoon/scaffolding/azimuth-pill.hoon $DESK_DIR +cp -rfL ./hoon/scaffolding/baby.hoon $DESK_DIR + +cp -rfL ./hoon/scaffolding/cradle.hoon $DESK_LIB_DIR +cp -rfL ./hoon/scaffolding/naive-cradle.hoon $DESK_LIB_DIR +cp -rfL ./hoon/scaffolding/logs.jam $DESK_LIB_DIR +cp -rfL ./hoon/scaffolding/mainnet.azimuth-snapshot $DESK_LIB_DIR + +lensapp 'hood' "+hood/commit %$DESK" + +# XX: No tests yet +#mkdir $DESK_TST_DIR +# cp -rfL ./hoon/scaffolding/tests/* $DESK_TST_DIR + +# XX: redo when conn.c cli available +check() { + [ -z "$(lensdojo "-build-file /=$DESK=/$1/hoon" | grep 'thread failed')" ] +} + +if check 'baby' && check 'azimuth-pill'; then + echo "boot success" +else + echo "boot failure" + exit 1 +fi diff --git a/.github/scripts/hoon/test-ship.sh b/.github/scripts/hoon/test-ship.sh new file mode 100755 index 0000000..e13d33e --- /dev/null +++ b/.github/scripts/hoon/test-ship.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +set -xeuo pipefail + +LENS_PORT=$(grep 'loopback' $URBIT_PIER/.http.ports | awk -F ' ' '{print $1}') +lensdojo() { + curl -s \ + --data '{"source":{"dojo":"'"$1"'"},"sink":{"stdout":null}}' \ + "http://localhost:$LENS_PORT" +} + +# XX: redo when conn.c cli available; just runs tests whether they pass or fail +lensdojo "-test /=$DESK=/tests ~" diff --git a/.github/workflows/hoon-feature.yml b/.github/workflows/hoon-feature.yml new file mode 100644 index 0000000..ce1b183 --- /dev/null +++ b/.github/workflows/hoon-feature.yml @@ -0,0 +1,13 @@ +name: 'Hoon: Pull request' + +on: + pull_request: + paths: + - '.github/scripts/hoon/**.yml' + - '.github/workflows/hoon-feature.yml' + - '.github/workflows/hoon-shared.yml' + - 'hoon/scaffolding/**' + +jobs: + urbit: + uses: ./.github/workflows/hoon-shared.yml diff --git a/.github/workflows/hoon-shared.yml b/.github/workflows/hoon-shared.yml new file mode 100644 index 0000000..1cd190e --- /dev/null +++ b/.github/workflows/hoon-shared.yml @@ -0,0 +1,23 @@ +on: + workflow_call: + +env: + URBIT_URL: 'https://urbit.org/install/linux-x86_64/latest' + PILL_URL: 'https://github.com/urbit/urbit/raw/master/bin/solid.pill' + URBIT_PIER: './pier' + DESK: 'sandbox' + +jobs: + build: + runs-on: 'ubuntu-latest' + steps: + - uses: actions/checkout@v3 + + - name: 'Boot fake ship' + run: ./.github/scripts/hoon/boot-ship.sh + + - name: 'Setup fake ship' + run: ./.github/scripts/hoon/setup-ship.sh + + - name: 'Test fake ship' + run: ./.github/scripts/hoon/test-ship.sh diff --git a/.github/workflows/hoon-status.yml b/.github/workflows/hoon-status.yml new file mode 100644 index 0000000..ef27dca --- /dev/null +++ b/.github/workflows/hoon-status.yml @@ -0,0 +1,15 @@ +name: 'Hoon: Push to status' + +on: + push: + branches: + - status + paths: + - '.github/scripts/hoon/**.yml' + - '.github/workflows/hoon-shared.yml' + - '.github/workflows/hoon-status.yml' + - 'hoon/scaffolding/**' + +jobs: + urbit: + uses: ./.github/workflows/hoon-shared.yml