Skip to content
Draft
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
53 changes: 52 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,17 @@ jobs:
- name: Docs (warnings as errors)
run: mix docs --warnings-as-errors

- uses: actions/setup-node@v5
with:
node-version: "22"
cache: npm
cache-dependency-path: spec/package-lock.json

- name: Generate id pool model traces
run: |
npm ci --prefix spec
spec/traces.sh "$RUNNER_TEMP/model-traces"

- name: Create and migrate test DB
env:
MIX_ENV: test
Expand All @@ -112,11 +123,12 @@ jobs:
- name: Test + coverage (warnings as errors)
env:
MIX_ENV: test
HYPER_MODEL_TRACES: ${{ runner.temp }}/model-traces
# coveralls.json wraps `mix test` (so --no-start / --warnings-as-errors
# still apply) and writes cover/excoveralls.json for the Codecov upload.
# --no-start: the supervision tree provisions a real Firecracker host
# under /srv/hyper, unavailable on a CI runner.
run: mix coveralls.json --no-start --warnings-as-errors
run: mix coveralls.json --no-start --warnings-as-errors --include model

# !cancelled() (not always()) uploads results on test PASS or FAIL -- the
# point of Test Analytics is failure/flake history -- while still skipping
Expand All @@ -143,6 +155,14 @@ jobs:
name: elixir-test-results
path: _build/test/junit.xml

- name: Upload id pool model traces
if: ${{ failure() }}
uses: actions/upload-artifact@v7
with:
name: id-pool-model-traces
path: ${{ runner.temp }}/model-traces
if-no-files-found: ignore

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v7
with:
Expand All @@ -166,6 +186,37 @@ jobs:
- name: ShellCheck
run: git ls-files -z '*.sh' | xargs -0 -r shellcheck

spec:
name: Quint specs
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v7

- uses: actions/setup-node@v5
with:
node-version: "22"
cache: npm
cache-dependency-path: spec/package-lock.json

- uses: actions/setup-java@v6
with:
distribution: temurin
java-version: "21"

- name: Cache Apalache and TLC
uses: actions/cache@v6
with:
path: ~/.quint
key: ${{ runner.os }}-quint-apalache-${{ hashFiles('spec/package-lock.json') }}

- name: Install Quint
run: npm ci
working-directory: spec

- name: Check specs
run: spec/check.sh

# One job for the whole native/ workspace: guest-agent, hyperrs-elfsum,
# suidhelper and xtask. The guest agent and xtask are otherwise only built by
# Mix compilers, where cargo warnings scroll past without failing the build.
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,5 @@ docs/superpowers/
/test/grpc/generated/
/test/grpc/junit.xml
.DS_Store
/spec/node_modules/
/spec/_apalache-out/
75 changes: 75 additions & 0 deletions spec/check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/usr/bin/env bash
set -euo pipefail

cd "$(dirname "$0")"

quint() { node_modules/.bin/quint "$@"; }

holds() {
[ $# -ge 2 ] || {
echo "usage: holds spec main [flag...]" >&2
return 2
}
local spec=$1 main=$2
shift 2
echo "holds: $main $*"
quint compile "$spec" --main "$main" --target json "$@" >"$log"
grep -q '"name":"q::inv"' "$log" || {
echo "$main checks no invariant" >&2
return 1
}
quint verify "$spec" --main "$main" --backend tlc "$@" >"$log" 2>&1 || {
cat "$log" >&2
return 1
}
grep "distinct states found" "$log"
}

violates() {
[ $# -ge 3 ] || {
echo "usage: violates spec main invariant [flag...]" >&2
return 2
}
local spec=$1 main=$2 invariant=$3
shift 3
echo "violates: $main $invariant $*"
if quint verify "$spec" --main "$main" --backend tlc --invariant "$invariant" "$@" >"$log" 2>&1; then
echo "$main no longer violates $invariant: move it to a holds line" >&2
return 1
fi
grep -q "Invariant q_inv is violated" "$log" || {
cat "$log" >&2
return 1
}
}

log=$(mktemp)
trap 'rm -f "$log"' EXIT

for spec in *.qnt; do
quint typecheck "$spec"
done

holds id_pool.qnt id_pool_small

violates id_pool.qnt id_pool_small freedUnused --step stepTransientRestart
violates id_pool.qnt id_pool_small idExclusive --step stepPoolRestart

holds placement.qnt placement_reliable
holds placement.qnt placement_lossy

violates placement.qnt placement_reliable runningWithinCapacity
violates placement.qnt placement_lossy unreachableLeavesNothingAdmitted
violates placement.qnt placement_hard_crash admittedWithinCapacity
violates placement.qnt placement_vm_respawn admittedWithinCapacity
violates placement.qnt placement_retrying placedAtMostOnce
violates placement.qnt placement_trusting reservationsWithinCapacity

holds image_store.qnt image_store_leased
holds image_store.qnt image_store_recreate
holds image_store.qnt image_store_fork_vs_delete

violates image_store.qnt image_store_as_built mountedChainsPresent
violates image_store.qnt image_store_unfenced mountedChainsPresent
violates image_store.qnt image_store_failed_drop layersHaveFiles
violates image_store.qnt image_store_shared_delta layersHaveFiles
Loading
Loading