From 2a47159ea0b4062b84fd04792d9381e535a77b13 Mon Sep 17 00:00:00 2001 From: Frederic BIDON Date: Tue, 18 Mar 2025 19:44:25 +0100 Subject: [PATCH 1/8] experimental: markdown lint in CI Signed-off-by: Frederic BIDON --- .github/workflows/TODO.md | 5 +++++ .github/workflows/markdown.yml | 36 ++++++++++++++++++++++++++++++++++ .markdownlint.yml | 28 ++++++++++++++++++++++++++ README.md | 3 +++ 4 files changed, 72 insertions(+) create mode 100644 .github/workflows/TODO.md create mode 100644 .github/workflows/markdown.yml create mode 100644 .markdownlint.yml diff --git a/.github/workflows/TODO.md b/.github/workflows/TODO.md new file mode 100644 index 0000000..1845d62 --- /dev/null +++ b/.github/workflows/TODO.md @@ -0,0 +1,5 @@ +Evaluate: + +* misspell +* spellcheck +* govulncheck diff --git a/.github/workflows/markdown.yml b/.github/workflows/markdown.yml new file mode 100644 index 0000000..e4ee4f8 --- /dev/null +++ b/.github/workflows/markdown.yml @@ -0,0 +1,36 @@ +name: Markdown + +on: + pull_request_target: + paths: + - '**/*.md' + +permissions: + pull-requests: write + contents: read + +jobs: + lint-markdown: + runs-on: ubuntu-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v4 + + - name: Run markdown linter + id: markdownlint + #continue-on-error: true + uses: docker://avtodev/markdown-lint:v1 + with: + config: .markdownlint.yml + args: '**/*.md' + output: ./markdownlint.txt + + - name: Create PR comment + if: ${{ failure() && steps.markdownlint.outcome == 'failure' }} + #if: steps.markdownlint.outputs.exit_code != 0 + uses: peter-evans/create-or-update-comment@v4 + with: + issue-number: ${{ github.event.pull_request.number }} + title: Markdown Lint Report + body-path: ./markdownlint.txt + labels: report, bot-generated diff --git a/.markdownlint.yml b/.markdownlint.yml new file mode 100644 index 0000000..a0e540e --- /dev/null +++ b/.markdownlint.yml @@ -0,0 +1,28 @@ +# Default state for all rules +default: true + +# ul-style +MD004: false + +# hard-tabs +MD010: false + +# line-length +MD013: false + +# no-duplicate-header +MD024: + siblings_only: true + +#single-title +MD025: false + +# ol-prefix +MD029: + style: ordered + +# no-inline-html +MD033: false + +# fenced-code-language +MD040: false diff --git a/README.md b/README.md index 6d57ea5..dd8bd86 100644 --- a/README.md +++ b/README.md @@ -6,3 +6,6 @@ [![Go Report Card](https://goreportcard.com/badge/github.com/go-openapi/errors)](https://goreportcard.com/report/github.com/go-openapi/errors) Shared errors and error interface used throughout the various libraries found in the go-openapi toolkit. + + +# blah blah From 3e314be1817cfdd1668f19f3987162d5027919ac Mon Sep 17 00:00:00 2001 From: Frederic BIDON Date: Wed, 19 Mar 2025 10:58:43 +0100 Subject: [PATCH 2/8] raised markdown issue Signed-off-by: Frederic BIDON --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index dd8bd86..3e471d8 100644 --- a/README.md +++ b/README.md @@ -8,4 +8,6 @@ Shared errors and error interface used throughout the various libraries found in the go-openapi toolkit. -# blah blah +## blah blah + +# should raise an issue From 8d9b41f583b03b654ef0c5a5c008d196e3a49044 Mon Sep 17 00:00:00 2001 From: Frederic BIDON Date: Wed, 19 Mar 2025 11:01:07 +0100 Subject: [PATCH 3/8] fixup Signed-off-by: Frederic BIDON --- .github/workflows/markdown.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/markdown.yml b/.github/workflows/markdown.yml index e4ee4f8..7183997 100644 --- a/.github/workflows/markdown.yml +++ b/.github/workflows/markdown.yml @@ -31,6 +31,4 @@ jobs: uses: peter-evans/create-or-update-comment@v4 with: issue-number: ${{ github.event.pull_request.number }} - title: Markdown Lint Report body-path: ./markdownlint.txt - labels: report, bot-generated From 1bcc2039361ec8a1e95ecb6418b7592060ed8e86 Mon Sep 17 00:00:00 2001 From: Frederic BIDON Date: Wed, 19 Mar 2025 11:03:52 +0100 Subject: [PATCH 4/8] md linting experiment Signed-off-by: Frederic BIDON --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 3e471d8..e05a2b7 100644 --- a/README.md +++ b/README.md @@ -11,3 +11,5 @@ Shared errors and error interface used throughout the various libraries found in ## blah blah # should raise an issue + +# should raise another issue From f9d3f30b180eacbb946ca9be53552da7eecf978c Mon Sep 17 00:00:00 2001 From: Frederic BIDON Date: Wed, 19 Mar 2025 12:07:37 +0100 Subject: [PATCH 5/8] x Signed-off-by: Frederic BIDON --- .github/workflows/markdown.yml | 44 ++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/.github/workflows/markdown.yml b/.github/workflows/markdown.yml index 7183997..9f2b5fb 100644 --- a/.github/workflows/markdown.yml +++ b/.github/workflows/markdown.yml @@ -10,25 +10,59 @@ permissions: contents: read jobs: + lint-markdown: runs-on: ubuntu-latest steps: - name: Checkout Repo uses: actions/checkout@v4 + - name: Get all changed markdown files + id: changed-markdown-files + uses: tj-actions/changed-files@v45 + with: + # Avoid using single or double quotes for multiline patterns + files: | + **/*.md + + - name: "DEBUG List all changed files markdown files" + if: steps.changed-markdown-files.outputs.any_changed == 'true' + env: + ALL_CHANGED_FILES: + run: | + for file in ${ALL_CHANGED_FILES}; do + echo "$file was changed" + done + - name: Run markdown linter id: markdownlint - #continue-on-error: true uses: docker://avtodev/markdown-lint:v1 with: config: .markdownlint.yml - args: '**/*.md' - output: ./markdownlint.txt + args: '${{ steps.changed-markdown-files.outputs.all_changed_files }}' + output: ./lintreport.txt + + - name: Retrieve report as a variable + if: ${{ failure() && steps.markdownlint.outcome == 'failure' }} + id: conveyor + run: | + echo "::set-output name=text::$(cat ./lintreport.txt)" + + - name: Format PR comment + if: ${{ failure() && steps.markdownlint.outcome == 'failure' }} + id: commentformatter + uses: skills/action-text-variables@v1 + with: + template-vars: | + text=$${{ steps.conveyor.outputs.text }} + template-text: | + ## Markdown linting issues detected in modified files + + {{ text }} - name: Create PR comment if: ${{ failure() && steps.markdownlint.outcome == 'failure' }} - #if: steps.markdownlint.outputs.exit_code != 0 uses: peter-evans/create-or-update-comment@v4 with: issue-number: ${{ github.event.pull_request.number }} - body-path: ./markdownlint.txt + body: $${{ steps.commentformatter.outputs.updated-text }} From 0e3992e6ca2ed30699350cc3a0b75f219a997358 Mon Sep 17 00:00:00 2001 From: Frederic BIDON Date: Wed, 19 Mar 2025 13:47:02 +0100 Subject: [PATCH 6/8] experimental Signed-off-by: Frederic BIDON --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index e05a2b7..e7a4d26 100644 --- a/README.md +++ b/README.md @@ -13,3 +13,5 @@ Shared errors and error interface used throughout the various libraries found in # should raise an issue # should raise another issue + +## blah blah From 81faf46aecd547f7588c14d34425a4b8ef2d2cf1 Mon Sep 17 00:00:00 2001 From: Frederic BIDON Date: Wed, 19 Mar 2025 17:20:35 +0100 Subject: [PATCH 7/8] fix Signed-off-by: Frederic BIDON --- .github/workflows/TODO.md | 9 ++++ .github/workflows/markdown.yml | 80 ++++++++++++++++++++++++---------- .markdownlint.yml | 8 ++-- 3 files changed, 71 insertions(+), 26 deletions(-) diff --git a/.github/workflows/TODO.md b/.github/workflows/TODO.md index 1845d62..dbb1eed 100644 --- a/.github/workflows/TODO.md +++ b/.github/workflows/TODO.md @@ -1,5 +1,14 @@ Evaluate: +* markdownlint + * assessment: go + * used by opentelemetry/opentelemetry-go + * packaged as github action * misspell * spellcheck * govulncheck +* [x] godoc-lint: + * assessment: no go + * too simplistic: no real value added + * not integrated into golangci's suite of linters + * no packaged github action diff --git a/.github/workflows/markdown.yml b/.github/workflows/markdown.yml index 9f2b5fb..4f693f6 100644 --- a/.github/workflows/markdown.yml +++ b/.github/workflows/markdown.yml @@ -10,14 +10,14 @@ permissions: contents: read jobs: - - lint-markdown: - runs-on: ubuntu-latest + markdown-changed: + outputs: + proceed: ${ steps.changed-markdown-files.outputs.any_changed } steps: - name: Checkout Repo uses: actions/checkout@v4 - - name: Get all changed markdown files + - name: Get changed markdown files id: changed-markdown-files uses: tj-actions/changed-files@v45 with: @@ -25,44 +25,78 @@ jobs: files: | **/*.md - - name: "DEBUG List all changed files markdown files" - if: steps.changed-markdown-files.outputs.any_changed == 'true' - env: - ALL_CHANGED_FILES: - run: | - for file in ${ALL_CHANGED_FILES}; do - echo "$file was changed" - done + lint-markdown: + needs: markdown-changed + if: needs.markdown-changed.outputs.proceed == 'true' + runs-on: ubuntu-latest + env: + lintreport: "./report.txt" + outputs: + proceed: ${{ steps.report-exists.proceed }} + report: ${{ steps.report-exists.report }} + + steps: + - name: Checkout Repo + uses: actions/checkout@v4 - name: Run markdown linter + if: steps.changed-markdown-files.outputs.any_changed == 'true' + continue-on-error: true id: markdownlint uses: docker://avtodev/markdown-lint:v1 with: config: .markdownlint.yml args: '${{ steps.changed-markdown-files.outputs.all_changed_files }}' - output: ./lintreport.txt + output: ${{ env.lintreport }} + + - name: Comment on success + if: ${{ success() }} + id: congrats + uses: peter-evans/create-or-update-comment@v4 + with: + issue-number: ${{ github.event.pull_request.number }} + body: | + Markdown looks good to me. Congrats! - - name: Retrieve report as a variable - if: ${{ failure() && steps.markdownlint.outcome == 'failure' }} - id: conveyor + - name: Check lint report exists + if: ${{ failure() && steps.markdownlint.outcome == 'failure' && hashFiles(env.lintreport) != "" }} + id: report-exist run: | - echo "::set-output name=text::$(cat ./lintreport.txt)" + echo "proceed=true" >> $GITHUB_OUTPUT + echo "report=$(cat ${{ env.lintreport }})" >> $GITHUB_OUTPUT + pr-comment: + needs: lint-markdown + if: ${{ needs.lint-markdown.proceed == 'true' && needs.lint-markdown.report != '' }} + env: + comment-title: Markdown linting issues detected in modified files + + steps: - name: Format PR comment - if: ${{ failure() && steps.markdownlint.outcome == 'failure' }} id: commentformatter uses: skills/action-text-variables@v1 with: template-vars: | - text=$${{ steps.conveyor.outputs.text }} + text=${{ steps.conveyor.outputs.report }} template-text: | - ## Markdown linting issues detected in modified files + ### ${{ env.comment-title }} + This check is advisory and is not blocking. Please adopt a nice markdown style. + + Markdown rules formatting rules are documented [here](https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md). {{ text }} - - name: Create PR comment - if: ${{ failure() && steps.markdownlint.outcome == 'failure' }} + - name: Find previous PR comment + uses: peter-evans/find-comment@v3 + id: findcomment + with: + issue-number: ${{ github.event.pull_request.number }} + body-includes: ${{ steps.conveyor.outputs.report }} + direction: last + + - name: Create or update PR comment uses: peter-evans/create-or-update-comment@v4 with: issue-number: ${{ github.event.pull_request.number }} - body: $${{ steps.commentformatter.outputs.updated-text }} + comment-id: ${{ steps.findcomment.outputs.comment-id }} + body: ${{ steps.commentformatter.outputs.updated-text }} diff --git a/.markdownlint.yml b/.markdownlint.yml index a0e540e..35f8a0f 100644 --- a/.markdownlint.yml +++ b/.markdownlint.yml @@ -1,8 +1,10 @@ +# See rules documentation: https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md + # Default state for all rules default: true -# ul-style -MD004: false +# ul-style # default: consistent +# MD004: false # hard-tabs MD010: false @@ -15,7 +17,7 @@ MD024: siblings_only: true #single-title -MD025: false +#MD025: false # ol-prefix MD029: From a3ceac44a8210f5a6c3b7764a03266441c989ddc Mon Sep 17 00:00:00 2001 From: Frederic BIDON Date: Wed, 19 Mar 2025 17:22:07 +0100 Subject: [PATCH 8/8] simulate linting error Signed-off-by: Frederic BIDON --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e7a4d26..3c4c988 100644 --- a/README.md +++ b/README.md @@ -15,3 +15,4 @@ Shared errors and error interface used throughout the various libraries found in # should raise another issue ## blah blah +## blah blah