Skip to content

Commit c8a0807

Browse files
miharpclaude
andcommitted
Lint all tracked Markdown files in CI
Now that the entire tracked Markdown corpus lints clean, replace the changed-files detection (added vs. modified, with the modified step previously advisory) with a step that lints all git-tracked Markdown. Linting the git-tracked file list rather than a filesystem glob lints the canonical versioned collections once and skips the `_latest` symlinks (git stores them as single symlink entries, so a `**/*.md` glob would double-lint their targets). Generated reference docs are gitignored and so are also excluded; vendor/output/references_output stay excluded via .markdownlint-cli2.yaml. Closes #344 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Michael Harp <mike@mikeharp.com>
1 parent d80d1aa commit c8a0807

1 file changed

Lines changed: 13 additions & 64 deletions

File tree

.github/workflows/markdownlint.yml

Lines changed: 13 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -16,71 +16,20 @@ jobs:
1616
runs-on: ubuntu-latest
1717
steps:
1818
- uses: actions/checkout@v7
19-
with:
20-
fetch-depth: 0 # required to resolve base.sha for PR diff comparison
21-
- name: Find changed Markdown files
22-
id: changed-markdown
19+
- name: List tracked Markdown files
20+
id: tracked-markdown
2321
shell: bash
22+
# Lint git-tracked files only. This lints the canonical versioned dirs
23+
# once and skips the `_latest` symlinks (git stores them as single
24+
# symlink entries, so a filesystem glob would double-lint their targets).
25+
# It also excludes generated reference docs, which are gitignored.
2426
run: |
25-
case "${GITHUB_EVENT_NAME}" in
26-
pull_request)
27-
base_sha="${{ github.event.pull_request.base.sha }}"
28-
head_sha="${GITHUB_SHA}"
29-
;;
30-
push)
31-
base_sha="${{ github.event.before }}"
32-
head_sha="${GITHUB_SHA}"
33-
;;
34-
*)
35-
# workflow_dispatch: lints only files changed in the most recent commit, not the full branch
36-
# || true handles initial commits with no parent
37-
base_sha="$(git rev-parse "${GITHUB_SHA}^" 2>/dev/null || true)"
38-
head_sha="${GITHUB_SHA}"
39-
;;
40-
esac
41-
42-
if [[ -z "${base_sha}" || "${base_sha}" =~ ^0+$ ]]; then
43-
base_sha="$(git rev-list --max-parents=0 "${head_sha}")"
44-
fi
45-
46-
git diff --name-only --diff-filter=A "${base_sha}" "${head_sha}" -- '*.md' '*.markdown' > added-markdown-files.txt
47-
git diff --name-only --diff-filter=CMRT "${base_sha}" "${head_sha}" -- '*.md' '*.markdown' > modified-markdown-files.txt
48-
49-
if [[ -s added-markdown-files.txt ]]; then
50-
echo "has_added=true" >> "${GITHUB_OUTPUT}"
51-
{
52-
echo 'added_files<<EOF'
53-
cat added-markdown-files.txt
54-
echo 'EOF'
55-
} >> "${GITHUB_OUTPUT}"
56-
else
57-
echo "has_added=false" >> "${GITHUB_OUTPUT}"
58-
fi
59-
60-
if [[ -s modified-markdown-files.txt ]]; then
61-
echo "has_modified=true" >> "${GITHUB_OUTPUT}"
62-
{
63-
echo 'modified_files<<EOF'
64-
cat modified-markdown-files.txt
65-
echo 'EOF'
66-
} >> "${GITHUB_OUTPUT}"
67-
else
68-
echo "has_modified=false" >> "${GITHUB_OUTPUT}"
69-
fi
70-
71-
- name: No changed Markdown files
72-
if: steps.changed-markdown.outputs.has_added != 'true' && steps.changed-markdown.outputs.has_modified != 'true'
73-
run: echo "No changed Markdown files to lint."
74-
75-
- name: Lint new Markdown files (enforced)
76-
uses: DavidAnson/markdownlint-cli2-action@v23
77-
if: steps.changed-markdown.outputs.has_added == 'true'
78-
with:
79-
globs: ${{ steps.changed-markdown.outputs.added_files }}
80-
81-
- name: Lint modified Markdown files (advisory)
27+
{
28+
echo 'files<<EOF'
29+
git ls-files '*.md' '*.markdown'
30+
echo 'EOF'
31+
} >> "${GITHUB_OUTPUT}"
32+
- name: Lint tracked Markdown files
8233
uses: DavidAnson/markdownlint-cli2-action@v23
83-
if: steps.changed-markdown.outputs.has_modified == 'true'
84-
continue-on-error: true
8534
with:
86-
globs: ${{ steps.changed-markdown.outputs.modified_files }}
35+
globs: ${{ steps.tracked-markdown.outputs.files }}

0 commit comments

Comments
 (0)