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.