Skip to content

Commit 39fb8c1

Browse files
dougaitkenclaude
andcommitted
fix(ci): don't validate company files a PR removed
The Validate Company Profiles workflow built its file list from `gh pr diff --name-only`, which reports both the old and new path when a PR renames a company profile. The old path is absent from the sparse pr-head checkout, so validate-companies.js failed with ENOENT and blocked the PR over a file it had legitimately deleted. Any PR removing a profile hit the same wall. List changed files through the pulls API instead and drop entries with status "removed", so only files present in the checkout are validated. Verified against #2247 (rename -> yields only the added file) and #2249 (edit -> unchanged behaviour). Also guards the mapping loop with a warning rather than a silent skip, and short-circuits cleanly when nothing is left to validate. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MMca9WXKJAriMEfghGw1eT
1 parent a4ff145 commit 39fb8c1

4 files changed

Lines changed: 37 additions & 4 deletions

File tree

.github/workflows/validate-companies.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,15 @@ jobs:
4444
- name: Get changed files
4545
id: changed
4646
run: |
47-
FILES=$(gh pr diff ${{ github.event.pull_request.number }} --name-only | grep -E '(^src/companies/.*\.md$|^company-profiles/)' || true)
47+
# List changed files via the API rather than `gh pr diff --name-only`,
48+
# so we can filter on each file's status. A PR that renames or deletes
49+
# a company profile reports the old path too, and that path does not
50+
# exist in the pr-head checkout — validating it failed with ENOENT and
51+
# blocked the PR on a file it had legitimately removed.
52+
FILES=$(gh api \
53+
"repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files" \
54+
--paginate -q '.[] | select(.status != "removed") | .filename' \
55+
| grep -E '(^src/companies/.*\.md$|^company-profiles/)' || true)
4856
echo "files<<EOF" >> "$GITHUB_OUTPUT"
4957
echo "$FILES" >> "$GITHUB_OUTPUT"
5058
echo "EOF" >> "$GITHUB_OUTPUT"
@@ -64,8 +72,22 @@ jobs:
6472
MAPPED_FILES=()
6573
while IFS= read -r f; do
6674
[ -z "$f" ] && continue
75+
# Belt and braces: the status filter above should mean every path
76+
# here exists, so warn rather than skip silently if one does not.
77+
if [ ! -f "pr-head/$f" ]; then
78+
echo "::warning::Skipping $f — not present in the PR checkout"
79+
continue
80+
fi
6781
MAPPED_FILES+=("pr-head/$f")
6882
done <<< "$CHANGED_FILES"
83+
if [ ${#MAPPED_FILES[@]} -eq 0 ]; then
84+
echo "No company files to validate."
85+
echo "json<<EOF" >> "$GITHUB_OUTPUT"
86+
echo '{"oldFormatFiles":[],"files":{},"summary":{"total":0,"passed":0,"failed":0,"warnings":0}}' >> "$GITHUB_OUTPUT"
87+
echo "EOF" >> "$GITHUB_OUTPUT"
88+
echo "exit_code=0" >> "$GITHUB_OUTPUT"
89+
exit 0
90+
fi
6991
RESULT=$(node .github/scripts/validate-companies.js "${MAPPED_FILES[@]}")
7092
EXIT_CODE=$?
7193
set -e

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "remote-in-tech",
3-
"version": "4.13.5",
3+
"version": "4.13.6",
44
"description": "A list of semi to fully remote-friendly companies in or around tech",
55
"author": "Doug Aitken",
66
"license": "ISC",

src/_data/changelog.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
[
2+
{
3+
"version": "4.13.6",
4+
"date": "2026-09-07",
5+
"summary": "Fixed the company validation workflow blocking any PR that renames or removes a profile",
6+
"changes": [
7+
{
8+
"type": "fixed",
9+
"description": "The <code>Validate Company Profiles</code> workflow built its file list from <code>gh pr diff --name-only</code>, which reports both the old and new path when a PR renames a company profile. The old path no longer exists in the PR checkout, so validation died with <code>ENOENT</code> and blocked the PR over a file it had legitimately deleted — the same failure hit any PR removing a profile. The workflow now lists changed files through the API and filters out <code>removed</code> entries, so only files actually present get validated."
10+
}
11+
]
12+
},
213
{
314
"version": "4.13.5",
415
"date": "2026-09-07",

0 commit comments

Comments
 (0)