Skip to content
Open
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 156 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
name: Test Examples

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
Comment on lines +3 to +8
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Tighten trigger syntax to satisfy yamllint

yamllint flags the current trigger block (on, [ main ]). Quote the key and drop the extra spaces to clear the errors:

-on:
-  push:
-    branches: [ main ]
-  pull_request:
-    branches: [ main ]
+'on':
+  push:
+    branches: [main]
+  pull_request:
+    branches: [main]
🧰 Tools
🪛 YAMLlint (1.37.1)

[warning] 3-3: truthy value should be one of [false, true]

(truthy)


[error] 5-5: too many spaces inside brackets

(brackets)


[error] 5-5: too many spaces inside brackets

(brackets)


[error] 7-7: too many spaces inside brackets

(brackets)


[error] 7-7: too many spaces inside brackets

(brackets)

🤖 Prompt for AI Agents
In .github/workflows/test.yml around lines 3 to 8, tighten the GitHub Actions
trigger syntax to satisfy yamllint by removing the extra spaces in the branches
array and quoting keys/strings: replace occurrences like branches: [ main ] with
branches: ["main"] (no spaces inside the brackets) and ensure any YAML keys or
string values flagged by yamllint are quoted as required (e.g., "on" or branch
names) so the trigger block is valid.


jobs:
test-examples:
runs-on: ubuntu-latest

Comment on lines +10 to +13
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Optional: Add Cargo cache to speed builds.

Caching target/registry cuts CI time and bandwidth.

    steps:
      - uses: actions/checkout@v4

      - name: Cache cargo
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-
🤖 Prompt for AI Agents
In .github/workflows/test.yml around lines 10 to 13 the job currently lacks
Cargo caching which slows CI; add a cache step after the checkout that uses
actions/cache@v4 to cache ~/.cargo/registry, ~/.cargo/git and target, with a key
like ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} and a restore-keys
entry ${{ runner.os }}-cargo- so subsequent runs restore the registry/git crates
and target build artifacts to speed builds and reduce bandwidth.

steps:
- uses: actions/checkout@v4

- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: '1.82'
override: true
Comment on lines +17 to +21
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Replace the deprecated Rust setup action.

actions-rs/toolchain@v1 is stuck on the retired Node12 runtime, so this step fails before installing Rust. Switch to a maintained action (e.g., dtolnay/rust-toolchain@master with toolchain: 1.82) so the workflow can provision Rust successfully.

🧰 Tools
🪛 actionlint (1.7.8)

18-18: the runner of "actions-rs/toolchain@v1" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🤖 Prompt for AI Agents
.github/workflows/test.yml around lines 17 to 21: the workflow uses the
deprecated actions-rs/toolchain@v1 which runs on a retired Node12 runtime and
fails; replace that step with a maintained action such as
dtolnay/rust-toolchain@master and set the input to toolchain: '1.82' (remove the
deprecated override flag), ensuring the step name and inputs match the new
action's expected keys so the workflow can provision Rust successfully.


Comment on lines +17 to +22
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Replace the deprecated Rust toolchain action

actions-rs/toolchain@v1 now targets the removed Node12 runtime, so the step fails before the workflow can install Rust. Switch to a maintained setup action. For example:

-    - name: Setup Rust
-      uses: actions-rs/toolchain@v1
-      with:
-        toolchain: '1.82'
-        override: true
+    - name: Setup Rust
+      uses: dtolnay/rust-toolchain@master
+      with:
+        toolchain: 1.82
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: '1.82'
override: true
- name: Setup Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.82
🧰 Tools
🪛 actionlint (1.7.7)

18-18: the runner of "actions-rs/toolchain@v1" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🤖 Prompt for AI Agents
In .github/workflows/test.yml around lines 17-22, the workflow uses the
deprecated actions-rs/toolchain@v1 (Node12 runtime) which fails; replace that
step with a maintained setup action such as dtolnay/setup-rust@v1 (or
actions-rs/toolchain@v2 if available) and set the rust-version input to '1.82'
(remove the Node12-specific override), e.g., swap the uses line to
dtolnay/setup-rust@v1 and provide rust-version: '1.82' so the workflow installs
Rust with a supported action.

