Skip to content

Commit f262473

Browse files
authored
Merge pull request #240 from arduino/manage-npm-dependencies
Use npm to manage tool dependencies
2 parents f3cea83 + 2e10c4f commit f262473

39 files changed

+4560
-57
lines changed

.github/dependabot.yml

+9
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ updates:
2727
assignees:
2828
- per1234
2929

30+
- package-ecosystem: npm
31+
directory: /
32+
schedule:
33+
interval: daily
34+
labels:
35+
- "topic: infrastructure"
36+
assignees:
37+
- per1234
38+
3039
- package-ecosystem: pip
3140
directory: /
3241
schedule:

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

+18
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-markdown-task.md
22
name: Check Markdown
33

4+
env:
5+
# See: https://github.com/actions/setup-node/#readme
6+
NODE_VERSION: 16.x
7+
48
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
59
on:
610
create:
711
push:
812
paths:
913
- ".github/workflows/check-markdown-task.ya?ml"
1014
- ".markdown-link-check.json"
15+
- "package.json"
16+
- "package-lock.json"
1117
- "Taskfile.ya?ml"
1218
- "**/.markdownlint*"
1319
- "**.mdx?"
@@ -18,6 +24,8 @@ on:
1824
paths:
1925
- ".github/workflows/check-markdown-task.ya?ml"
2026
- ".markdown-link-check.json"
27+
- "package.json"
28+
- "package-lock.json"
2129
- "Taskfile.ya?ml"
2230
- "**/.markdownlint*"
2331
- "**.mdx?"
@@ -63,6 +71,11 @@ jobs:
6371
- name: Checkout repository
6472
uses: actions/checkout@v3
6573

74+
- name: Setup Node.js
75+
uses: actions/setup-node@v3
76+
with:
77+
node-version: ${{ env.NODE_VERSION }}
78+
6679
- name: Initialize markdownlint-cli problem matcher
6780
uses: xt0rted/markdownlint-problem-matcher@v1
6881

@@ -84,6 +97,11 @@ jobs:
8497
- name: Checkout repository
8598
uses: actions/checkout@v3
8699

100+
- name: Setup Node.js
101+
uses: actions/setup-node@v3
102+
with:
103+
node-version: ${{ env.NODE_VERSION }}
104+
87105
- name: Install Task
88106
uses: arduino/setup-task@v1
89107
with:

.github/workflows/check-npm-task.yml

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-npm-task.md
2+
name: Check npm
3+
4+
env:
5+
# See: https://github.com/actions/setup-node/#readme
6+
NODE_VERSION: 16.x
7+
8+
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
9+
on:
10+
push:
11+
paths:
12+
- ".github/workflows/check-npm-task.ya?ml"
13+
- "**/package.json"
14+
- "**/package-lock.json"
15+
- "Taskfile.ya?ml"
16+
pull_request:
17+
paths:
18+
- ".github/workflows/check-npm-task.ya?ml"
19+
- "**/package.json"
20+
- "**/package-lock.json"
21+
- "Taskfile.ya?ml"
22+
schedule:
23+
# Run every Tuesday at 8 AM UTC to catch breakage resulting from changes to the JSON schema.
24+
- cron: "0 8 * * TUE"
25+
workflow_dispatch:
26+
repository_dispatch:
27+
28+
permissions:
29+
contents: read
30+
31+
jobs:
32+
validate:
33+
runs-on: ubuntu-latest
34+
35+
steps:
36+
- name: Checkout repository
37+
uses: actions/checkout@v3
38+
39+
- name: Setup Node.js
40+
uses: actions/setup-node@v3
41+
with:
42+
node-version: ${{ env.NODE_VERSION }}
43+
44+
- name: Install Task
45+
uses: arduino/setup-task@v1
46+
with:
47+
repo-token: ${{ secrets.GITHUB_TOKEN }}
48+
version: 3.x
49+
50+
- name: Validate package.json
51+
run: task npm:validate
52+
53+
check-sync:
54+
runs-on: ubuntu-latest
55+
56+
steps:
57+
- name: Checkout repository
58+
uses: actions/checkout@v3
59+
60+
- name: Setup Node.js
61+
uses: actions/setup-node@v3
62+
with:
63+
node-version: ${{ env.NODE_VERSION }}
64+
65+
- name: Install Task
66+
uses: arduino/setup-task@v1
67+
with:
68+
repo-token: ${{ secrets.GITHUB_TOKEN }}
69+
version: 3.x
70+
71+
- name: Install npm dependencies
72+
run: task npm:install-deps
73+
74+
- name: Check package-lock.json
75+
run: git diff --color --exit-code package-lock.json

