Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 0 additions & 33 deletions .github/workflows/validate-prose.yaml

This file was deleted.

80 changes: 9 additions & 71 deletions .github/workflows/validate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name: Validate
on:
pull_request:
branches:
- main
- lint-changes # TODO: change back to main
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO

merge_group:
types:
- checks_requested
Expand All @@ -16,79 +16,17 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Install frontmatter-validator
uses: giantswarm/install-binary-action@c94c7adadeb14af4bdbdd601f9a6e7f69638134c # v4.0.0
with:
binary: frontmatter-validator
version: "0.5.0"
smoke_test: frontmatter-validator --help

- name: Validate front matter for changed files
run: |
echo "Detecting changed files:"
git fetch --no-tags origin "${GITHUB_BASE_REF}":"${GITHUB_BASE_REF}"
git diff --name-only "refs/heads/${GITHUB_BASE_REF}" -- . | tee files.txt
if [ -s files.txt ]; then
# Validate the changed files
echo "Validating front matter for changed files:"
cat files.txt | frontmatter-validator --config ./scripts/frontmatter-validator/config-default.yaml

# Print for debugging
printf "\nAnnotations JSON:\n"
cat ./annotations.json
fetch-depth: 0

# Save as environment variable for next step
if [ $(jq length < ./annotations.json) -gt 0 ]; then
echo "found_front_matter_issues=true" >> $GITHUB_ENV
fi
fi
rm files.txt

- name: Send front matter annotations
if: ${{ env.found_front_matter_issues == 'true' }}
uses: yuzutech/annotations-action@0e061a6e3ac848299310b6429b60d67cafd4e7f8 # v0.5.0
- name: Execute pre-commit hooks
uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
title: Front matter problems
input: ./annotations.json

- name: markdownlint
run: |
make RUNNING_IN_CI=true lint-markdown || true

# Only fail if the run didn't work for technical reasons
if [ ! -e markdownlint.out ]; then
echo "ERROR: Linting did not write output file with findings"
exit 1
fi

# Otherwise create annotations
cat markdownlint.out \
| jq -nR '[inputs | (. | capture("(?<filename>[^:]+):(?<line>[0-9]+)(:(?<col>[0-9]+))?\\s+(?<description>.+)") | {"file": .filename, "line": (.line | tonumber), "end_line": (.line | tonumber), "title": "markdownlint problem", "message": .description, "annotation_level": "error"})]' \
> markdownlint-annotations.json

# Print for debugging
printf "\nAnnotations JSON:\n"
cat ./markdownlint-annotations.json

if [ $(jq length < ./markdownlint-annotations.json) -gt 0 ]; then
echo "found_markdown_issues=true" >> $GITHUB_ENV
fi

- name: Send markdownlint annotations
if: ${{ env.found_markdown_issues == 'true' }}
uses: yuzutech/annotations-action@0e061a6e3ac848299310b6429b60d67cafd4e7f8 # v0.5.0
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
title: markdownlint problems
input: ./markdownlint-annotations.json

- name: Fail if markdownlint had findings
if: ${{ env.found_markdown_issues == 'true' }}
run: |
echo "ERROR: See markdownlint findings (annotated as errors in the PR when you click on 'Files changed')"
exit 1
# Compiles list of changed files in this PR
extra_args: >-
${{ github.event_name == 'pull_request'
&& format('--from-ref {0} --to-ref {1}', github.event.pull_request.base.sha, github.event.pull_request.head.sha)
|| '--all-files' }}

- name: Check file and folder names in content
shell: python {0}
Expand Down