Use npm to manage tool dependencies
Some of the assets use tools sourced from the npm software registry. 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. --- These tools were installed via either of the following methods: `npx <pkg>` This approach has the following behaviors of interest: https://docs.npmjs.com/cli/v8/commands/npx#description > If any requested packages are not present in the local project dependencies, then they are installed to a folder in the npm cache, which is added to the PATH environment variable in the executed process. > Package names provided without a specifier will be matched with whatever version exists in the local project. Package names with a specifier will only be considered a match if they have the exact same name and version as the local dependency. This means that the version used was: 1. Whatever happens to be present in the local cache 2. The latest available version if it is not already present `npm install --global <pkg>` The latest available version of the package is used. --- The new approach is to specify the version of the tools via the standard npm metadata files (package.json + package-lock.json). This approach was chosen over the `npx <pkg>@<version>` alternative for the following reasons: - Enables automated updates via Dependabot PRs - Enables automated vulnerability alerts - Separates dependency management from the asset contents (i.e., no need to mess with the taskfile or workflow on every update) - Matches how we are already managing Python dependencies (pyproject.toml + poetry.lock)
This commit is contained in:
@@ -10,11 +10,15 @@ on:
|
||||
paths:
|
||||
- ".github/workflows/check-action-metadata-task.ya?ml"
|
||||
- "action.ya?ml"
|
||||
- "package.json"
|
||||
- "package-lock.json"
|
||||
- "Taskfile.ya?ml"
|
||||
pull_request:
|
||||
paths:
|
||||
- ".github/workflows/check-action-metadata-task.ya?ml"
|
||||
- "action.ya?ml"
|
||||
- "package.json"
|
||||
- "package-lock.json"
|
||||
- "Taskfile.ya?ml"
|
||||
schedule:
|
||||
# Run every Tuesday at 8 AM UTC to catch breakage from changes to the JSON schema.
|
||||
|
||||
+9
@@ -11,6 +11,8 @@ on:
|
||||
paths:
|
||||
- ".github/workflows/check-markdown-task.ya?ml"
|
||||
- ".markdown-link-check.json"
|
||||
- "package.json"
|
||||
- "package-lock.json"
|
||||
- "Taskfile.ya?ml"
|
||||
- "**/.markdownlint*"
|
||||
- "**.mdx?"
|
||||
@@ -21,6 +23,8 @@ on:
|
||||
paths:
|
||||
- ".github/workflows/check-markdown-task.ya?ml"
|
||||
- ".markdown-link-check.json"
|
||||
- "package.json"
|
||||
- "package-lock.json"
|
||||
- "Taskfile.ya?ml"
|
||||
- "**/.markdownlint*"
|
||||
- "**.mdx?"
|
||||
@@ -65,6 +69,11 @@ jobs:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
|
||||
- name: Install Task
|
||||
uses: arduino/setup-task@v1
|
||||
with:
|
||||
|
||||
+4
@@ -10,11 +10,15 @@ on:
|
||||
paths:
|
||||
- ".github/workflows/check-tsconfig-task.ya?ml"
|
||||
- "**/tsconfig*.json"
|
||||
- "package.json"
|
||||
- "package-lock.json"
|
||||
- "Taskfile.ya?ml"
|
||||
pull_request:
|
||||
paths:
|
||||
- ".github/workflows/check-tsconfig-task.ya?ml"
|
||||
- "**/tsconfig*.json"
|
||||
- "package.json"
|
||||
- "package-lock.json"
|
||||
- "Taskfile.ya?ml"
|
||||
schedule:
|
||||
# Run every Tuesday at 8 AM UTC to catch breakage from changes to the JSON schema.
|
||||
|
||||
@@ -41,6 +41,8 @@ tasks:
|
||||
vars:
|
||||
ACTION_METADATA_SCHEMA_PATH:
|
||||
sh: mktemp -t github-action-schema-XXXXXXXXXX.json
|
||||
deps:
|
||||
- task: npm:install-deps
|
||||
cmds:
|
||||
- wget --quiet --output-document="{{.ACTION_METADATA_SCHEMA_PATH}}" https://json.schemastore.org/github-action
|
||||
- npx ajv-cli validate --strict=false -s "{{.ACTION_METADATA_SCHEMA_PATH}}" -d "action.yml"
|
||||
@@ -95,6 +97,8 @@ tasks:
|
||||
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-prettier-formatting-task/Taskfile.yml
|
||||
general:format-prettier:
|
||||
desc: Format all supported files with Prettier
|
||||
deps:
|
||||
- task: npm:install-deps
|
||||
cmds:
|
||||
- npx prettier --write .
|
||||
|
||||
@@ -109,6 +113,7 @@ tasks:
|
||||
desc: Check for broken links
|
||||
deps:
|
||||
- task: docs:generate
|
||||
- task: npm:install-deps
|
||||
cmds:
|
||||
- |
|
||||
if [[ "{{.OS}}" == "Windows_NT" ]]; then
|
||||
@@ -152,12 +157,16 @@ tasks:
|
||||
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-markdown-task/Taskfile.yml
|
||||
markdown:fix:
|
||||
desc: Automatically correct linting violations in Markdown files where possible
|
||||
deps:
|
||||
- task: npm:install-deps
|
||||
cmds:
|
||||
- npx markdownlint-cli --fix "**/*.md"
|
||||
|
||||
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-markdown-task/Taskfile.yml
|
||||
markdown:lint:
|
||||
desc: Check for problems in Markdown files
|
||||
deps:
|
||||
- task: npm:install-deps
|
||||
cmds:
|
||||
- npx markdownlint-cli "**/*.md"
|
||||
|
||||
@@ -283,6 +292,8 @@ tasks:
|
||||
sh: task utility:mktemp-folder TEMPLATE="ts-validate-XXXXXXXXXX"
|
||||
WORKING_INSTANCE_PATH:
|
||||
sh: echo "{{.WORKING_FOLDER}}/$(basename "{{.INSTANCE_PATH}}")"
|
||||
deps:
|
||||
- task: npm:install-deps
|
||||
cmds:
|
||||
- |
|
||||
# TypeScript allows comments in tsconfig.json.
|
||||
|
||||
Generated
+1868
File diff suppressed because it is too large
Load Diff
@@ -39,8 +39,11 @@
|
||||
"github-label-sync": "2.2.0",
|
||||
"jest": "^28.1.3",
|
||||
"jest-circus": "^29.3.1",
|
||||
"markdown-link-check": "^3.10.3",
|
||||
"markdownlint-cli": "^0.32.2",
|
||||
"nock": "^13.2.9",
|
||||
"prettier": "^2.8.1",
|
||||
"strip-json-comments-cli": "^2.0.2",
|
||||
"ts-jest": "^28.0.8",
|
||||
"typescript": "^4.9.4"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user