- name: Install Solana
run: |
sh -c "$(curl -sSfL https://release.anza.xyz/v2.1.21/install)"
echo "$HOME/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH

- name: Install Anchor
run: |
cargo install --git https://github.com/coral-xyz/anchor avm --locked --force
avm install 0.31.1
avm use 0.31.1
echo "$HOME/.avm/bin" >> $GITHUB_PATH

- name: Install MagicBlock Ephemeral Validator
run: |
npm install -g @magicblock-labs/ephemeral-validator@latest

Comment on lines +35 to +38
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Pin Ephemeral Validator npm version for reproducibility

Installing @latest is brittle. Pin a known-good version to avoid sudden CI breaks.

-        npm install -g @magicblock-labs/ephemeral-validator@latest
+        npm install -g @magicblock-labs/ephemeral-validator@<pinned-version>

If you share the target version, I can update the diff.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Install MagicBlock Ephemeral Validator
run: |
npm install -g @magicblock-labs/ephemeral-validator@latest
- name: Install MagicBlock Ephemeral Validator
run: |
npm install -g @magicblock-labs/ephemeral-validator@<pinned-version>
🤖 Prompt for AI Agents
.github/workflows/test.yml around lines 35 to 38: the workflow installs
@magicblock-labs/ephemeral-validator using @latest which is brittle; change the
install step to pin a specific known-good semver (e.g., @1.2.3) or reference a
repository variable/GITHUB_REF for the approved release, updating the npm
install -g invocation to use that explicit version string (and if you want, add
a comment or workflow input to make future version updates explicit).

- name: Configure Solana
run: |
solana config set --url localhost
solana-keygen new --no-bip39-passphrase --silent --outfile ~/.config/solana/id.json

- name: Start Solana Test Validator
run: |
solana-test-validator \
--ledger ./my-ledger-1 \
--reset \
--clone mAGicPQYBMvcYveUZA5F5UNNwyHvfYh5xkLS2Fr1mev \
--clone EpJnX7ueXk7fKojBymqmVuCuwyhDQsYcLVL1XMsBbvDX \
--clone 7JrkjmZPprHwtuvtuGTXp9hwfGYFAQLnLeFM52kqAgXg \
--clone noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV \
--clone-upgradeable-program DELeGGvXpWV2fqJUhqcF5ZSYMS4JTLjteaAMARRSaeSh \
--clone Cuj97ggrhhidhbu39TijNVqE74xvKJ69gDervRUXAxGh \
--clone 5hBR571xnXppuCPveTrctfTU7tJLSN94nq7kv7FRK5Tc \
--clone F72HqCR8nwYsVyeVd38pgKkjXmXFzVAM8rjZZsXWbdE \
--clone vrfkfM4uoisXZQPrFiS2brY4oMkU9EWjyvmvqaFd5AS \
--clone-upgradeable-program Vrf1RNUjXmQGjmQrQLvJHs9SNkvDJEsRVFPkfSQUwGz \
--clone-upgradeable-program BTWAqWNBmF2TboMh3fxMJfgR16xGHYD7Kgr2dPwbRPBi \
--url https://api.devnet.solana.com &

# Wait for validator to be ready
timeout 30 bash -c 'until solana cluster-version --url http://localhost:8899 >/dev/null 2>&1; do sleep 1; done'

- name: Start MagicBlock Ephemeral Validator
run: |
# Magic voodoo to increase resource limits
sudo prlimit --pid $$ --nofile=1048576:1048576
sudo sysctl fs.inotify.max_user_instances=1280
sudo sysctl fs.inotify.max_user_watches=655360

RUST_LOG=info ephemeral-validator \
--accounts-lifecycle ephemeral \
--remote-cluster development \
--remote-url http://127.0.0.1:8899 \
--remote-ws-url ws://127.0.0.1:8900 \
--rpc-port 7799

