Skip to content

Use npm to manage tool dependencies #607

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/check-action-metadata-task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/check-markdown-task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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?"
Expand All @@ -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?"
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/check-tsconfig-task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/sync-labels.md
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/sync-labels-npm.md
name: Sync Labels

# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
env:
# See: https://github.com/actions/setup-node/#readme
NODE_VERSION: 16.x
CONFIGURATIONS_FOLDER: .github/label-configuration-files
CONFIGURATIONS_ARTIFACT: label-configuration-files

# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
on:
push:
paths:
- ".github/workflows/sync-labels.ya?ml"
- ".github/workflows/sync-labels-npm.ya?ml"
- ".github/label-configuration-files/*.ya?ml"
- "package.json"
- "package-lock.json"
pull_request:
paths:
- ".github/workflows/sync-labels.ya?ml"
- ".github/workflows/sync-labels-npm.ya?ml"
- ".github/label-configuration-files/*.ya?ml"
- "package.json"
- "package-lock.json"
schedule:
# Run daily at 8 AM UTC to sync with changes to shared label configurations.
- cron: "0 8 * * *"
workflow_dispatch:
repository_dispatch:

env:
CONFIGURATIONS_FOLDER: .github/label-configuration-files
CONFIGURATIONS_ARTIFACT: label-configuration-files

jobs:
check:
runs-on: ubuntu-latest
Expand All @@ -29,6 +35,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: Download JSON schema for labels configuration file
id: download-schema
uses: carlosperate/download-file-action@v2
Expand All @@ -37,20 +48,19 @@ jobs:
location: ${{ runner.temp }}/label-configuration-schema

- name: Install JSON schema validator
run: |
sudo npm install \
--global \
ajv-cli \
ajv-formats
run: npm install

- name: Validate local labels configuration
run: |
# See: https://github.com/ajv-validator/ajv-cli#readme
ajv validate \
--all-errors \
-c ajv-formats \
-s "${{ steps.download-schema.outputs.file-path }}" \
-d "${{ env.CONFIGURATIONS_FOLDER }}/*.{yml,yaml}"
npx \
--package=ajv-cli \
--package=ajv-formats \
ajv validate \
--all-errors \
-c ajv-formats \
-s "${{ steps.download-schema.outputs.file-path }}" \
-d "${{ env.CONFIGURATIONS_FOLDER }}/*.{yml,yaml}"

download:
needs: check
Expand Down Expand Up @@ -86,7 +96,7 @@ jobs:
steps:
- name: Set environment variables
run: |
# See: https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
# See: https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable
echo "MERGED_CONFIGURATION_PATH=${{ runner.temp }}/labels.yml" >> "$GITHUB_ENV"

- name: Determine whether to dry run
Expand Down Expand Up @@ -119,21 +129,27 @@ jobs:
with:
name: ${{ env.CONFIGURATIONS_ARTIFACT }}

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}

- name: Merge label configuration files
run: |
# Merge all configuration files
shopt -s extglob
cat "${{ env.CONFIGURATIONS_FOLDER }}"/*.@(yml|yaml) > "${{ env.MERGED_CONFIGURATION_PATH }}"

- name: Install github-label-sync
run: sudo npm install --global github-label-sync
run: npm install

- name: Sync labels
env:
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# See: https://github.com/Financial-Times/github-label-sync
github-label-sync \
--labels "${{ env.MERGED_CONFIGURATION_PATH }}" \
${{ steps.dry-run.outputs.flag }} \
${{ github.repository }}
npx \
github-label-sync \
--labels "${{ env.MERGED_CONFIGURATION_PATH }}" \
${{ steps.dry-run.outputs.flag }} \
${{ github.repository }}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
[![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)
[![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)
[![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)
[![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)

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.

Expand Down
24 changes: 15 additions & 9 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 .

Expand All @@ -109,6 +113,7 @@ tasks:
desc: Check for broken links
deps:
- task: docs:generate
- task: npm:install-deps
cmds:
- |
if [[ "{{.OS}}" == "Windows_NT" ]]; then
Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -240,34 +249,29 @@ tasks:
ts:build:
desc: Build the action's TypeScript code.
deps:
- task: ts:install-deps
- task: npm:install-deps
cmds:
- npx tsc
- npx ncc build

ts:fix-lint:
desc: Fix TypeScript code linting violations
deps:
- task: ts:install-deps
- task: npm:install-deps
cmds:
- npx eslint --ext .js,.jsx,.ts,.tsx --fix .

ts:install-deps:
desc: Install TypeScript dependencies
deps:
- task: npm:install-deps

ts:lint:
desc: Lint TypeScript code
deps:
- task: ts:install-deps
- task: npm:install-deps
cmds:
- npx eslint --ext .js,.jsx,.ts,.tsx .

ts:test:
desc: Test the action's TypeScript code.
deps:
- task: ts:install-deps
- task: npm:install-deps
cmds:
- npx jest

Expand All @@ -283,6 +287,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.
Expand Down
Loading