Skip to content

Commit 8597315

Browse files
committed
Run anchor build before pnpm install in anchor CI
The build step generates IDL files and TypeScript types that the test dependencies need. Running pnpm install first means those generated files aren't available during dependency resolution/linking. Reorder to: anchor build → pnpm install → anchor test --skip-build. Also pass --skip-build to anchor test since the program is already built, avoiding a redundant rebuild.
1 parent 198f89b commit 8597315

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

.github/workflows/anchor.yml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,25 +128,26 @@ jobs:
128128
echo "Building and Testing $project"
129129
cd "$project" || return 1
130130
131-
# Install dependencies first
132-
if ! pnpm install --frozen-lockfile; then
133-
echo "::error::pnpm install failed for $project"
134-
echo "$project: pnpm install failed" >> $GITHUB_WORKSPACE/failed_projects.txt
131+
# Build first — generates IDL and types that pnpm install/tests need
132+
if ! anchor build; then
133+
echo "::error::anchor build failed for $project"
134+
echo "$project: anchor build failed" >> $GITHUB_WORKSPACE/failed_projects.txt
135+
rm -rf target
135136
cd - > /dev/null
136137
return 1
137138
fi
138139
139-
# Run anchor build
140-
if ! anchor build; then
141-
echo "::error::anchor build failed for $project"
142-
echo "$project: anchor build failed" >> $GITHUB_WORKSPACE/failed_projects.txt
140+
# Install dependencies (after build so generated types are available)
141+
if ! pnpm install --frozen-lockfile; then
142+
echo "::error::pnpm install failed for $project"
143+
echo "$project: pnpm install failed" >> $GITHUB_WORKSPACE/failed_projects.txt
143144
rm -rf target
144145
cd - > /dev/null
145146
return 1
146147
fi
147148
148-
# Run anchor test
149-
if ! anchor test; then
149+
# Run anchor test (--skip-build since we already built above)
150+
if ! anchor test --skip-build; then
150151
echo "::error::anchor test failed for $project"
151152
echo "$project: anchor test failed" >> $GITHUB_WORKSPACE/failed_projects.txt
152153
rm -rf target node_modules

0 commit comments

Comments
 (0)