From 52c28104dbe8e746f8fd8af16037a0e3a20acce3 Mon Sep 17 00:00:00 2001 From: dkijania Date: Mon, 29 Jun 2026 08:37:38 +0200 Subject: [PATCH] test: enforce coverage floor + nightly live tests for devnet/mainnet/mesa Two gaps from the test-coverage audit (#181): no coverage threshold in CI, and no live integration tests against real per-network data (devnet existed only as a static dump; mainnet was one skipped endpoint; mesa had none). - Add a coverage gate to `test:coverage` via c8 `--check-coverage` (lines 50, functions 50, statements 50, branches 80). Current coverage (~53% lines, 95% branches) clears it; the floor blocks regressions and rises as the suite grows. - Add a `test:live-api` script that runs the live-api suite against `STAGING_GRAPHQL_ENDPOINT`. - Add the `Live Integration` workflow: nightly + manual, runs the live-api suite against devnet/mainnet/mesa using per-network repo variables (`*_ARCHIVE_API_URL`), skipping any network without a configured endpoint so it stays green until they're set. `fail-fast: false` keeps networks independent. - Document the setup and the remaining `actions`/successful-`zkappCommands` fixture work in the live-api README. Closes #181. Co-Authored-By: Claude Opus 4.8 (1M context) Claude-Session: https://claude.ai/code/session_01QSuak9smCHbp4N17xjjLF6 --- .github/workflows/live-integration.yaml | 54 +++++++++++++++++++++++++ package.json | 3 +- tests/live-api/README.md | 25 ++++++++++++ 3 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/live-integration.yaml diff --git a/.github/workflows/live-integration.yaml b/.github/workflows/live-integration.yaml new file mode 100644 index 0000000..2323f95 --- /dev/null +++ b/.github/workflows/live-integration.yaml @@ -0,0 +1,54 @@ +name: Live Integration + +# Read-only integration tests against deployed Archive Node API endpoints on each +# network. Scheduled (not on PRs) so schema/query drift against real data is +# caught without slowing the PR loop. Endpoints come from repo variables; a +# network with no configured URL is skipped, so this stays green until they're set. + +on: + schedule: + - cron: '0 5 * * *' # nightly + workflow_dispatch: + +permissions: + contents: read + +jobs: + live-api: + name: live-api (${{ matrix.network }}) + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + network: [devnet, mainnet, mesa] + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '22' + - run: npm ci + + - name: Resolve endpoint for ${{ matrix.network }} + id: endpoint + env: + DEVNET_URL: ${{ vars.DEVNET_ARCHIVE_API_URL }} + MAINNET_URL: ${{ vars.MAINNET_ARCHIVE_API_URL }} + MESA_URL: ${{ vars.MESA_ARCHIVE_API_URL }} + run: | + case "${{ matrix.network }}" in + devnet) URL="$DEVNET_URL" ;; + mainnet) URL="$MAINNET_URL" ;; + mesa) URL="$MESA_URL" ;; + esac + if [ -z "$URL" ]; then + echo "No endpoint configured for ${{ matrix.network }} (set the *_ARCHIVE_API_URL repo variable); skipping." + echo "skip=true" >> "$GITHUB_OUTPUT" + else + echo "url=$URL" >> "$GITHUB_OUTPUT" + fi + + - name: Run live-api tests against ${{ matrix.network }} + if: steps.endpoint.outputs.skip != 'true' + env: + STAGING_GRAPHQL_ENDPOINT: ${{ steps.endpoint.outputs.url }} + run: npm run test:live-api diff --git a/package.json b/package.json index 3c71d02..f809b79 100644 --- a/package.json +++ b/package.json @@ -25,8 +25,9 @@ "dev": "cross-env NODE_NO_WARNINGS=1 npx nodemon --exec 'node -r dotenv/config --loader ts-node/esm' src/index.ts", "test": "./run-tests.sh", "test:unit": "npm run build && (ec=0; for f in ./build/tests/unit/*test.js ./build/tests/utils.test.js ./build/tests/services/*/*.test.js; do node --enable-source-maps --test \"$f\" || ec=$?; done; exit $ec)", - "test:coverage": "npm run build && npx c8 --include 'build/src/**' --reporter text --reporter lcov -- bash -c 'ec=0; for f in ./build/tests/unit/*test.js ./build/tests/utils.test.js ./build/tests/services/*/*.test.js; do node --enable-source-maps --test \"$f\" || ec=$?; done; exit $ec'", + "test:coverage": "npm run build && npx c8 --include 'build/src/**' --check-coverage --lines 50 --functions 50 --statements 50 --branches 80 --reporter text --reporter lcov -- bash -c 'ec=0; for f in ./build/tests/unit/*test.js ./build/tests/utils.test.js ./build/tests/services/*/*.test.js; do node --enable-source-maps --test \"$f\" || ec=$?; done; exit $ec'", "test:integration": "npm run build && (ec=0; for f in ./build/tests/integration/*.test.js; do node --enable-source-maps --test \"$f\" || ec=$?; done; exit $ec)", + "test:live-api": "npm run build && node --enable-source-maps --test ./build/tests/live-api/*.test.js", "test:live-network": "npm run build && node --enable-source-maps --test-timeout 600000 --test ./build/tests/live-network/live-network.test.js", "test:devnet-dump": "npm run build && node --enable-source-maps --test-timeout 900000 --test ./build/tests/devnet-dump/devnet-dump.test.js", "clean": "rimraf ./build", diff --git a/tests/live-api/README.md b/tests/live-api/README.md index 5e2c816..e01389a 100644 --- a/tests/live-api/README.md +++ b/tests/live-api/README.md @@ -36,8 +36,33 @@ STAGING_GRAPHQL_ENDPOINT=http://localhost:4000 LIVE_API_TESTS=true npm test # Include pending-chain tests (requires DB access) PG_CONN=postgresql://user:pass@host:5432/archive LIVE_API_TESTS=true npm test + +# Run just the live-api suite directly against an endpoint +STAGING_GRAPHQL_ENDPOINT=https://my-archive-api npm run test:live-api ``` +## Nightly multi-network runs (CI) + +The [`Live Integration`](../../.github/workflows/live-integration.yaml) workflow +runs this suite nightly against **devnet, mainnet, and mesa** to catch schema or +query drift against each network's real data without slowing the PR loop. + +Each network's endpoint is read from a repository variable; a network with no +configured URL is skipped (so the job stays green until it's set): + +| Repo variable | Network | +|---------------|---------| +| `DEVNET_ARCHIVE_API_URL` | devnet | +| `MAINNET_ARCHIVE_API_URL` | mainnet | +| `MESA_ARCHIVE_API_URL` | mesa | + +Set them under **Settings → Secrets and variables → Actions → Variables**, or +trigger the workflow manually from the Actions tab. + +> Note: `actions.test.ts` is still a placeholder — it needs a known mainnet/mesa +> zkApp with actions to snapshot fixtures against. Filling that in (and adding a +> successful-`zkappCommands` fixture) is the remaining piece of test coverage. + ## Fixtures The `fixtures/` directory contains expected responses snapshotted from known-good API output. Each fixture file is named `
__.json` corresponding to the query parameters used.