Skip to content

Commit e59dabf

Browse files
committed
raised markdown issue
Signed-off-by: Frederic BIDON <[email protected]>
1 parent 2a47159 commit e59dabf

File tree

6 files changed

+167
-18
lines changed

6 files changed

+167
-18
lines changed

.markdownlint.yml renamed to .github/.markdownlint.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
# See rules documentation: https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md
2+
13
# Default state for all rules
24
default: true
35

4-
# ul-style
5-
MD004: false
6+
# ul-style # default: consistent
7+
MD004: consistent
68

79
# hard-tabs
810
MD010: false
@@ -15,11 +17,11 @@ MD024:
1517
siblings_only: true
1618

1719
#single-title
18-
MD025: false
20+
MD025: true
1921

2022
# ol-prefix
2123
MD029:
22-
style: ordered
24+
style: one_or_ordered
2325

2426
# no-inline-html
2527
MD033: false

.github/workflows/TODO.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
Evaluate:
22

3+
* markdownlint
4+
* assessment: go
5+
* used by opentelemetry/opentelemetry-go
6+
* packaged as github action
37
* misspell
48
* spellcheck
59
* govulncheck
10+
* [x] godoc-lint:
11+
* assessment: no go
12+
* too simplistic: no real value added
13+
* not integrated into golangci's suite of linters
14+
* no packaged github action

.github/workflows/markdown.yml

Lines changed: 122 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,139 @@ permissions:
99
pull-requests: write
1010
contents: read
1111

12+
env:
13+
comment-title: Markdown linter
14+
1215
jobs:
16+
markdown-changed:
17+
runs-on: ubuntu-latest
18+
outputs:
19+
proceed: ${{ steps.changed-markdown-files.outputs.any_changed }}
20+
all_changed_files: ${{ steps.changed-markdown-files.outputs.all_changed_files }}
21+
steps:
22+
- name: Checkout Repo
23+
uses: actions/checkout@v4
24+
25+
- name: Get changed markdown files
26+
id: changed-markdown-files
27+
uses: tj-actions/changed-files@v45
28+
with:
29+
files: '**/*.md'
30+
31+
- name: Notify
32+
run: |
33+
echo "::notice::Detected some changed markdown files"
34+
echo "${{ steps.changed-markdown-files.outputs.all_changed_files }}"
35+
1336
lint-markdown:
37+
needs: markdown-changed
38+
if: needs.markdown-changed.outputs.proceed == 'true'
1439
runs-on: ubuntu-latest
40+
env:
41+
lintreport: './markdownlint-report.txt'
42+
outputs:
43+
proceed: ${{ steps.report-exists.outputs.proceed }}
44+
report: ${{ steps.report-exists.outputs.report }}
45+
1546
steps:
1647
- name: Checkout Repo
1748
uses: actions/checkout@v4
1849

1950
- name: Run markdown linter
51+
continue-on-error: true
2052
id: markdownlint
21-
#continue-on-error: true
22-
uses: docker://avtodev/markdown-lint:v1
53+
uses: docker://avtodev/markdown-lint:v1.5
54+
with:
55+
config: ./.github/.markdownlint.yml
56+
args: ${{ needs.markdown-changed.outputs.all_changed_files }}
57+
output: '${{ env.lintreport }}'
58+
59+
- name: Find previous PR comment
60+
if: steps.markdownlint.outcome == 'success'
61+
uses: peter-evans/find-comment@v3
62+
id: findcomment
2363
with:
24-
config: .markdownlint.yml
25-
args: '**/*.md'
26-
output: ./markdownlint.txt
64+
issue-number: ${{ github.event.pull_request.number }}
65+
body-includes: ${{ env.comment-title }}
66+
direction: last
2767

