Skip to content

fix: ci/cd tests#76

Merged
GabrielePicco merged 10 commits intomainfrom
fix/ci-cd
Apr 25, 2026
Merged

fix: ci/cd tests#76
GabrielePicco merged 10 commits intomainfrom
fix/ci-cd

Conversation

@GabrielePicco
Copy link
Copy Markdown
Contributor

@GabrielePicco GabrielePicco commented Apr 24, 2026

Summary by CodeRabbit

  • Tests
    • Streamlined CI/test scripts to skip heavy local validator startup, improving runtime.
    • Improved failure diagnostics with richer log capture and clearer error reporting.
    • Hardened cleanup and terminal restoration for more stable test runs.
  • Chores
    • Switched local test cluster default to localnet and adjusted ignore rules for deploy artifacts.
    • Updated on-chain program identifiers and added corresponding deploy key artifacts.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 24, 2026

Warning

Rate limit exceeded

@GabrielePicco has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 23 minutes and 54 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 23 minutes and 54 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 50594a69-5608-49a4-baa0-2838ace08936

📥 Commits

Reviewing files that changed from the base of the PR and between 4fb692e and 5731f2a.

📒 Files selected for processing (3)
  • .github/workflows/test-examples.yml
  • anchor-counter/tests/private-counter.ts
  • anchor-counter/tests/public-counter.ts

Walkthrough

CI workflow removes local and ephemeral validator startup; test script gains robust validator handling, TTY support, improved readiness checks, log capture, and cluster override behavior; Anchor projects switch provider cluster to localnet, update program IDs, add deploy keypair artifacts, and adjust gitignore entries.

Changes

Cohort / File(s) Summary
CI Workflow
.github/workflows/test-examples.yml
Removes background launch and readiness polling for mb-test-validator and ephemeral validator; simplifies validator limits step to only adjust sysctl inotify limits; changes anchor test invocation/environment for anchor-counter.
End-to-end test script
fullstack-test.sh
Adds cluster override precedence, TTY restoration (stty sane), robust start/cleanup for validators (iterative TERM/KILL), Python pseudo-TTY spawn for ephemeral validator, slot-based readiness checks, sanitized validator log dumping and stronger failure diagnostics.
Anchor project config
anchor-counter/Anchor.toml
Switches provider cluster from devnet to localnet.
Program IDs
anchor-counter/programs/private-counter/src/lib.rs, anchor-counter/programs/public-counter/src/lib.rs
Updates Anchor declare_id! values (new program public keys).
Deploy artifacts
anchor-counter/target/deploy/private_counter-keypair.json, anchor-counter/target/deploy/public_counter-keypair.json
Adds keypair JSON deployment artifact files containing private/public keybyte arrays.
Gitignore changes
.gitignore, anchor-counter/.gitignore
Replaces a specific keypair ignore with broader deploy/ ignore rules while preserving *-keypair.json patterns; retains other existing ignores.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • jonasXchen
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'fix: ci/cd tests' is vague and generic, providing minimal insight into the specific changes made beyond indicating a CI/CD fix. Consider a more specific title that describes the actual changes, such as 'fix: refactor validator startup and cluster configuration in tests' or 'fix: improve test resilience with enhanced validator handling and local cluster support'.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/ci-cd

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 24, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
er-rolldice Ready Ready Preview, Comment Apr 25, 2026 8:10pm
magicblock-counter-example Ready Ready Preview, Comment Apr 25, 2026 8:10pm
magicblock-engine-examples Ready Ready Preview, Comment Apr 25, 2026 8:10pm
magicblock-rewards-dashboard Ready Ready Preview, Comment Apr 25, 2026 8:10pm
spl-tokens Ready Ready Preview, Comment Apr 25, 2026 8:10pm

Request Review

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.github/workflows/test-examples.yml (1)

43-45: 🧹 Nitpick | 🔵 Trivial

Pin the MagicBlock Ephemeral Validator to a specific version.

Using @latest in CI workflows silently picks up new major/minor versions on every run, producing non-reproducible builds that fail for reasons unrelated to code changes. Pin to a known-good version (e.g., 0.8.3) and use Dependabot/Renovate for automated updates.

Suggested change
       - name: Install MagicBlock Ephemeral Validator
         run: |
