Skip to content

Commit 51b3eac

Browse files
committed
Use npm to manage Markdown tool dependencies
The project uses several tools for development and validation of Markdown files. Previously, the version of the tools used was not controlled. This was problematic because: - A different version of the tool may be used on the contributor's machine than on the CI runner, resulting in confusing failures. - The project is immediately subject to disruption or breakage resulting from a release of the tool. The new approach is to specify the version of the tools via the standard npm metadata files (package.json + package-lock.json), providing the following benefits: - Enables automated updates via Dependabot PRs - Enables automated vulnerability alerts
1 parent 92d023e commit 51b3eac

9 files changed

+1679
-0
lines changed

Diff for: .ecrc

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"^\\.git[/\\\\]",
44
"__pycache__[/\\\\]",
55
"^LICENSE\\.txt$",
6+
"node_modules[/\\\\]",
67
"^poetry\\.lock$",
78
"^\\.licenses[/\\\\]",
89
"^internal/rule/schema/schemadata/bindata.go$",

Diff for: .github/workflows/check-markdown-task.yml

+16
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ name: Check Markdown
44
env:
55
# See: https://github.com/actions/setup-go/tree/main#supported-version-syntax
66
GO_VERSION: "1.17"
7+
# See: https://github.com/actions/setup-node/#readme
8+
NODE_VERSION: 20.x
79

810
# See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows
911
on:
@@ -12,6 +14,8 @@ on:
1214
paths:
1315
- ".github/workflows/check-markdown-task.ya?ml"
1416
- ".markdown-link-check.json"
17+
- "package.json"
18+
- "package-lock.json"
1519
- "Taskfile.ya?ml"
1620
- "**/.markdownlint*"
1721
- "**.mdx?"
@@ -22,6 +26,8 @@ on:
2226
paths:
2327
- ".github/workflows/check-markdown-task.ya?ml"
2428
- ".markdown-link-check.json"
29+
- "package.json"
30+
- "package-lock.json"
2531
- "Taskfile.ya?ml"
2632
- "**/.markdownlint*"
2733
- "**.mdx?"
@@ -70,6 +76,11 @@ jobs:
7076
- name: Checkout repository
7177
uses: actions/checkout@v4
7278

79+
- name: Setup Node.js
80+
uses: actions/setup-node@v4
81+
with:
82+
node-version: ${{ env.NODE_VERSION }}
83+
7384
- name: Initialize markdownlint-cli problem matcher
7485
uses: xt0rted/markdownlint-problem-matcher@v3
7586

@@ -98,6 +109,11 @@ jobs:
98109
with:
99110
go-version: ${{ env.GO_VERSION }}
100111

112+
- name: Setup Node.js
113+
uses: actions/setup-node@v4
114+
with:
115+
node-version: ${{ env.NODE_VERSION }}
116+
101117
- name: Install Task
102118
uses: arduino/setup-task@v2
103119
with:

Diff for: .gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
arduino-lint.exe
44
__pycache__/
55

6+
# Generated files
7+
node_modules/
8+
69
# Test artifacts
710
coverage_unit.txt
811

Diff for: .markdownlintignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-markdown/.markdownlintignore
22
.licenses/
33
__pycache__/
4+
node_modules/

Diff for: .prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# Generated files
88
/.licenses/
99
__pycache__/
10+
node_modules/
1011

1112
# Test files
1213
/internal/rule/schema/testdata/input/invalid-schema.json

Diff for: Taskfile.yml

+15
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ tasks:
320320
desc: Check for broken links
321321
deps:
322322
- task: docs:generate
323+
- task: npm:install-deps
323324
cmds:
324325
- |
325326
if [[ "{{.OS}}" == "Windows_NT" ]]; then
@@ -361,15 +362,29 @@ tasks:
361362
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-markdown-task/Taskfile.yml
362363
markdown:fix:
363364
desc: Automatically correct linting violations in Markdown files where possible
365+
deps:
366+
- task: npm:install-deps
364367
cmds:
365368
- npx markdownlint-cli --fix "**/*.md"
366369

367370
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-markdown-task/Taskfile.yml
368371
markdown:lint:
369372
desc: Check for problems in Markdown files
373+
deps:
374+
- task: npm:install-deps
370375
cmds:
371376
- npx markdownlint-cli "**/*.md"
372377

378+
# Parameter variables:
379+
# - PROJECT_PATH: path of the npm-managed project. Default value: "./"
380+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/npm-task/Taskfile.yml
381+
npm:install-deps:
382+
desc: Install dependencies managed by npm
383+
dir: |
384+
"{{default "./" .PROJECT_PATH}}"
385+
cmds:
386+
- npm install
387+
373388
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml
374389
poetry:install-deps:
375390
desc: Install dependencies managed by Poetry

Diff for: docs/CONTRIBUTING.md

+3
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ If you want to run integration tests or work on documentation, you will also nee
8383

8484
- A working [Python](https://www.python.org/downloads/) environment, version 3.9 or later.
8585
- [Poetry](https://python-poetry.org/docs/).
86+
- [**Node.js** / **npm**](https://nodejs.org/en/download/) - Node.js dependencies management tool.
87+
- **** [**nvm**](https://github.com/nvm-sh/nvm#installing-and-updating) is recommended if you want to manage multiple
88+
installations of **Node.js** on your system.
8689

8790
### Building the source code
8891

0 commit comments

Comments
 (0)