-
Notifications
You must be signed in to change notification settings - Fork 1.5k
build: Switch to mdlint cli2 #8632
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
c529d06
5203cba
b1cce58
2a96f06
e3f07f2
628e866
08cb76c
3d5503c
29cf6ae
9a01b20
42c545a
9b6ff12
ae0b97d
ccdd20e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,17 +4,22 @@ on: | |
| repository_dispatch: | ||
| workflow_dispatch: | ||
| schedule: | ||
| # Everyday at 9:00 AM. | ||
| - cron: "0 9 * * *" | ||
| # Everyday at 9:00 AM. | ||
| - cron: "0 9 * * *" | ||
| pull_request: | ||
| branches: | ||
| - main | ||
| paths: | ||
| - ".github/workflows/markdown.yml" | ||
|
|
||
| # Declare default permissions as read only. | ||
| permissions: read-all | ||
|
|
||
| jobs: | ||
| lint-markdown: | ||
| permissions: | ||
| issues: write # required for creating issues from markdown lint reports | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| lint_outcome: ${{ steps.markdownlint.outcome }} | ||
| steps: | ||
| - name: Checkout Repo | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
|
|
@@ -23,16 +28,36 @@ jobs: | |
|
|
||
| - name: Run linter | ||
| id: markdownlint | ||
| uses: docker://avtodev/markdown-lint:v1@sha256:6aeedc2f49138ce7a1cd0adffc1b1c0321b841dc2102408967d9301c031949ee | ||
| uses: DavidAnson/markdownlint-cli2-action@8de2aa07cae85fd17c0b35642db70cf5495f1d25 # v24.0.0 | ||
| with: | ||
| config: .markdownlint.yaml | ||
| args: '**/*.md' | ||
| output: ./markdownlint.txt | ||
| config: .markdownlint-cli2.yaml | ||
| fix: false | ||
| globs: | | ||
| **/*.md | ||
| continue-on-error: true | ||
|
|
||
| - name: Create Issue From File | ||
| if: steps.markdownlint.outputs.exit_code != 0 | ||
| uses: peter-evans/create-issue-from-file@fca9117c27cdc29c6c4db3b86c48e4115a786710 # v6.0.0 | ||
| with: | ||
| title: Markdown Lint Report | ||
| content-filepath: ./markdownlint.txt | ||
| labels: report, bot-generated | ||
| report: | ||
| if: github.event_name == 'schedule' | ||
| needs: lint-markdown | ||
| permissions: | ||
| issues: write # required for creating issues from markdown lint reports | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Manage issue | ||
| if: github.event_name == 'schedule' | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This job starts on a fresh runner without checkout or Could we pass the repository explicitly and read |
||
| run: | | ||
| number=$(gh issue list --search "in:title Workflow failed: $GITHUB_WORKFLOW" --limit 1 --json number -q .[].number) | ||
|
|
||
| echo $number | ||
|
|
||
| if [[ $number ]]; then | ||
| if [[ "${{ steps.markdownlint.outcome }}" != "failure" ]]; then | ||
| gh issue close $number | ||
| fi | ||
| elif [[ "${{ steps.markdownlint.outcome }}" == "failure" ]]; then | ||
| gh issue create --title "Workflow failed: $GITHUB_WORKFLOW (#$GITHUB_RUN_NUMBER)" \ | ||
| --body "See [$GITHUB_WORKFLOW #$GITHUB_RUN_NUMBER](https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID)." \ | ||
| --label "report,bot-generated" | ||
| fi | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| config: | ||
| extends: .markdownlint.yaml | ||
| gitignore: '**/.{git,markdownlint}ignore' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| .github/ISSUE_TEMPLATE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| # This is a renovate-friendly source of Docker images. | ||
| FROM python:3.13.6-slim-bullseye@sha256:e98b521460ee75bca92175c16247bdf7275637a8faaeb2bcfa19d879ae5c4b9a AS python | ||
| FROM otel/weaver:v0.25.1@sha256:9ad46ca9cd4fa5974b121f886aa3e9946a8ef8ea905001a96c018d21f9db87ca AS weaver | ||
| FROM avtodev/markdown-lint:v1@sha256:6aeedc2f49138ce7a1cd0adffc1b1c0321b841dc2102408967d9301c031949ee AS markdown | ||
| FROM davidanson/markdownlint-cli2:v0.23.1@sha256:f382ea4fdc949883e79de678009437fb40c339323654c7b0dd4d5221cda8ed20 AS markdown |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once the trigger indentation is fixed, the new
pull_requestpath will reuse a job withissues: write,continue-on-error, and unconditional issue management. On same-repository PRs, a lint failure can create the shared workflow issue while the job stays green, and a passing PR can close an issue raised bymain; on fork PRs, attempted mutations are denied.Could we give PRs a read-only path where lint failures fail the job, and keep issue management only for non-PR monitoring runs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have split the report step into it's own job with different path.
You don't want this job to fail the ci as it is scanning the entire repo. We have the fail fast check which only fails if a changed file fails the linting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The split keeps issue writes out of PRs, but
continue-on-errorremains unconditional, so a failure in this self-check still leaves the PR workflow green. The fail-fast workflow only runs for Markdown changes, so it does not cover a PR that changes this workflow.Could we make
continue-on-errorconditional ongithub.event_name == 'schedule'?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If i do that, the following will occur. lets say a new linter rule is introduced then the pr to update it will now fail rather than doing what it does now which is allowing it to pass and instead creating an action item to address it.
In effect it eliminate nearly any need for the reporting workflows as it would only occur if someone merged a pr with a failed linter check.