From 626b1a38a0364596ec6abe5af990c1039624af17 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 7 Jul 2026 15:50:30 +0000 Subject: [PATCH] ci(anchor): handle two-line anchor version output breaking setup The Anchor matrix aborts at toolchain setup with: ##[error]Unable to process file command 'output' successfully. ##[error]Invalid format '1.1.2' heyAyushh/setup-anchor@v4.999 detects an existing install with `anchor --version | awk '{print $2}'` and writes the result to $GITHUB_OUTPUT. `anchor --version` now prints more than one line, so the value is multi-line and the write fails, killing every matrix group before any project is built. It only surfaces when the Anchor matrix actually runs (a change touches an Anchor project), which is why main looks green. Replace the action in anchor.yml with the same install steps (Solana via the Anza installer, Anchor via avm) plus toolchain caching, and read the version from the first line only so a multi-line value can't break the run. The other workflows using setup-anchor (native, quasar, pinocchio, solana-asm) share the latent bug and can be migrated the same way once this is confirmed green. --- .github/workflows/anchor.yml | 40 ++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/.github/workflows/anchor.yml b/.github/workflows/anchor.yml index 84a00422..829932cf 100644 --- a/.github/workflows/anchor.yml +++ b/.github/workflows/anchor.yml @@ -169,12 +169,44 @@ jobs: restore-keys: | cargo-${{ runner.os }}- - uses: pnpm/action-setup@v4 - - uses: heyAyushh/setup-anchor@v4.999 + # Replaces heyAyushh/setup-anchor@v4.999. That action's version-detection step + # runs `anchor --version | awk '{print $2}'` and writes the result straight to + # $GITHUB_OUTPUT. `anchor --version` now prints more than one line, so the value + # becomes multi-line and the step dies with "Invalid format", aborting the whole + # job before any project is built. These steps install the same toolchain (Solana + # via the Anza installer, Anchor via avm) and read the version from the first line + # only. The other workflows that use setup-anchor (native, quasar, pinocchio, + # solana-asm) hit the same latent bug once their matrices run; migrate them the + # same way once this is confirmed green. + - uses: actions/setup-node@v4 with: + node-version: lts/* + - name: Install Solana CLI + run: | + sh -c "$(curl -sSfL https://release.anza.xyz/v3.1.14/install)" + echo "$HOME/.local/share/solana/install/active_release/bin" >> "$GITHUB_PATH" + - name: Cache Anchor toolchain + uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/anchor + ~/.cargo/bin/avm + ~/.avm # Pinned to match the anchor-lang/anchor-spl crate version the programs depend on. - anchor-version: 1.1.2 - # setup-anchor resolves tags like stable by querying GitHub API for latest release which can fail with 429 errors - solana-cli-version: 3.1.14 + key: anchor-toolchain-${{ runner.os }}-1.1.2 + - name: Install Anchor 1.1.2 + run: | + export PATH="$HOME/.cargo/bin:$HOME/.avm/bin:$PATH" + # `anchor --version` can emit more than one line; read the first line only so + # a multi-line value never reaches downstream parsing. + current="$(anchor --version 2>/dev/null | head -n1 | awk '{print $2}' || true)" + if [ "$current" != "1.1.2" ]; then + cargo install --git https://github.com/coral-xyz/anchor avm --force + avm install 1.1.2 + avm use 1.1.2 + fi + echo "$HOME/.cargo/bin" >> "$GITHUB_PATH" + echo "$HOME/.avm/bin" >> "$GITHUB_PATH" - name: Install Surfpool run: curl -sL https://run.surfpool.run/ | bash - name: Display Versions