.github/workflows/check-prettier-formatting-task.yml

+9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-prettier-formatting-task.md
22
name: Check Prettier Formatting
33

4+
env:
5+
# See: https://github.com/actions/setup-node/#readme
6+
NODE_VERSION: 16.x
7+
48
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
59
on:
610
push:
@@ -209,6 +213,11 @@ jobs:
209213
- name: Checkout repository
210214
uses: actions/checkout@v3
211215

216+
- name: Setup Node.js
217+
uses: actions/setup-node@v3
218+
with:
219+
node-version: ${{ env.NODE_VERSION }}
220+
212221
- name: Install Task
213222
uses: arduino/setup-task@v1
214223
with:

.github/workflows/check-taskfiles.yml

+23-11
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-taskfiles.md
22
name: Check Taskfiles
33

4+
env:
5+
# See: https://github.com/actions/setup-node/#readme
6+
NODE_VERSION: 16.x
7+
48
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
59
on:
610
push:
711
paths:
812
- ".github/workflows/check-taskfiles.ya?ml"
13+
- "package.json"
14+
- "package-lock.json"
915
- "**/Taskfile.ya?ml"
1016
pull_request:
1117
paths:
1218
- ".github/workflows/check-taskfiles.ya?ml"
19+
- "package.json"
20+
- "package-lock.json"
1321
- "**/Taskfile.ya?ml"
1422
schedule:
1523
# Run every Tuesday at 8 AM UTC to catch breakage resulting from changes to the JSON schema.
@@ -34,6 +42,11 @@ jobs:
3442
- name: Checkout repository
3543
uses: actions/checkout@v3
3644

45+
- name: Setup Node.js
46+
uses: actions/setup-node@v3
47+
with:
48+
node-version: ${{ env.NODE_VERSION }}
49+
3750
- name: Download JSON schema for Taskfiles
3851
id: download-schema
3952
uses: carlosperate/download-file-action@v1
@@ -43,18 +56,17 @@ jobs:
4356
location: ${{ runner.temp }}/taskfile-schema
4457

4558
- name: Install JSON schema validator
46-
run: |
47-
sudo npm install \
48-
--global \
49-
ajv-cli \
50-
ajv-formats
59+
run: npm install
5160

5261
- name: Validate ${{ matrix.file }}
5362
run: |
5463
# See: https://github.com/ajv-validator/ajv-cli#readme
55-
ajv validate \
56-
--all-errors \
57-
--strict=false \
58-
-c ajv-formats \
59-
-s "${{ steps.download-schema.outputs.file-path }}" \
60-
-d "${{ matrix.file }}"
64+
npx \
65+
--package=ajv-cli \
66+
--package=ajv-formats \
67+
ajv validate \
68+
--all-errors \
69+
--strict=false \
70+
-c ajv-formats \
71+
-s "${{ steps.download-schema.outputs.file-path }}" \
72+
-d "${{ matrix.file }}"

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

+9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Source: https://github.com/arduino/tooling-project-assets/blob/master/workflow-templates/check-workflows-task.md
22
name: Check Workflows
33

4+
env:
5+
# See: https://github.com/actions/setup-node/#readme
6+
NODE_VERSION: 16.x
7+
48
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
59
on:
610
push:
@@ -27,6 +31,11 @@ jobs:
2731
- name: Checkout repository
2832
uses: actions/checkout@v3
2933

34+
- name: Setup Node.js
35+
uses: actions/setup-node@v3
36+
with:
37+
node-version: ${{ env.NODE_VERSION }}
38+
3039
- name: Install Task
3140
uses: arduino/setup-task@v1
3241
with:

