Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5f03cb9

Browse files
[skip-changelog] Sync check-markdown-task with upstream version of the workflow (#2118)
1 parent a8b52ea commit 5f03cb9

File tree

6 files changed

+1395
-4
lines changed

6 files changed

+1395
-4
lines changed

‎.github/workflows/check-markdown-task.yml‎

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,20 @@
22
name: Check Markdown
33

44
env:
5+
# See: https://github.com/actions/setup-node/#readme
6+
NODE_VERSION: 16.x
57
# See: https://github.com/actions/setup-go/tree/main#supported-version-syntax
68
GO_VERSION: "1.19"
79

8-
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
10+
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
911
on:
12+
create:
1013
push:
1114
paths:
1215
- ".github/workflows/check-markdown-task.ya?ml"
1316
- ".markdown-link-check.json"
17+
- "package.json"
18+
- "package-lock.json"
1419
- "Taskfile.ya?ml"
1520
- "**/.markdownlint*"
1621
- "**.go"
@@ -23,6 +28,8 @@ on:
2328
paths:
2429
- ".github/workflows/check-markdown-task.ya?ml"
2530
- ".markdown-link-check.json"
31+
- "package.json"
32+
- "package-lock.json"
2633
- "Taskfile.ya?ml"
2734
- "**/.markdownlint*"
2835
- "**.go"
@@ -38,13 +45,43 @@ on:
3845
repository_dispatch:
3946

4047
jobs:
48+
run-determination:
49+
runs-on: ubuntu-latest
50+
outputs:
51+
result: ${{ steps.determination.outputs.result }}
52+
steps:
53+
- name: Determine if the rest of the workflow should run
54+
id: determination
55+
run: |
56+
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
57+
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
58+
if [[
59+
"${{ github.event_name }}" != "create" ||
60+
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
61+
]]; then
62+
# Run the other jobs.
63+
RESULT="true"
64+
else
65+
# There is no need to run the other jobs.
66+
RESULT="false"
67+
fi
68+
69+
echo "result=$RESULT" >> $GITHUB_OUTPUT
70+
4171
lint:
72+
needs: run-determination
73+
if: needs.run-determination.outputs.result == 'true'
4274
runs-on: ubuntu-latest
4375

4476
steps:
4577
- name: Checkout repository
4678
uses: actions/checkout@v3
4779

80+
- name: Setup Node.js
81+
uses: actions/setup-node@v3
82+
with:
83+
node-version: ${{ env.NODE_VERSION }}
84+
4885
- name: Initialize markdownlint-cli problem matcher
4986
uses: xt0rted/markdownlint-problem-matcher@v2
5087

@@ -58,12 +95,19 @@ jobs:
5895
run: task markdown:lint
5996

6097
links:
98+
needs: run-determination
99+
if: needs.run-determination.outputs.result == 'true'
61100
runs-on: ubuntu-latest
62101

63102
steps:
64103
- name: Checkout repository
65104
uses: actions/checkout@v3
66105

106+
- name: Setup Node.js
107+
uses: actions/setup-node@v3
108+
with:
109+
node-version: ${{ env.NODE_VERSION }}
110+
67111
- name: Install Go
68112
uses: actions/setup-go@v4
69113
with:

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ venv
1212
.pytest_cache
1313
/dist
1414
/.pytest-tmp-dir
15+
/node_modules/
1516

1617
# gRPC client example folder
1718
/client_example/client_example

‎.markdownlintignore‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-markdown/.markdownlintignore
2+
.licenses/
3+
__pycache__/
4+
node_modules/

‎Taskfile.yml‎

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,15 @@ tasks:
142142
desc: Check for broken links
143143
deps:
144144
- task: docs:generate
145+
- task: npm:install-deps
145146
cmds:
146147
- |
147148
if [[ "{{.OS}}" == "Windows_NT" ]]; then
148149
# npx --call uses the native shell, which makes it too difficult to use npx for this application on Windows,
149150
# so the Windows user is required to have markdown-link-check installed and in PATH.
150151
if ! which markdown-link-check &>/dev/null; then
151-
echo "markdown-link-check not found or not in PATH. Please install: https://github.com/tcort/markdown-link-check#readme"
152+
echo "markdown-link-check not found or not in PATH."
153+
echo "Please install: https://github.com/tcort/markdown-link-check#readme"
152154
exit 1
153155
fi
154156
# Default behavior of the task on Windows is to exit the task when the first broken link causes a non-zero
@@ -158,7 +160,14 @@ tasks:
158160
# Using -regex instead of -name to avoid Task's behavior of globbing even when quoted on Windows
159161
# The odd method for escaping . in the regex is required for windows compatibility because mvdan.cc/sh gives
160162
# \ characters special treatment on Windows in an attempt to support them as path separators.
161-
for file in $(find . -regex ".*[.]md"); do
163+
for file in $(
164+
find . \
165+
-type d -name '.git' -prune -o \
166+
-type d -name '.licenses' -prune -o \
167+
-type d -name '__pycache__' -prune -o \
168+
-type d -name 'node_modules' -prune -o \
169+
-regex ".*[.]md" -print
170+
); do
162171
markdown-link-check \
163172
--quiet \
164173
--config "./.markdown-link-check.json" \
@@ -169,7 +178,14 @@ tasks:
169178
else
170179
npx --package=markdown-link-check --call='
171180
STATUS=0
172-
for file in $(find . -regex ".*[.]md"); do
181+
for file in $(
182+
find . \
183+
-type d -name '.git' -prune -o \
184+
-type d -name '.licenses' -prune -o \
185+
-type d -name '__pycache__' -prune -o \
186+
-type d -name 'node_modules' -prune -o \
187+
-regex ".*[.]md" -print
188+
); do
173189
markdown-link-check \
174190
--quiet \
175191
--config "./.markdown-link-check.json" \
@@ -183,15 +199,25 @@ tasks:
183199
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-markdown-task/Taskfile.yml
184200
markdown:fix:
185201
desc: Automatically correct linting violations in Markdown files where possible
202+
deps:
203+
- task: npm:install-deps
186204
cmds:
187205
- npx markdownlint-cli --fix "**/*.md"
188206

189207
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-markdown-task/Taskfile.yml
190208
markdown:lint:
191209
desc: Check for problems in Markdown files
210+
deps:
211+
- task: npm:install-deps
192212
cmds:
193213
- npx markdownlint-cli "**/*.md"
194214

215+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/npm-task/Taskfile.yml
216+
npm:install-deps:
217+
desc: Install dependencies managed by npm
218+
cmds:
219+
- npm install
220+
195221
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml
196222
poetry:install-deps:
197223
desc: Install dependencies managed by Poetry

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /