Skip to content

Commit 187c483

Browse files
committed
Add support to "Check npm" workflow for projects in subfolders
The "Check npm" workflow checks for problems with the npm configuration files of a repository. Previously this workflow assumed that a repository would only ever have these files in the root folder. However, a repository might also contain multiple separate npm-managed projects in arbitrary subfolders. Support for any repository structure is added to the workflow by using a job matrix to check the projects under an array of arbitrary paths that can be configured for the specific repository the template is installed in.
1 parent 838f0e9 commit 187c483

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

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

+17-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,15 @@ jobs:
5151
run: task --silent npm:validate
5252

5353
check-sync:
54+
name: check-sync (${{ matrix.project.path }})
5455
runs-on: ubuntu-latest
5556

57+
strategy:
58+
fail-fast: false
59+
matrix:
60+
project:
61+
- path: .
62+
5663
steps:
5764
- name: Checkout repository
5865
uses: actions/checkout@v4
@@ -69,7 +76,15 @@ jobs:
6976
version: 3.x
7077

7178
- name: Install npm dependencies
72-
run: task npm:install-deps
79+
run: |
80+
task \
81+
npm:install-deps \
82+
PROJECT_PATH="${{ matrix.project.path }}"
7383
7484
- name: Check package-lock.json
75-
run: git diff --color --exit-code package-lock.json
85+
run: |
86+
git \
87+
diff \
88+
--color \
89+
--exit-code \
90+
"${{ matrix.project.path }}/package-lock.json"

Taskfile.yml

+8-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ includes:
55
dist: ./DistTasks.yml
66

77
vars:
8+
# Path of the primary npm-managed project:
9+
DEFAULT_NPM_PROJECT_PATH: ./
810
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/release-go-task/Taskfile.yml
911
PROJECT_NAME: "arduinoOTA"
1012
DIST_DIR: "dist"
@@ -239,7 +241,12 @@ tasks:
239241

240242
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/npm-task/Taskfile.yml
241243
npm:install-deps:
242-
desc: Install dependencies managed by npm
244+
desc: |
245+
Install dependencies managed by npm.
246+
Environment variable parameters:
247+
PROJECT_PATH: Path of the npm-managed project (default: {{.DEFAULT_NPM_PROJECT_PATH}}).
248+
dir: |
249+
"{{default .DEFAULT_NPM_PROJECT_PATH .PROJECT_PATH}}"
243250
cmds:
244251
- npm install
245252

0 commit comments

Comments
 (0)