.github/workflows/sync-labels.yml renamed to .github/workflows/sync-labels-npm.yml

+38-22
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,32 @@
1-
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/sync-labels.md
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/sync-labels-npm.md
22
name: Sync Labels
33

4+
env:
5+
# See: https://github.com/actions/setup-node/#readme
6+
NODE_VERSION: 16.x
7+
CONFIGURATIONS_FOLDER: .github/label-configuration-files
8+
CONFIGURATIONS_ARTIFACT: label-configuration-files
9+
410
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
511
on:
612
push:
713
paths:
8-
- ".github/workflows/sync-labels.ya?ml"
14+
- ".github/workflows/sync-labels-npm.ya?ml"
915
- ".github/label-configuration-files/*.ya?ml"
16+
- "package.json"
17+
- "package-lock.json"
1018
pull_request:
1119
paths:
12-
- ".github/workflows/sync-labels.ya?ml"
20+
- ".github/workflows/sync-labels-npm.ya?ml"
1321
- ".github/label-configuration-files/*.ya?ml"
22+
- "package.json"
23+
- "package-lock.json"
1424
schedule:
1525
# Run daily at 8 AM UTC to sync with changes to shared label configurations.
1626
- cron: "0 8 * * *"
1727
workflow_dispatch:
1828
repository_dispatch:
1929

20-
env:
21-
CONFIGURATIONS_FOLDER: .github/label-configuration-files
22-
CONFIGURATIONS_ARTIFACT: label-configuration-files
23-
2430
jobs:
2531
check:
2632
runs-on: ubuntu-latest
@@ -29,6 +35,11 @@ jobs:
2935
- name: Checkout repository
3036
uses: actions/checkout@v3
3137

38+
- name: Setup Node.js
39+
uses: actions/setup-node@v3
40+
with:
41+
node-version: ${{ env.NODE_VERSION }}
42+
3243
- name: Download JSON schema for labels configuration file
3344
id: download-schema
3445
uses: carlosperate/download-file-action@v1
@@ -37,20 +48,19 @@ jobs:
3748
location: ${{ runner.temp }}/label-configuration-schema
3849

3950
- name: Install JSON schema validator
40-
run: |
41-
sudo npm install \
42-
--global \
43-
ajv-cli \
44-
ajv-formats
51+
run: npm install
4552

4653
- name: Validate local labels configuration
4754
run: |
4855
# See: https://github.com/ajv-validator/ajv-cli#readme
49-
ajv validate \
50-
--all-errors \
51-
-c ajv-formats \
52-
-s "${{ steps.download-schema.outputs.file-path }}" \
53-
-d "${{ env.CONFIGURATIONS_FOLDER }}/*.{yml,yaml}"
56+
npx \
57+
--package=ajv-cli \
58+
--package=ajv-formats \
59+
ajv validate \
60+
--all-errors \
61+
-c ajv-formats \
62+
-s "${{ steps.download-schema.outputs.file-path }}" \
63+
-d "${{ env.CONFIGURATIONS_FOLDER }}/*.{yml,yaml}"
5464
5565
download:
5666
needs: check
@@ -118,21 +128,27 @@ jobs:
118128
with:
119129
name: ${{ env.CONFIGURATIONS_ARTIFACT }}
120130

