Skip to content

Commit eb46c22

Browse files
committed
Add ci to auto-build and do simple smoke test
1 parent d938dfe commit eb46c22

2 files changed

Lines changed: 99 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Integration Test
2+
3+
on:
4+
repository_dispatch:
5+
types: [upstream-changed]
6+
push:
7+
branches: [kotlin]
8+
pull_request:
9+
branches: [kotlin]
10+
workflow_dispatch:
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
integration-test:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Enable KVM
23+
run: |
24+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
25+
sudo udevadm control --reload-rules
26+
sudo udevadm trigger --name-match=kvm
27+
28+
- name: Install Rust
29+
run: |
30+
rustup install --no-self-update 1.87 1.89
31+
rustup default 1.89
32+
rustup target add x86_64-unknown-none
33+
34+
- name: Install clang
35+
run: sudo apt-get install -y clang
36+
37+
- uses: extractions/setup-just@v2
38+
39+
- name: Install wasm-tools
40+
run: cargo install --locked wasm-tools
41+
42+
- uses: actions/setup-java@v4
43+
with:
44+
distribution: 'temurin'
45+
java-version: '21'
46+
47+
# need this for the clones in the justfile to succeed
48+
- name: Configure Git to use HTTPS instead of SSH
49+
run: git config --global url."https://github.com/".insteadOf git@github.com:
50+
51+
- name: Build
52+
run: just build
53+
54+
- name: Smoke test
55+
run: |
56+
just run &
57+
SERVER_PID=$!
58+
trap "kill $SERVER_PID 2>/dev/null || true" EXIT
59+
60+
for i in $(seq 1 30); do
61+
if curl -s http://localhost:3000 > /dev/null 2>&1; then
62+
break
63+
fi
64+
sleep 4
65+
done
66+
67+
./smokeTest.sh

smokeTest.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
url=${1:-"http://localhost:3000"}
5+
failures=0
6+
7+
check() {
8+
local desc=$1 pattern=$2
9+
shift 2
10+
if "$@" | grep -qi "$pattern"; then
11+
echo "PASS: $desc"
12+
else
13+
echo "FAIL: $desc"
14+
failures=$((failures + 1))
15+
fi
16+
}
17+
18+
check "GET / returns 200" "200" \
19+
curl -s -o /dev/null -w '%{http_code}' "$url"
20+
21+
check "POST /echo echoes body" "hola mundo" \
22+
curl -s -d "hola mundo" "$url/echo"
23+
24+
check "GET /echo-headers reflects custom header" "x-language: spanish" \
25+
curl -s -I -H "x-language: spanish" "$url/echo-headers"
26+
27+
check "GET /idontexist returns 404" "404" \
28+
curl -s -o /dev/null -w '%{http_code}' "$url/idontexist"
29+
30+
echo ""
31+
[ "$failures" -gt 0 ] && echo "$failures test(s) failed" && exit 1
32+
echo "All tests passed"

0 commit comments

Comments
 (0)