Skip to content

Commit 353ecc2

Browse files
danbarrclaude
andauthored
Run prettier/eslint repo-wide in upstream-release-docs autofix (#812)
The per-file autofix step failed when the skill deleted a doc page, because git diff --name-only includes deletions and prettier exits non-zero on missing paths (PR #809, deleted mcp-optimizer.mdx). Replace the diff-driven xargs with the repo-wide npm scripts. Both already exclude auto-generated reference paths via .prettierignore and eslint.config.mjs, so the original "don't fight the generators" intent is preserved. Co-authored-by: Dan Barr <6922515+danbarr@users.noreply.github.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent ed3ee23 commit 353ecc2

1 file changed

Lines changed: 12 additions & 35 deletions

File tree

.github/workflows/upstream-release-docs.yml

Lines changed: 12 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -820,44 +820,21 @@ jobs:
820820
echo "Skill produced $COUNT commit(s) between pre_skill and now."
821821
822822
# Auto-apply the same formatters the project's pre-commit hook
823-
# runs, scoped to the files the skill touched. The skill's
824-
# sandbox doesn't include npm run prettier/eslint, so without
825-
# this step any formatting drift lands on PR CI as a "Lint and
826-
# format checks" failure requiring a human push. Scope via git
827-
# diff vs the pre-skill SHA so we don't reformat auto-generated
828-
# reference assets (which would fight the generators).
829-
- name: Auto-fix prettier and eslint on skill-touched files
823+
# runs. The skill's sandbox doesn't include npm run
824+
# prettier/eslint, so without this step any formatting drift
825+
# lands on PR CI as a "Lint and format checks" failure
826+
# requiring a human push. Run the repo-wide scripts: they
827+
# already exclude auto-generated reference paths via
828+
# .prettierignore and eslint.config.mjs, and a whole-repo
829+
# scan is robust to deletions and renames in the skill's
830+
# diff (which a per-file xargs invocation is not).
831+
- name: Auto-fix prettier and eslint
830832
id: autofix
831833
if: always() && steps.skill_gen.conclusion == 'success'
832-
env:
833-
BASELINE_SHA: ${{ steps.pre_skill.outputs.sha }}
834834
run: |
835-
# Files the skill added/modified, excluding the three
836-
# auto-generated reference paths.
837-
CHANGED=$(git diff --name-only "$BASELINE_SHA..HEAD" -- \
838-
':!docs/toolhive/reference/cli/' \
839-
':!docs/toolhive/reference/crds/' \
840-
':!static/api-specs/' \
841-
2>/dev/null | \
842-
grep -E '\.(md|mdx|ts|tsx|js|jsx|mjs|cjs|css|json|jsonc|yaml|yml)$' || true)
843-
if [ -z "$CHANGED" ]; then
844-
echo "No skill-touched files in scope for autofix."
845-
exit 0
846-
fi
847-
echo "Running prettier --write and eslint --fix on:"
848-
echo "$CHANGED"
849-
# xargs -0 with a NUL-delimited list so filenames with
850-
# spaces survive.
851-
printf '%s\n' "$CHANGED" | tr '\n' '\0' | \
852-
xargs -0 npx prettier --write --log-level warn
853-
# eslint --fix against mdx/ts/tsx/js only.
854-
LINT_TARGETS=$(printf '%s\n' "$CHANGED" | \
855-
grep -E '\.(mdx|ts|tsx|js|jsx|mjs|cjs)$' || true)
856-
if [ -n "$LINT_TARGETS" ]; then
857-
printf '%s\n' "$LINT_TARGETS" | tr '\n' '\0' | \
858-
xargs -0 npx eslint --fix --no-error-on-unmatched-pattern || \
859-
echo "::warning::eslint --fix reported non-zero; proceeding."
860-
fi
835+
npm run prettier:fix
836+
npm run eslint:fix || \
837+
echo "::warning::eslint --fix reported non-zero; proceeding."
861838
if git diff --quiet; then
862839
echo "No formatting changes needed."
863840
else

0 commit comments

Comments
 (0)