Skip to content

Commit

Permalink
Add support to "Check npm" workflow for multiple project npm packages
Browse files Browse the repository at this point in the history
Previously the workflow design assumed that the project would only consist of a single npm package in the root of the
repository.

A project might contain multiple packages in arbitrary subfolders. This is now supported by specifying the path to each
package in the job matrixes.
  • Loading branch information
per1234 committed Oct 18, 2023
1 parent 9c0eec2 commit 3a52fd4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/check-npm-task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,19 @@ jobs:
echo "result=$RESULT" >> $GITHUB_OUTPUT
validate:
name: validate (${{ matrix.package.path }})
needs: run-determination
if: needs.run-determination.outputs.result == 'true'
runs-on: ubuntu-latest
permissions:
contents: read

strategy:
fail-fast: false
matrix:
package:
- path: .

steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -77,15 +84,24 @@ jobs:
github.com/go-task/task/v3/cmd/task
- name: Validate package.json
env:
NPM_PACKAGE_PATH: ${{ matrix.package.path }}
run: task --silent npm:validate

check-sync:
name: check-sync (${{ matrix.package.path }})
needs: run-determination
if: needs.run-determination.outputs.result == 'true'
runs-on: ubuntu-latest
permissions:
contents: read

strategy:
fail-fast: false
matrix:
package:
- path: .

steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -107,6 +123,8 @@ jobs:
github.com/go-task/task/v3/cmd/task
- name: Install npm dependencies
env:
NPM_PACKAGE_PATH: ${{ matrix.package.path }}
run: task npm:install-deps

- name: Check package-lock.json
Expand Down
1 change: 1 addition & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ tasks:
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/npm-task/Taskfile.yml
npm:install-deps:
desc: Install dependencies managed by npm
dir: "{{default .DEFAULT_NPM_PACKAGE_PATH .NPM_PACKAGE_PATH}}"
cmds:
- npm install

Expand Down

0 comments on commit 3a52fd4

Please sign in to comment.