28-
- name: Create PR comment
29-
if: ${{ failure() && steps.markdownlint.outcome == 'failure' }}
30-
#if: steps.markdownlint.outputs.exit_code != 0
68+
- name: Comment on success
69+
if: steps.markdownlint.outcome == 'success'
70+
id: congrats
3171
uses: peter-evans/create-or-update-comment@v4
3272
with:
3373
issue-number: ${{ github.event.pull_request.number }}
34-
title: Markdown Lint Report
35-
body-path: ./markdownlint.txt
36-
labels: report, bot-generated
74+
comment-id: ${{ steps.findcomment.outputs.comment-id }}
75+
reactions: hooray
76+
reactions-edit-mode: replace
77+
body: |
78+
### ${{ env.comment-title }}
79+
Markdown looks good to me. Congrats!
80+
81+
- name: Check lint report exists
82+
if: ${{ steps.markdownlint.outcome != 'success' && hashFiles(env.lintreport) != '' }}
83+
id: report-exists
84+
run: |
85+
echo 'report<<EOF' >> $GITHUB_OUTPUT
86+
cat ${{ env.lintreport }}|sed -e '$a\' >> $GITHUB_OUTPUT
87+
echo 'EOF' >> $GITHUB_OUTPUT
88+
89+
if [[ "$(cat ${{ env.lintreport }}|wc -l)" != "0" ]] ; then
90+
echo "proceed=true" >> $GITHUB_OUTPUT
91+
echo "::notice::Detected some linting issues with changed markdown"
92+
cat ${{ env.lintreport }}|sed -e '$a\'
93+
else
94+
echo "proceed=false" >> $GITHUB_OUTPUT
95+
echo "::notice::No linting issues with changed markdown"
96+
fi
97+
98+
- name: Other linter errors
99+
if: ${{ steps.markdownlint.outcome != 'success' && hashFiles(env.lintreport) == '' }}
100+
run: |
101+
echo "::error::markdown linter encountered an error"
102+
exit 1
103+
104+
pr-comment:
105+
needs: lint-markdown
106+
if: needs.lint-markdown.outputs.proceed == 'true'
107+
runs-on: ubuntu-latest
108+
109+
steps:
110+
- name: Format PR comment
111+
id: commentformatter
112+
uses: skills/action-text-variables@v1
113+
with:
114+
template-vars: |
115+
text='${{ needs.lint-markdown.outputs.report }}'
116+
template-text: |
117+
### ${{ env.comment-title }}
118+
Some markdown linting issues were detected in modified .md files.
119+
120+
This check is advisory only and not blocking. Please adopt a nice markdown style.
121+
122+
Markdown formatting rules are documented [here](https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md).
123+
<br>
124+
{{ text }}
125+
126+
- name: Find previous PR comment
127+
uses: peter-evans/find-comment@v3
128+
id: findcomment
129+
with:
130+
issue-number: ${{ github.event.pull_request.number }}
131+
body-includes: ${{ env.comment-title }}
132+
direction: last
133+
134+
- name: Create or update PR comment
135+
uses: peter-evans/create-or-update-comment@v4
136+
with:
137+
issue-number: ${{ github.event.pull_request.number }}
138+
comment-id: ${{ steps.findcomment.outputs.comment-id }}
139+
reactions: confused
140+
reactions-edit-mode: replace
141+
body: ${{ steps.commentformatter.outputs.updated-text }}
142+
edit-mode: replace
143+
144+
- name: Notify
145+
run: |
146+
echo "::notice::Commented pull request ${{ github.event.pull_request.number }}"
147+
echo "::debug::${{ steps.commentformatter.outputs.updated-text }}"

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,3 @@
66
[![Go Report Card](https://goreportcard.com/badge/github.com/go-openapi/errors)](https://goreportcard.com/report/github.com/go-openapi/errors)
77

88
Shared errors and error interface used throughout the various libraries found in the go-openapi toolkit.
9-
10-
11-
# blah blah

doc.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# blag blah
2+
# blag blah
3+
4+
Ordered list:
5+
6+
1. xyz
7+
2. abc
8+
9+
First list:
10+
11+
- a
12+
- b
13+
- c
14+
15+
Second list:
16+
17+
* A
18+
* B
19+
* C
20+
21+
Another Ordered list:
22+
23+
0. xyz
24+
0. abc

html.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<h1>dfkjfkfj<h1>
2+
3+
4+
ERGGLGKLK
5+
==========
6+
this is a title

0 commit comments

Comments
 (0)