Skip to content

Commit 073fbec

Browse files
authored
Merge pull request #607 from per1234/manage-tool-dependencies
Use npm to manage tool dependencies
2 parents 3bb910e + b998e03 commit 073fbec

8 files changed

+3862
-203
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@ on:
1010
paths:
1111
- ".github/workflows/check-action-metadata-task.ya?ml"
1212
- "action.ya?ml"
13+
- "package.json"
14+
- "package-lock.json"
1315
- "Taskfile.ya?ml"
1416
pull_request:
1517
paths:
1618
- ".github/workflows/check-action-metadata-task.ya?ml"
1719
- "action.ya?ml"
20+
- "package.json"
21+
- "package-lock.json"
1822
- "Taskfile.ya?ml"
1923
schedule:
2024
# Run every Tuesday at 8 AM UTC to catch breakage from changes to the JSON schema.

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ on:
1111
paths:
1212
- ".github/workflows/check-markdown-task.ya?ml"
1313
- ".markdown-link-check.json"
14+
- "package.json"
15+
- "package-lock.json"
1416
- "Taskfile.ya?ml"
1517
- "**/.markdownlint*"
1618
- "**.mdx?"
@@ -21,6 +23,8 @@ on:
2123
paths:
2224
- ".github/workflows/check-markdown-task.ya?ml"
2325
- ".markdown-link-check.json"
26+
- "package.json"
27+
- "package-lock.json"
2428
- "Taskfile.ya?ml"
2529
- "**/.markdownlint*"
2630
- "**.mdx?"
@@ -65,6 +69,11 @@ jobs:
6569
- name: Checkout repository
6670
uses: actions/checkout@v3
6771

72+
- name: Setup Node.js
73+
uses: actions/setup-node@v3
74+
with:
75+
node-version: ${{ env.NODE_VERSION }}
76+
6877
- name: Install Task
6978
uses: arduino/setup-task@v1
7079
with:

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@ on:
1010
paths:
1111
- ".github/workflows/check-tsconfig-task.ya?ml"
1212
- "**/tsconfig*.json"
13+
- "package.json"
14+
- "package-lock.json"
1315
- "Taskfile.ya?ml"
1416
pull_request:
1517
paths:
1618
- ".github/workflows/check-tsconfig-task.ya?ml"
1719
- "**/tsconfig*.json"
20+
- "package.json"
21+
- "package-lock.json"
1822
- "Taskfile.ya?ml"
1923
schedule:
2024
# Run every Tuesday at 8 AM UTC to catch breakage from changes to the JSON schema.

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

Lines changed: 40 additions & 24 deletions
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-
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
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+
10+
# 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@v2
@@ -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
@@ -86,7 +96,7 @@ jobs:
8696
steps:
8797
- name: Set environment variables
8898
run: |
89-
# See: https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
99+
# See: https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable
90100
echo "MERGED_CONFIGURATION_PATH=${{ runner.temp }}/labels.yml" >> "$GITHUB_ENV"
91101
92102
- name: Determine whether to dry run
@@ -119,21 +129,27 @@ jobs:
119129
with:
120130
name: ${{ env.CONFIGURATIONS_ARTIFACT }}
121131

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

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

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
[![Spell Check status](https://github.com/arduino/setup-task/actions/workflows/spell-check-task.yml/badge.svg)](https://github.com/arduino/setup-task/actions/workflows/spell-check-task.yml)
1212
[![Check License status](https://github.com/arduino/setup-task/actions/workflows/check-license.yml/badge.svg)](https://github.com/arduino/setup-task/actions/workflows/check-license.yml)
1313
[![Check npm Dependencies status](https://github.com/arduino/setup-task/actions/workflows/check-npm-dependencies-task.yml/badge.svg)](https://github.com/arduino/setup-task/actions/workflows/check-npm-dependencies-task.yml)
14+
[![Sync Labels status](https://github.com/arduino/setup-task/actions/workflows/sync-labels-npm.yml/badge.svg)](https://github.com/arduino/setup-task/actions/workflows/sync-labels-npm.yml)
1415

1516
A [GitHub Actions](https://docs.github.com/en/actions) action that makes the [Task](https://taskfile.dev/#/) task runner / build tool available to use in your workflow.
1617

Taskfile.yml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ tasks:
4141
vars:
4242
ACTION_METADATA_SCHEMA_PATH:
4343
sh: mktemp -t github-action-schema-XXXXXXXXXX.json
44+
deps:
45+
- task: npm:install-deps
4446
cmds:
4547
- wget --quiet --output-document="{{.ACTION_METADATA_SCHEMA_PATH}}" https://json.schemastore.org/github-action
4648
- npx ajv-cli validate --strict=false -s "{{.ACTION_METADATA_SCHEMA_PATH}}" -d "action.yml"
@@ -95,6 +97,8 @@ tasks:
9597
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-prettier-formatting-task/Taskfile.yml
9698
general:format-prettier:
9799
desc: Format all supported files with Prettier
100+
deps:
101+
- task: npm:install-deps
98102
cmds:
99103
- npx prettier --write .
100104

@@ -109,6 +113,7 @@ tasks:
109113
desc: Check for broken links
110114
deps:
111115
- task: docs:generate
116+
- task: npm:install-deps
112117
cmds:
113118
- |
114119
if [[ "{{.OS}}" == "Windows_NT" ]]; then
@@ -152,12 +157,16 @@ tasks:
152157
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-markdown-task/Taskfile.yml
153158
markdown:fix:
154159
desc: Automatically correct linting violations in Markdown files where possible
160+
deps:
161+
- task: npm:install-deps
155162
cmds:
156163
- npx markdownlint-cli --fix "**/*.md"
157164

158165
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-markdown-task/Taskfile.yml
159166
markdown:lint:
160167
desc: Check for problems in Markdown files
168+
deps:
169+
- task: npm:install-deps
161170
cmds:
162171
- npx markdownlint-cli "**/*.md"
163172

@@ -240,34 +249,29 @@ tasks:
240249
ts:build:
241250
desc: Build the action's TypeScript code.
242251
deps:
243-
- task: ts:install-deps
252+
- task: npm:install-deps
244253
cmds:
245254
- npx tsc
246255
- npx ncc build
247256

248257
ts:fix-lint:
249258
desc: Fix TypeScript code linting violations
250259
deps:
251-
- task: ts:install-deps
260+
- task: npm:install-deps
252261
cmds:
253262
- npx eslint --ext .js,.jsx,.ts,.tsx --fix .
254263

255-
ts:install-deps:
256-
desc: Install TypeScript dependencies
257-
deps:
258-
- task: npm:install-deps
259-
260264
ts:lint:
261265
desc: Lint TypeScript code
262266
deps:
263-
- task: ts:install-deps
267+
- task: npm:install-deps
264268
cmds:
265269
- npx eslint --ext .js,.jsx,.ts,.tsx .
266270

267271
ts:test:
268272
desc: Test the action's TypeScript code.
269273
deps:
270-
- task: ts:install-deps
274+
- task: npm:install-deps
271275
cmds:
272276
- npx jest
273277

@@ -283,6 +287,8 @@ tasks:
283287
sh: task utility:mktemp-folder TEMPLATE="ts-validate-XXXXXXXXXX"
284288
WORKING_INSTANCE_PATH:
285289
sh: echo "{{.WORKING_FOLDER}}/$(basename "{{.INSTANCE_PATH}}")"
290+
deps:
291+
- task: npm:install-deps
286292
cmds:
287293
- |
288294
# TypeScript allows comments in tsconfig.json.

0 commit comments

Comments
 (0)