-          npm install -g `@magicblock-labs/ephemeral-validator`@latest
+          npm install -g `@magicblock-labs/ephemeral-validator`@0.8.3
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/test-examples.yml around lines 43 - 45, The CI step
"Install MagicBlock Ephemeral Validator" currently installs
`@magicblock-labs/ephemeral-validator`@latest which causes non-reproducible
builds; change the installer to use a pinned, known-good version (for example
replace `@latest` with `@0.8.3`) in the step named "Install MagicBlock Ephemeral
Validator" and rely on Dependabot/Renovate to automate future updates.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/test-examples.yml:
- Around line 52-62: The CI runs plain `anchor test` which starts Anchor's local
validator and then conflicts with fullstack-test.sh's validator management;
modify the "Test anchor-counter" step to invoke `anchor test
--skip-local-validator --skip-build --skip-deploy` (so fullstack-test.sh keeps
control of the validator lifecycle) while keeping the preceding `yarn install`
and working directory change; reference the `anchor test` invocation, the
`fullstack-test.sh` script, and the Anchor.toml cluster="localnet" behavior when
making the change.

In `@fullstack-test.sh`:
- Around line 258-265: The else branch after the check for
/tmp/ephemeral-validator.log is misleading because it runs only when the file
does not exist; update the message to reflect that the log was not produced
(e.g., echo "No startup log found at /tmp/ephemeral-validator.log — the process
may not have produced output") or simply remove the else branch entirely; locate
the if block that tests [ -f /tmp/ephemeral-validator.log ] and adjust the echo
in the else branch accordingly.

---

Outside diff comments:
In @.github/workflows/test-examples.yml:
- Around line 43-45: The CI step "Install MagicBlock Ephemeral Validator"
currently installs `@magicblock-labs/ephemeral-validator`@latest which causes
non-reproducible builds; change the installer to use a pinned, known-good
version (for example replace `@latest` with `@0.8.3`) in the step named "Install
MagicBlock Ephemeral Validator" and rely on Dependabot/Renovate to automate
future updates.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 818b231d-4e92-43a3-9267-e67d35438bf0

📥 Commits

Reviewing files that changed from the base of the PR and between 0db2bf8 and 53d3634.

📒 Files selected for processing (2)
  • .github/workflows/test-examples.yml
  • fullstack-test.sh

Comment thread .github/workflows/test-examples.yml Outdated
Comment thread fullstack-test.sh Outdated
- Wrap ephemeral-validator in a pty (python3) so its mandatory ratatui/crossterm
  TUI sees a controlling terminal; without one it silently exits 0 before
  binding port 7799, both in CI and when invoked from a non-tty bg job.
- Move test endpoint env vars (PROVIDER_ENDPOINT, EPHEMERAL_PROVIDER_ENDPOINT,
  TEE_PROVIDER_ENDPOINT, ROUTER_ENDPOINT, WS variants) to the workflow step so
  the test runner doesn't fall back to devnet defaults. Tests read these
  directly; setting them inside fullstack-test.sh leaked project conventions
  into the script.
- Set anchor-counter Anchor.toml cluster to "localnet" so the merge of main
  into this branch keeps localnet (was reverting to "devnet" via 3-way merge).
- Commit private-/public-counter program keypairs and update .gitignore so
  deploy doesn't fail with DeclaredProgramIdMismatch on fresh clones; declare_id!()
  values now match the committed keypairs (no anchor keys sync needed).
- fullstack-test.sh: wait for the upstream validator to be producing slots
  (commitment=processed) before starting ephemeral-validator; portable sed -E
  for slot extraction (BSD vs GNU); harden the kill of anchor's pre-flight
  validator with SIGTERM->SIGKILL and a port-free poll; honor --provider.cluster
  override from the anchor CLI; print mb-test-validator log on ephemeral failure
  with ANSI codes stripped.
- Workflow: set kernel inotify limits ahead of time, raise nofile via prlimit
  in the same step as anchor test (prlimit on $$ doesn't propagate across
  GitHub Actions step shells).
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/test-examples.yml:
- Around line 57-69: anchor-counter's package.json lacks the
`@magicblock-labs/ephemeral-validator` dependency, so running yarn install before
anchor test won't install the binaries required by ../fullstack-test.sh; update
anchor-counter/package.json by adding "@magicblock-labs/ephemeral-validator":
"0.8.8" to the "dependencies" (not devDependencies) so the ephemeral-validator
and mb-test-validator binaries are available when running anchor test
--provider.cluster localnet.

In `@anchor-counter/programs/public-counter/src/lib.rs`:
- Line 6: Update the hardcoded program ID constants in
anchor-counter/app/src/App.tsx: replace the values assigned to
PUBLIC_COUNTER_PROGRAM and PRIVATE_COUNTER_PROGRAM with the new declared IDs
from the on-chain program (public: A4D1N6zdiwtAFr7mQcHkNbk2yXmDcpvovvU5D27kZoGv,
private: 7Y2rYVGqRY31m7ogMHjmtdRMUjeWakoJ6iVx12i6voCY) so PDA derivation and
program client instantiation use the correct program IDs (search for the
PUBLIC_COUNTER_PROGRAM and PRIVATE_COUNTER_PROGRAM constants and update their
PublicKey string literals accordingly).

In `@fullstack-test.sh`:
- Around line 323-343: Add a fast preflight check to ensure python3 is available
before running the background wrapper: test for the `python3` binary (used by
the `python3 -c '...'` invocation that runs `pty.spawn`) and fail with a clear
error if missing so the script doesn't silently continue; then keep launching
the wrapper and capture its PID in `EPHEMERAL_VALIDATOR_PID=$!` as before. Also
add a brief inline comment near `EPHEMERAL_VALIDATOR_PID`/`cleanup` explaining
that `pty.spawn()` does not forward signals to the spawned `ephemeral-validator`
process, so `cleanup` must still kill the validator itself (e.g. via the
existing `pkill -f "ephemeral-validator"`) rather than relying on terminating
the python wrapper.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: fa09895e-92f2-4d8f-83cf-aae7e5477f8c

📥 Commits

Reviewing files that changed from the base of the PR and between 53d3634 and 4fb692e.

⛔ Files ignored due to path filters (1)
  • anchor-counter/yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (9)
  • .github/workflows/test-examples.yml
  • .gitignore
  • anchor-counter/.gitignore
  • anchor-counter/Anchor.toml
  • anchor-counter/programs/private-counter/src/lib.rs
  • anchor-counter/programs/public-counter/src/lib.rs
  • anchor-counter/target/deploy/private_counter-keypair.json
  • anchor-counter/target/deploy/public_counter-keypair.json
  • fullstack-test.sh

Comment thread .github/workflows/test-examples.yml
Comment thread anchor-counter/programs/public-counter/src/lib.rs
Comment thread fullstack-test.sh
- Tests construct wsEndpoint by replacing http:// → ws:// while keeping the
  RPC port. Solana convention uses RPC on port N and WS on N+1, so
  http://127.0.0.1:8899 was producing ws://127.0.0.1:8899 instead of
  ws://127.0.0.1:8900, leading to TransactionExpiredTimeoutError when
  sendAndConfirm couldn't subscribe for confirmation.
- Honor explicit WS_ENDPOINT / EPHEMERAL_WS_ENDPOINT / TEE_WS_ENDPOINT env
  vars and fall back to undefined (web3.js auto-derive, which correctly
  bumps the port).
- Workflow: pass the matching WS env vars so localnet runs subscribe to the
  right port.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5731f2aa2a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


[provider]
cluster = "devnet"
cluster = "localnet"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep default cluster aligned with test endpoint defaults

Changing the default provider cluster to localnet makes anchor test enter the local-validator path by default, but the test files still default their base-layer RPC to devnet when PROVIDER_ENDPOINT is unset (anchor-counter/tests/public-counter.ts and private-counter.ts), and fullstack-test.sh does not export PROVIDER_ENDPOINT/WS_ENDPOINT for local runs. In a normal local invocation (cd anchor-counter && anchor test), this now deploys programs to localnet while the test client sends transactions to devnet, which leads to consistent failures unless callers manually set extra env vars.

Useful? React with 👍 / 👎.

@GabrielePicco GabrielePicco merged commit 3bf92cb into main Apr 25, 2026
9 checks passed
@GabrielePicco GabrielePicco deleted the fix/ci-cd branch April 25, 2026 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant