-
Notifications
You must be signed in to change notification settings - Fork 26
test(upgradability): integration tests for the CMA #489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
2379e0d
d4520f0
4dd2e04
313bc15
ee52bd0
93de0c3
17b2f83
e0fda31
434ff3c
6d24b24
9244552
93a7e55
7b58970
2eecd12
1977521
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| name: Compact Contracts Integration Suite | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [labeled, synchronize] | ||
| schedule: | ||
| - cron: "0 6 * * *" # nightly at 06:00 UTC | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| run-integration: | ||
| # Run on scheduled/manual triggers, or on PRs carrying the `integration` label. | ||
| if: > | ||
| github.event_name == 'schedule' || | ||
| github.event_name == 'workflow_dispatch' || | ||
| (github.event_name == 'pull_request' && | ||
| contains(github.event.pull_request.labels.*.name, 'integration')) | ||
| name: Run Integration Suite | ||
| runs-on: ubuntu-24.04 | ||
| permissions: | ||
| contents: read | ||
| timeout-minutes: 30 | ||
|
|
||
| steps: | ||
| - name: Harden Runner | ||
| uses: step-security/harden-runner@fe104658747b27e96e4f7e80cd0a94068e53901d # v2.16.1 | ||
| with: | ||
| egress-policy: audit | ||
|
|
||
| - name: Check out code | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
| with: | ||
| fetch-depth: 2 | ||
|
|
||
| - name: Setup Environment | ||
| uses: ./.github/actions/setup | ||
|
|
||
| - name: Compile contracts | ||
| run: turbo compact --filter=@openzeppelin/compact-contracts | ||
|
|
||
| - name: Start local Midnight stack | ||
| run: make env-up | ||
|
|
||
| - name: Wait for local stack health | ||
| run: | | ||
| for i in $(seq 1 60); do | ||
| if docker compose -f local-env.yml ps --format json | \ | ||
| grep -q '"Health":"healthy"'; then | ||
| echo "Local stack healthy"; exit 0 | ||
| fi | ||
| sleep 5 | ||
| done | ||
| echo "Local stack did not become healthy in time" | ||
| docker compose -f local-env.yml ps | ||
| exit 1 | ||
|
|
||
| - name: Run integration tests | ||
| run: yarn test:integration | ||
|
|
||
| - name: Upload container logs on failure | ||
| if: failure() | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: midnight-stack-logs | ||
| path: logs/ | ||
| if-no-files-found: warn | ||
|
|
||
| - name: Tear down local stack | ||
| if: always() | ||
| run: make env-down | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,3 +46,5 @@ coverage | |
| *~ | ||
|
|
||
| *temp | ||
|
|
||
| .claude/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| COMPOSE_FILE := local-env.yml | ||
| LOGS_DIR := logs | ||
| SERVICES := proof-server indexer node | ||
|
|
||
| .PHONY: env-up env-down env-logs env-logs-clean env-status | ||
|
|
||
| ## Start local environment and stream logs to logs/ | ||
| env-up: env-down | ||
| docker compose -f $(COMPOSE_FILE) up -d | ||
| @mkdir -p $(LOGS_DIR) | ||
| @for svc in $(SERVICES); do \ | ||
| docker compose -f $(COMPOSE_FILE) logs -f --no-log-prefix $$svc > $(LOGS_DIR)/$$svc.log 2>&1 & \ | ||
| done | ||
| @echo "Logs streaming to $(LOGS_DIR)/" | ||
|
Comment on lines
+8
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wait for the stack to become ready before Line 9 only starts the containers; it does not guarantee that the node, indexer, and proof server are accepting requests yet. Since CI appears to run tests right after 🧰 Tools🪛 checkmake (0.3.2)[warning] 8-8: Target body for "env-up" exceeds allowed length of 5 lines (6). (maxbodylength) 🤖 Prompt for AI Agents |
||
|
|
||
| ## Stop local environment | ||
| env-down: | ||
| @-pkill -f "docker compose -f $(COMPOSE_FILE) logs" 2>/dev/null || true | ||
| docker compose -f $(COMPOSE_FILE) down | ||
|
|
||
| ## Tail all logs | ||
| env-logs: | ||
| tail -f $(LOGS_DIR)/*.log | ||
|
|
||
| ## Clear log files | ||
| env-logs-clean: | ||
| rm -rf $(LOGS_DIR)/*.log | ||
|
|
||
| ## Show container status | ||
| env-status: | ||
| docker compose -f $(COMPOSE_FILE) ps | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,8 +30,16 @@ | |
| "compact:security": "compact-compiler --dir security", | ||
| "compact:token": "compact-compiler --dir token", | ||
| "compact:utils": "compact-compiler --dir utils", | ||
| "compact:mocks": "compact-compiler --src-root mocks", | ||
| "compact:mocks:access": "compact-compiler --src-root mocks --dir access", | ||
| "compact:mocks:security": "compact-compiler --src-root mocks --dir security", | ||
| "compact:mocks:token": "compact-compiler --src-root mocks --dir token", | ||
| "compact:mocks:utils": "compact-compiler --src-root mocks --dir utils", | ||
| "compact:integration-mocks": "compact-compiler --src-root test/integration/_mocks", | ||
| "build": "compact-builder", | ||
| "test": "compact-compiler --skip-zk && vitest run", | ||
| "test:integration": "COMPACT_TOOLCHAIN_VERSION=0.30.0 yarn compact && COMPACT_TOOLCHAIN_VERSION=0.30.0 yarn compact:integration-mocks && vitest run --config vitest.integration.config.ts", | ||
| "test:integration:watch": "vitest --config vitest.integration.config.ts", | ||
|
Comment on lines
+41
to
+42
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Line 42 drops both the artifact generation and the pinned 🤖 Prompt for AI Agents |
||
| "types": "tsc -p tsconfig.json --noEmit", | ||
| "clean": "git clean -fXd" | ||
| }, | ||
|
|
@@ -42,11 +50,45 @@ | |
| "@openzeppelin-compact/compact": "workspace:^" | ||
| }, | ||
| "devDependencies": { | ||
| "@apollo/client": "^3.11.8", | ||
| "@midnight-ntwrk/compact-js": "2.5.0", | ||
| "@midnight-ntwrk/ledger-v8": "8.0.3", | ||
| "@midnight-ntwrk/midnight-js-contracts": "4.0.2", | ||
| "@midnight-ntwrk/midnight-js-http-client-proof-provider": "4.0.2", | ||
| "@midnight-ntwrk/midnight-js-indexer-public-data-provider": "4.0.2", | ||
| "@midnight-ntwrk/midnight-js-level-private-state-provider": "4.0.2", | ||
| "@midnight-ntwrk/midnight-js-network-id": "4.0.2", | ||
| "@midnight-ntwrk/midnight-js-node-zk-config-provider": "4.0.2", | ||
| "@midnight-ntwrk/midnight-js-types": "4.0.2", | ||
| "@midnight-ntwrk/midnight-js-utils": "4.0.2", | ||
| "@midnight-ntwrk/testkit-js": "4.0.2", | ||
| "@midnight-ntwrk/wallet-sdk-address-format": "3.1.0", | ||
| "@midnight-ntwrk/wallet-sdk-dust-wallet": "3.0.0", | ||
| "@midnight-ntwrk/wallet-sdk-facade": "3.0.0", | ||
| "@midnight-ntwrk/wallet-sdk-hd": "3.0.1", | ||
| "@midnight-ntwrk/wallet-sdk-shielded": "2.1.0", | ||
| "@midnight-ntwrk/wallet-sdk-unshielded-wallet": "2.1.0", | ||
| "@openzeppelin-compact/contracts-simulator": "workspace:^", | ||
| "@scure/bip39": "^1.2.1", | ||
| "@tsconfig/node24": "^24.0.4", | ||
| "@types/node": "24.10.0", | ||
| "axios": "^1.12.0", | ||
| "buffer": "^6.0.3", | ||
| "cross-fetch": "^4.0.0", | ||
| "effect": "^3.20.0", | ||
| "fetch-retry": "^6.0.0", | ||
| "graphql": "^16.8.1", | ||
| "graphql-ws": "^5.16.0", | ||
| "isomorphic-ws": "^5.0.0", | ||
| "level": "^8.0.1", | ||
| "pino": "^9.7.0", | ||
| "pino-pretty": "^13.0.0", | ||
| "rxjs": "^7.8.1", | ||
| "superjson": "^2.2.1", | ||
| "testcontainers": "^10.28.0", | ||
| "ts-node": "^10.9.2", | ||
| "typescript": "^5.9.3", | ||
| "vitest": "^4.1.2" | ||
| "vitest": "^4.1.2", | ||
| "ws": "^8.16.0" | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Health-check loop exits as soon as ONE service is healthy — tests may fire before the indexer is ready.
grep -q '"Health":"healthy"'succeeds on the first matching line, so the loop exits as soon as any service becomes healthy. Given thatnodehas a 2-second health-check interval andindexeronly starts afternodeis healthy (and then needs its own 10-second health-check cycle), the loop can exit while the indexer is still initialising. Integration tests that hit the indexer endpoint would fail flakily.Pin the loop exit to all three services being healthy:
🛠️ Proposed fix
- name: Wait for local stack health run: | for i in $(seq 1 60); do - if docker compose -f local-env.yml ps --format json | \ - grep -q '"Health":"healthy"'; then - echo "Local stack healthy"; exit 0 + healthy=$(docker compose -f local-env.yml ps --format json \ + | grep -c '"Health":"healthy"' || true) + if [ "$healthy" -ge 3 ]; then + echo "All 3 services healthy"; exit 0 fi sleep 5 done echo "Local stack did not become healthy in time" docker compose -f local-env.yml ps exit 1🤖 Prompt for AI Agents