# Wait for validator to be ready
timeout 20 bash -c 'until curl -s http://localhost:7799 >/dev/null 2>&1; do sleep 1; done'
Comment on lines 65 to 80
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Background the MagicBlock validator or run it and its wait logic in one step.

ephemeral-validator runs in the foreground here. Because it never exits, the wait loop on Line 80 and all subsequent steps are never reached, causing the job to hang. Either background the process (and add cleanup) or launch/wait/test within a single step before the process exits.

🤖 Prompt for AI Agents
.github/workflows/test.yml around lines 65–80: the workflow starts
ephemeral-validator in the foreground so the step never completes and the
subsequent wait/steps are never executed; fix by starting the validator in the
background and managing its lifecycle in the same step: launch
ephemeral-validator in background, save its PID, run the existing readiness loop
(curl until ready), run any tests that require the validator, then kill the
background PID and wait for it to exit (or use a trap to ensure cleanup on
failure); alternatively, keep the validator in-foreground but move the readiness
check and any tests into the same step that runs the validator and exit that
step only after readiness and tests complete.


- name: Build and Deploy anchor-counter
run: |
cd anchor-counter
anchor build && anchor deploy --provider.cluster localnet

- name: Test anchor-counter
run: |
cd anchor-counter
EPHEMERAL_PROVIDER_ENDPOINT="http://localhost:7799" \
EPHEMERAL_WS_ENDPOINT="ws://localhost:7800" \
anchor test \
--provider.cluster localnet \
--skip-local-validator \
--skip-build \
--skip-deploy

# - name: Test anchor-minter
# run: |
# cd anchor-minter
# yarn install
# EPHEMERAL_PROVIDER_ENDPOINT=http://localhost:7799 \
# EPHEMERAL_WS_ENDPOINT=ws://localhost:7800 \
# PROVIDER_ENDPOINT=http://localhost:8899 \
# WS_ENDPOINT=http://localhost:8900 \
# anchor test

# - name: Test anchor-rock-paper-scissor
# run: |
# cd anchor-rock-paper-scissor
# yarn install
# EPHEMERAL_PROVIDER_ENDPOINT=http://localhost:7799 \
# EPHEMERAL_WS_ENDPOINT=ws://localhost:7800 \
# PROVIDER_ENDPOINT=http://localhost:8899 \
# WS_ENDPOINT=http://localhost:8900 \
# anchor test

# - name: Test bolt-counter
# run: |
# cd bolt-counter
# yarn install
# EPHEMERAL_PROVIDER_ENDPOINT=http://localhost:7799 \
# EPHEMERAL_WS_ENDPOINT=ws://localhost:7800 \
# PROVIDER_ENDPOINT=http://localhost:8899 \
# WS_ENDPOINT=http://localhost:8900 \
# yarn test

# - name: Test dummy-token-transfer
# run: |
# cd dummy-token-transfer
# yarn install
# EPHEMERAL_PROVIDER_ENDPOINT=http://localhost:7799 \
# EPHEMERAL_WS_ENDPOINT=ws://localhost:7800 \
# PROVIDER_ENDPOINT=http://localhost:8899 \
# WS_ENDPOINT=http://localhost:8900 \
# anchor test

# - name: Test roll-dice
# run: |
# cd roll-dice
# yarn install
# EPHEMERAL_PROVIDER_ENDPOINT=http://localhost:7799 \
# EPHEMERAL_WS_ENDPOINT=ws://localhost:7800 \
# PROVIDER_ENDPOINT=http://localhost:8899 \
# WS_ENDPOINT=http://localhost:8900 \
# anchor test

# - name: Test rust-counter
# run: |
# cd rust-counter
# yarn install
# EPHEMERAL_PROVIDER_ENDPOINT=http://localhost:7799 \
# EPHEMERAL_WS_ENDPOINT=ws://localhost:7800 \
# PROVIDER_ENDPOINT=http://localhost:8899 \
# WS_ENDPOINT=http://localhost:8900 \
# yarn test
Loading