name: Test # Publishing only happens on v* tags (publish.yml), so this is what # keeps plain main pushes honest between releases. on: push: branches: [main] pull_request: jobs: test: runs-on: bare env: # Same shared-toolchain/cache story as publish.yml. CARGO_HOME: /var/local/cargo RUSTUP_HOME: /var/local/rustup PATH: /var/local/cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/bin SCCACHE_DIR: /var/local/sccache SCCACHE_SERVER_PORT: "4228" CARGO_TARGET_DIR: /var/local/cargo-target steps: - uses: actions/checkout@v4 # A throwaway JetStream for tests/jetstream.rs. Best effort: if the # runner cannot use docker the variable stays unset and that one # test reports itself skipped rather than failing the build. - name: Start a throwaway JetStream run: | docker rm -f portal-test-nats >/dev/null 2>&1 || true if docker run -d --rm --name portal-test-nats -p 127.0.0.1:14223:4222 nats:2.14.6-alpine -js >/dev/null 2>&1; then sleep 2 echo "PORTAL_TEST_NATS_URL=nats://127.0.0.1:14223" >> "$GITHUB_ENV" else echo "::warning::no docker on this runner - the JetStream integration test will be skipped" fi - name: Test run: cargo test --features ssr # Every plan under plans/ built deterministically and held to the # lint, both by this very portal: a builder change that renders a # site the lint rejects fails here, not at the next training run. # (portal-trainer's CI did this until the trainer moved in.) - name: Build and lint every plan run: | set -euo pipefail cargo build --features ssr --bin portal bin="$CARGO_TARGET_DIR/debug/portal" tmp=$(mktemp -d) lint="$tmp/portal-lint" printf '#!/bin/sh\nexec %s lint "$@"\n' "$bin" > "$lint" && chmod +x "$lint" for plan in plans/*.yaml; do name=$(basename "$plan" .yaml) echo "== $plan" rm -rf "$tmp/plan-$name" "$bin" build --plan "$plan" --out "$tmp/plan-$name" --lint "$lint" done - name: Stop the throwaway JetStream if: always() run: docker rm -f portal-test-nats >/dev/null 2>&1 || true