Skip to content

Commit 0982a9a

Browse files
committed
fix(ci): restrict changed-project detection to exact framework roots
The dirname/grep/sed pipeline in each per-framework workflow used to keep any path whose dirname contained the framework name, then collapse only the `/<framework>/...` suffix. Sibling directories like `anchor-example/`, `anchor-example/app/pages/api` and `anchor-example/app/utils` passed straight through, even though they are not Anchor projects and have no package.json. The build step then tried to `pnpm install` in them and the whole job failed. This is exactly what happened on the PR #16 merge to main: four bogus "anchor" paths under `tokens/token-extensions/nft-meta-data-pointer/anchor-example` were added to the project list and pnpm install failed for each. Add an `awk -F/ '$NF == "<framework>"'` filter after the existing sed so only paths whose final segment exactly equals the framework name survive. This matches the behaviour of `get_projects()` (`find -name <framework>`) already used on push/schedule runs. Apply the same fix to anchor, native, pinocchio, quasar and solana-asm workflows. The asm workflow is the most sensitive to this bug because `asm` is a common substring (wasm, plasma, etc.).
1 parent 8abb5d1 commit 0982a9a

5 files changed

Lines changed: 31 additions & 9 deletions

File tree

.github/workflows/anchor.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,17 @@ jobs:
6464
if [ -z "$changed_files" ]; then
6565
projects=$(get_projects)
6666
else
67-
projects=$(echo "$changed_files" | while read file; do dirname "$file" | grep anchor | sed 's#/anchor/.*#/anchor#g'; done | grep -vE "$ignore_pattern" | sort -u)
67+
# Only keep paths whose final segment is exactly "anchor" — otherwise
68+
# siblings like "anchor-example/" or nested "anchor-example/app/" leak in
69+
# and the build script tries to `pnpm install` in directories with no
70+
# package.json. See https://github.com/quiknode-labs/solana-program-examples
71+
# CI failure on PR #16.
72+
projects=$(echo "$changed_files" | while read file; do dirname "$file" | grep anchor | sed 's#/anchor/.*#/anchor#g'; done | awk -F/ '$NF == "anchor"' | grep -vE "$ignore_pattern" | sort -u)
6873
fi
6974
elif [[ "${{ steps.changes.outputs.anchor }}" == "true" ]]; then
7075
changed_files=(${{ steps.changes.outputs.anchor_files }})
71-
projects=$(for file in "${changed_files[@]}"; do dirname "${file}" | grep anchor | sed 's#/anchor/.*#/anchor#g'; done | grep -vE "$ignore_pattern" | sort -u)
76+
# Only keep paths whose final segment is exactly "anchor" — see comment above.
77+
projects=$(for file in "${changed_files[@]}"; do dirname "${file}" | grep anchor | sed 's#/anchor/.*#/anchor#g'; done | awk -F/ '$NF == "anchor"' | grep -vE "$ignore_pattern" | sort -u)
7278
else
7379
projects=""
7480
fi

.github/workflows/native.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,15 @@ jobs:
6464
if [ -z "$changed_files" ]; then
6565
projects=$(get_projects)
6666
else
67-
projects=$(echo "$changed_files" | while read file; do dirname "$file" | grep native | sed 's#/native/.*#/native#g'; done | grep -vE "$ignore_pattern" | sort -u)
67+
# Only keep paths whose final segment is exactly "native" — otherwise
68+
# siblings like "alternative/" leak in and the build script tries to
69+
# `pnpm install` in directories with no package.json.
70+
projects=$(echo "$changed_files" | while read file; do dirname "$file" | grep native | sed 's#/native/.*#/native#g'; done | awk -F/ '$NF == "native"' | grep -vE "$ignore_pattern" | sort -u)
6871
fi
6972
elif [[ "${{ steps.changes.outputs.native }}" == "true" ]]; then
7073
changed_files=(${{ steps.changes.outputs.native_files }})
71-
projects=$(for file in "${changed_files[@]}"; do dirname "${file}" | grep native | sed 's#/native/.*#/native#g'; done | grep -vE "$ignore_pattern" | sort -u)
74+
# Only keep paths whose final segment is exactly "native" — see comment above.
75+
projects=$(for file in "${changed_files[@]}"; do dirname "${file}" | grep native | sed 's#/native/.*#/native#g'; done | awk -F/ '$NF == "native"' | grep -vE "$ignore_pattern" | sort -u)
7276
else
7377
projects=""
7478
fi

.github/workflows/pinocchio.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,15 @@ jobs:
6464
if [ -z "$changed_files" ]; then
6565
projects=$(get_projects)
6666
else
67-
projects=$(echo "$changed_files" | while read file; do dirname "$file" | grep pinocchio | sed 's#/pinocchio/.*#/pinocchio#g'; done | grep -vE "$ignore_pattern" | sort -u)
67+
# Only keep paths whose final segment is exactly "pinocchio" — otherwise
68+
# siblings like "pinocchio-example/" would leak in and the build script
69+
# would try to `pnpm install` in directories with no package.json.
70+
projects=$(echo "$changed_files" | while read file; do dirname "$file" | grep pinocchio | sed 's#/pinocchio/.*#/pinocchio#g'; done | awk -F/ '$NF == "pinocchio"' | grep -vE "$ignore_pattern" | sort -u)
6871
fi
6972
elif [[ "${{ steps.changes.outputs.pinocchio }}" == "true" ]]; then
7073
changed_files=(${{ steps.changes.outputs.pinocchio_files }})
71-
projects=$(for file in "${changed_files[@]}"; do dirname "${file}" | grep pinocchio | sed 's#/pinocchio/.*#/pinocchio#g'; done | grep -vE "$ignore_pattern" | sort -u)
74+
# Only keep paths whose final segment is exactly "pinocchio" — see comment above.
75+
projects=$(for file in "${changed_files[@]}"; do dirname "${file}" | grep pinocchio | sed 's#/pinocchio/.*#/pinocchio#g'; done | awk -F/ '$NF == "pinocchio"' | grep -vE "$ignore_pattern" | sort -u)
7276
else
7377
projects=""
7478
fi

.github/workflows/quasar.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,15 @@ jobs:
6666
if [ -z "$changed_files" ]; then
6767
projects=$(get_projects)
6868
else
69-
projects=$(echo "$changed_files" | while read file; do dirname "$file" | grep quasar | sed 's#/quasar/.*#/quasar#g'; done | grep -vE "$ignore_pattern" | sort -u)
69+
# Only keep paths whose final segment is exactly "quasar" — otherwise
70+
# siblings like "quasar-example/" would leak in and the build script
71+
# would try to `pnpm install` in directories with no package.json.
72+
projects=$(echo "$changed_files" | while read file; do dirname "$file" | grep quasar | sed 's#/quasar/.*#/quasar#g'; done | awk -F/ '$NF == "quasar"' | grep -vE "$ignore_pattern" | sort -u)
7073
fi
7174
elif [[ "${{ steps.changes.outputs.quasar }}" == "true" ]]; then
7275
changed_files=(${{ steps.changes.outputs.quasar_files }})
73-
projects=$(for file in "${changed_files[@]}"; do dirname "${file}" | grep quasar | sed 's#/quasar/.*#/quasar#g'; done | grep -vE "$ignore_pattern" | sort -u)
76+
# Only keep paths whose final segment is exactly "quasar" — see comment above.
77+
projects=$(for file in "${changed_files[@]}"; do dirname "${file}" | grep quasar | sed 's#/quasar/.*#/quasar#g'; done | awk -F/ '$NF == "quasar"' | grep -vE "$ignore_pattern" | sort -u)
7478
else
7579
projects=""
7680
fi

.github/workflows/solana-asm.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ jobs:
5353
projects=$(get_projects)
5454
elif [[ "${{ steps.changes.outputs.asm }}" == "true" ]]; then
5555
changed_files=(${{ steps.changes.outputs.asm_files }})
56-
projects=$(for file in "${changed_files[@]}"; do dirname "${file}" | grep asm | sed 's#/asm/.*#/asm#g'; done | grep -vE "$ignore_pattern" | sort -u)
56+
# Only keep paths whose final segment is exactly "asm" — otherwise
57+
# anything containing the substring "asm" (e.g. "wasm/", "plasma/") would
58+
# leak in and the build script would try to test directories with no
59+
# ASM project. Match the get_projects() behaviour above.
60+
projects=$(for file in "${changed_files[@]}"; do dirname "${file}" | grep asm | sed 's#/asm/.*#/asm#g'; done | awk -F/ '$NF == "asm"' | grep -vE "$ignore_pattern" | sort -u)
5761
else
5862
projects=""
5963
fi

0 commit comments

Comments
 (0)