diff --git a/.github/workflows/validate-prose.yaml b/.github/workflows/validate-prose.yaml deleted file mode 100644 index 30cc19167e..0000000000 --- a/.github/workflows/validate-prose.yaml +++ /dev/null @@ -1,33 +0,0 @@ -name: Vale -on: - - pull_request - -jobs: - vale: - name: vale - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - - name: Execute Vale - run: | - wget -q https://github.com/errata-ai/vale/releases/download/v3.4.1/vale_3.4.1_Linux_64-bit.tar.gz - mkdir bin && tar -xvzf vale_3.4.1_Linux_64-bit.tar.gz -C bin - ls -la bin - bin/vale --config=./.vale.ini \ - --glob '!{src/content/changes/**}' \ - --no-exit \ - --output ./.vale/styles/rdjsonl.tmpl \ - src/content > out.jsonl - - - name: Install reviewdog - uses: reviewdog/action-setup@d8a7baabd7f3e8544ee4dbde3ee41d0011c3a93f # v1.5.0 - with: - reviewdog_version: latest - - - name: Create annotations on touched files - env: - REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - reviewdog -f=rdjsonl -name=Vale -reporter=github-pr-annotations -fail-level=error -filter-mode=added -level=info < out.jsonl diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml index 206e1dab0b..b0c69df347 100644 --- a/.github/workflows/validate.yaml +++ b/.github/workflows/validate.yaml @@ -5,7 +5,7 @@ name: Validate on: pull_request: branches: - - main + - lint-changes # TODO: change back to main merge_group: types: - checks_requested @@ -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("(?[^:]+):(?[0-9]+)(:(?[0-9]+))?\\s+(?.+)") | {"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}