build: add CI for Hoon code

This commit is contained in:
Alex Shelkovnykov 2023-03-04 17:24:08 +09:00
parent e585fe422f
commit 6cf84dfee3
6 changed files with 164 additions and 0 deletions

34
.github/scripts/hoon/boot-ship.sh vendored Executable file
View File

@ -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

66
.github/scripts/hoon/setup-ship.sh vendored Executable file
View File

@ -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

13
.github/scripts/hoon/test-ship.sh vendored Executable file
View File

@ -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 ~"

13
.github/workflows/hoon-feature.yml vendored Normal file
View File

@ -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

23
.github/workflows/hoon-shared.yml vendored Normal file
View File

@ -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

15
.github/workflows/hoon-status.yml vendored Normal file
View File

@ -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