131+
- name: Setup Node.js
132+
uses: actions/setup-node@v3
133+
with:
134+
node-version: ${{ env.NODE_VERSION }}
135+
121136
- name: Merge label configuration files
122137
run: |
123138
# Merge all configuration files
124139
shopt -s extglob
125140
cat "${{ env.CONFIGURATIONS_FOLDER }}"/*.@(yml|yaml) > "${{ env.MERGED_CONFIGURATION_PATH }}"
126141
127142
- name: Install github-label-sync
128-
run: sudo npm install --global github-label-sync
143+
run: npm install
129144

130145
- name: Sync labels
131146
env:
132147
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
133148
run: |
134149
# See: https://github.com/Financial-Times/github-label-sync
135-
github-label-sync \
136-
--labels "${{ env.MERGED_CONFIGURATION_PATH }}" \
137-
${{ steps.dry-run.outputs.flag }} \
138-
${{ github.repository }}
150+
npx \
151+
github-label-sync \
152+
--labels "${{ env.MERGED_CONFIGURATION_PATH }}" \
153+
${{ steps.dry-run.outputs.flag }} \
154+
${{ github.repository }}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
/node_modules/
12
__pycache__/
23
.idea/

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
[![Check Issue Templates status](https://github.com/arduino/tooling-project-assets/actions/workflows/check-issue-templates.yml/badge.svg)](https://github.com/arduino/tooling-project-assets/actions/workflows/check-issue-templates.yml)
55
[![Check Label Configuration status](https://github.com/arduino/tooling-project-assets/actions/workflows/check-labels.yml/badge.svg)](https://github.com/arduino/tooling-project-assets/actions/workflows/check-labels.yml)
66
[![Check markdownlint Configuration status](https://github.com/arduino/tooling-project-assets/actions/workflows/check-markdownlint.yml/badge.svg)](https://github.com/arduino/tooling-project-assets/actions/workflows/check-markdownlint.yml)
7+
[![Check npm status](https://github.com/arduino/tooling-project-assets/actions/workflows/check-npm-task.yml/badge.svg)](https://github.com/arduino/tooling-project-assets/actions/workflows/check-npm-task.yml)
78
[![Check General Formatting status](https://github.com/arduino/tooling-project-assets/actions/workflows/check-general-formatting-task.yml/badge.svg)](https://github.com/arduino/tooling-project-assets/actions/workflows/check-general-formatting-task.yml)
89
[![Check License status](https://github.com/arduino/tooling-project-assets/actions/workflows/check-license.yml/badge.svg)](https://github.com/arduino/tooling-project-assets/actions/workflows/check-license.yml)
910
[![Check Workflow Duplicates Sync status](https://github.com/arduino/tooling-project-assets/actions/workflows/check-dependabot-sync.yml/badge.svg)](https://github.com/arduino/tooling-project-assets/actions/workflows/check-dependabot-sync.yml)
@@ -14,7 +15,7 @@
1415
[![Check Prettier Formatting status](https://github.com/arduino/tooling-project-assets/actions/workflows/check-prettier-formatting-task.yml/badge.svg)](https://github.com/arduino/tooling-project-assets/actions/workflows/check-prettier-formatting-task.yml)
1516
[![Check Taskfiles status](https://github.com/arduino/tooling-project-assets/actions/workflows/check-taskfiles.yml/badge.svg)](https://github.com/arduino/tooling-project-assets/actions/workflows/check-taskfiles.yml)
1617
[![Check YAML status](https://github.com/arduino/tooling-project-assets/actions/workflows/check-yaml-task.yml/badge.svg)](https://github.com/arduino/tooling-project-assets/actions/workflows/check-yaml-task.yml)
17-
[![Sync Labels status](https://github.com/arduino/tooling-project-assets/actions/workflows/sync-labels.yml/badge.svg)](https://github.com/arduino/tooling-project-assets/actions/workflows/sync-labels.yml)
18+
[![Sync Labels status](https://github.com/arduino/tooling-project-assets/actions/workflows/sync-labels-npm.yml/badge.svg)](https://github.com/arduino/tooling-project-assets/actions/workflows/sync-labels-npm.yml)
1819
[![Check Workflows status](https://github.com/arduino/tooling-project-assets/actions/workflows/check-workflows-task.yml/badge.svg)](https://github.com/arduino/tooling-project-assets/actions/workflows/check-workflows-task.yml)
1920
[![Spell Check status](https://github.com/arduino/tooling-project-assets/actions/workflows/spell-check-task.yml/badge.svg)](https://github.com/arduino/tooling-project-assets/actions/workflows/spell-check-task.yml)
2021
[![Check Python status](https://github.com/arduino/tooling-project-assets/actions/workflows/check-python-task.yml/badge.svg)](https://github.com/arduino/tooling-project-assets/actions/workflows/check-python-task.yml)

0 commit comments

Comments
 (0)