Skip to content

Commit 9545b41

Browse files
authored
chore(ci): clean up redundancies from the #606 CI repair (#607)
* chore(ci): drop redundant pnpm config from asm projects The pnpm 10.33.0 pin in the asm workflow is what fixes the ERR_PNPM_IGNORED_BUILDS failure (pinned pnpm treats ignored build scripts as a warning, not a hard error). The per-project pnpm.ignoredBuiltDependencies blocks only silenced the warning and did not fix CI, so remove them. * ci(anchor): drop anchor build retry loop The sparse registry protocol (CARGO_REGISTRIES_CRATES_IO_PROTOCOL) plus CARGO_NET_RETRY handle the transient crates.io index fetch failures at the cargo level, so the explicit 3x anchor build retry loop is redundant. * ci(anchor): drop redundant explicit anchor keys sync anchor test syncs program ids to the ephemeral keypair itself before building and deploying, so the separate anchor keys sync step is redundant. * refactor(anchor): stage cpi keypairs via pre_build hook The cross-program-invocation example needs stable hand/lever program ids (declare_program! bakes the lever address into hand). They were force-added into the gitignored target/deploy. Move them to a tracked keypairs/ dir and stage them into target/deploy with an Anchor.toml pre_build hook, so the ids stay stable without committing into an ignored path. * ci(anchor): verify cpi keypairs match Anchor.toml in pre_build The global anchor build --ignore-keys skips the keypair/declare_id check, so a drifted or missing committed keypair would only surface at test time. Have the pre_build hook assert each staged keypair's pubkey appears in Anchor.toml and fail the build loudly otherwise. * docs(ci): note anchor 1.0.x key-sync assumption in anchor test The reliance on anchor test syncing program ids itself is Anchor 1.0.x behavior; flag it so it gets re-verified when anchor-version is bumped. --------- Co-authored-by: Jo D <dev-jodee@users.noreply.github.com>
1 parent 8544990 commit 9545b41

8 files changed

Lines changed: 8 additions & 38 deletions

File tree

.github/workflows/anchor.yml

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -143,27 +143,17 @@ jobs:
143143
# Run anchor build
144144
# --ignore-keys: most examples don't commit program keypairs, so CI
145145
# generates ephemeral ones that won't match the source declare_id!
146-
# Retry to ride out transient crates.io index fetch failures.
147-
build_ok=false
148-
for attempt in 1 2 3; do
149-
if anchor build --ignore-keys; then
150-
build_ok=true
151-
break
152-
fi
153-
echo "anchor build attempt $attempt failed for $project; retrying"
154-
done
155-
if [ "$build_ok" != "true" ]; then
146+
if ! anchor build --ignore-keys; then
156147
echo "::error::anchor build failed for $project"
157148
echo "$project: anchor build failed" >> $GITHUB_WORKSPACE/failed_projects.txt
158149
rm -rf target
159150
cd - > /dev/null
160151
return 1
161152
fi
162153
163-
# Align declare_id! and Anchor.toml with the ephemeral keypair
164-
anchor keys sync
165-
166-
# Run anchor test
154+
# Run anchor test. Anchor 1.0.x syncs program ids to the ephemeral
155+
# keypair during its own build, so no separate keys sync is needed —
156+
# re-verify this if anchor-version is bumped.
167157
# --validator legacy: surfpool (the Anchor 1.0 default) isn't installed in CI
168158
if ! anchor test --validator legacy; then
169159
echo "::error::anchor test failed for $project"

basics/checking-accounts/asm/package.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,5 @@
1818
"ts-mocha": "^10.0.0",
1919
"typescript": "^4.3.5",
2020
"solana-bankrun": "^0.3.0"
21-
},
22-
"pnpm": {
23-
"ignoredBuiltDependencies": [
24-
"bufferutil",
25-
"utf-8-validate"
26-
]
2721
}
2822
}

basics/create-account/asm/package.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,5 @@
1818
"solana-bankrun": "^0.3.0",
1919
"ts-mocha": "^10.0.0",
2020
"typescript": "^4.3.5"
21-
},
22-
"pnpm": {
23-
"ignoredBuiltDependencies": [
24-
"bufferutil",
25-
"utf-8-validate"
26-
]
2721
}
2822
}

basics/cross-program-invocation/anchor/Anchor.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ solana_version = "3.1.8"
55
resolution = true
66
skip-lint = false
77

8+
[hooks]
9+
# program keypairs are committed under keypairs/ so ids stay stable (declare_program! bakes the lever id); stage them and fail loudly if one no longer matches Anchor.toml (the global anchor build --ignore-keys would otherwise hide drift until test time)
10+
pre_build = "mkdir -p target/deploy && cp keypairs/*.json target/deploy/ && for k in keypairs/*-keypair.json; do grep -q \"$(solana-keygen pubkey \"$k\")\" Anchor.toml || { echo \"keypair drift: $k does not match Anchor.toml\"; exit 1; }; done"
11+
812
[programs.localnet]
913
hand = "59c3ER1YrnnnezUVH7ix4WDUw9TQ9k7xH6wQyAmWvc52"
1014
lever = "A6GUsa5Ej8iWzMMP3B6otFVB5aaUckVm8a31Y5TMLYRV"

basics/cross-program-invocation/anchor/target/deploy/hand-keypair.json renamed to basics/cross-program-invocation/anchor/keypairs/hand-keypair.json

File renamed without changes.

basics/cross-program-invocation/anchor/target/deploy/lever-keypair.json renamed to basics/cross-program-invocation/anchor/keypairs/lever-keypair.json

File renamed without changes.

basics/hello-solana/asm/package.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,5 @@
1919
"solana-bankrun": "^0.3.1",
2020
"ts-mocha": "^10.1.0",
2121
"typescript": "^4.9.5"
22-
},
23-
"pnpm": {
24-
"ignoredBuiltDependencies": [
25-
"bufferutil",
26-
"utf-8-validate"
27-
]
2822
}
2923
}

basics/transfer-sol/asm/package.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,5 @@
2020
"solana-bankrun": "^0.3.0",
2121
"ts-mocha": "^10.0.0",
2222
"typescript": "^4.3.5"
23-
},
24-
"pnpm": {
25-
"ignoredBuiltDependencies": [
26-
"bufferutil",
27-
"utf-8-validate"
28-
]
2923
}
3024
}

0 commit comments

Comments
 (0)