Skip to content

Add template workflow to validate Taskfiles #13

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 1 commit into from
Jun 15, 2021
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
54 changes: 54 additions & 0 deletions .github/workflows/check-taskfiles.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-taskfiles.md
name: Check Taskfiles

# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
on:
push:
paths:
- ".github/workflows/check-taskfiles.ya?ml"
- "**/Taskfile.ya?ml"
pull_request:
paths:
- ".github/workflows/check-taskfiles.ya?ml"
- "**/Taskfile.ya?ml"
schedule:
# Run every Tuesday at 8 AM UTC to catch breakage resulting from changes to the JSON schema.
- cron: "0 8 * * TUE"
workflow_dispatch:
repository_dispatch:

jobs:
validate:
name: Validate ${{ matrix.file }}
runs-on: ubuntu-latest

strategy:
fail-fast: false

matrix:
file:
# TODO: add paths to any additional Taskfiles here
- ./**/Taskfile.yml

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Download JSON schema for Taskfiles
id: download-schema
uses: carlosperate/download-file-action@v1.0.3
with:
# See: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/taskfile.json
file-url: https://json.schemastore.org/taskfile.json
location: ${{ runner.temp }}/taskfile-schema

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

- name: Validate ${{ matrix.file }}
run: |
# See: https://github.com/ajv-validator/ajv-cli#readme
ajv validate \
--strict=false \
-s "${{ steps.download-schema.outputs.file-path }}" \
-d "${{ matrix.file }}"
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
[![Check Configuration Files Sync status](https://github.com/arduino/tooling-project-assets/actions/workflows/check-config-sync.yml/badge.svg)](https://github.com/arduino/tooling-project-assets/actions/workflows/check-config-sync.yml)
[![Check Markdown status](https://github.com/arduino/tooling-project-assets/actions/workflows/check-markdown-task.yml/badge.svg)](https://github.com/arduino/tooling-project-assets/actions/workflows/check-markdown-task.yml)
[![Check Prettier Formatting status](https://github.com/arduino/tooling-project-assets/actions/workflows/check-prettier-formatting-task.yml/badge.svg)](https://github.com/arduino/tooling-project-assets/actions/workflows/check-prettier-formatting-task.yml)
[![Check Taskfiles status](https://github.com/arduino/tooling-project-assets/actions/workflows/check-taskfiles.yml/badge.svg)](https://github.com/arduino/tooling-project-assets/actions/workflows/check-taskfiles.yml)


The [Arduino](https://www.arduino.cc/) Tooling Team's collection of reusable project infrastructure assets.

Expand Down
1 change: 1 addition & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ tasks:
"{{.WORKFLOW_TEMPLATES_PATH}}/check-general-formatting-task.yml" \
"{{.WORKFLOW_TEMPLATES_PATH}}/check-markdown-task.yml" \
"{{.WORKFLOW_TEMPLATES_PATH}}/check-prettier-formatting-task.yml" \
"{{.WORKFLOW_TEMPLATES_PATH}}/check-taskfiles.yml" \
"{{.WORKFLOWS_PATH}}"

config:sync:
Expand Down
40 changes: 40 additions & 0 deletions workflow-templates/check-taskfiles.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# "Check Taskfiles" workflow

Workflow file: [check-taskfiles.yml](check-taskfiles.yml)

Validate the repository's [Taskfiles](https://taskfile.dev/#/usage) against the JSON schema.

## Readme badge

Markdown badge:

```markdown
[![Check Taskfiles status](https://github.com/REPO_OWNER/REPO_NAME/actions/workflows/check-taskfiles.yml/badge.svg)](https://github.com/REPO_OWNER/REPO_NAME/actions/workflows/check-taskfiles.yml)
```

Replace the `REPO_OWNER` and `REPO_NAME` placeholders in the URLs with the final repository owner and name ([example](https://raw.githubusercontent.com/arduino-libraries/ArduinoIoTCloud/master/README.md)).

---

Asciidoc badge:

```adoc
image:https://github.com/{repository-owner}/{repository-name}/actions/workflows/check-taskfiles.yml/badge.svg["Check Taskfiles status", link="https://github.com/{repository-owner}/{repository-name}/actions/workflows/check-taskfiles.yml"]
```

Define the `{repository-owner}` and `{repository-name}` attributes and use them throughout the readme ([example](https://raw.githubusercontent.com/arduino-libraries/WiFiNINA/master/README.adoc)).

## Commit message

```
Add CI workflow to validate Taskfiles

On every push or pull request that affects the repository's Taskfiles, and periodically, validate them
against the JSON schema.
```

## PR message

```markdown
On every push or pull request that affects the repository's [Taskfiles](https://taskfile.dev/#/usage), and periodically, validate them against the JSON schema.
```
54 changes: 54 additions & 0 deletions workflow-templates/check-taskfiles.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-taskfiles.md
name: Check Taskfiles

# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
on:
push:
paths:
- ".github/workflows/check-taskfiles.ya?ml"
- "**/Taskfile.ya?ml"
pull_request:
paths:
- ".github/workflows/check-taskfiles.ya?ml"
- "**/Taskfile.ya?ml"
schedule:
# Run every Tuesday at 8 AM UTC to catch breakage resulting from changes to the JSON schema.
- cron: "0 8 * * TUE"
workflow_dispatch:
repository_dispatch:

jobs:
validate:
name: Validate ${{ matrix.file }}
runs-on: ubuntu-latest

strategy:
fail-fast: false

matrix:
file:
# TODO: add paths to any additional Taskfiles here
- ./**/Taskfile.yml

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Download JSON schema for Taskfiles
id: download-schema
uses: carlosperate/download-file-action@v1.0.3
with:
# See: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/taskfile.json
file-url: https://json.schemastore.org/taskfile.json
location: ${{ runner.temp }}/taskfile-schema

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

- name: Validate ${{ matrix.file }}
run: |
# See: https://github.com/ajv-validator/ajv-cli#readme
ajv validate \
--strict=false \
-s "${{ steps.download-schema.outputs.file-path }}" \
-d "${{ matrix.file }}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-taskfiles.md
name: Check Taskfiles

# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
on:
push:
paths:
- ".github/workflows/check-taskfiles.ya?ml"
- "**/Taskfile.ya?ml"
pull_request:
paths:
- ".github/workflows/check-taskfiles.ya?ml"
- "**/Taskfile.ya?ml"
schedule:
# Run every Tuesday at 8 AM UTC to catch breakage resulting from changes to the JSON schema.
- cron: "0 8 * * TUE"
workflow_dispatch:
repository_dispatch:

jobs:
validate:
name: Validate ${{ matrix.file }}
runs-on: ubuntu-latest

strategy:
fail-fast: false

matrix:
file:
# TODO: add paths to any additional Taskfiles here
- ./**/Taskfile.yml

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Download JSON schema for Taskfiles
id: download-schema
uses: carlosperate/download-file-action@v1.0.3
with:
# See: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/taskfile.json
file-url: https://json.schemastore.org/taskfile.json
location: ${{ runner.temp }}/taskfile-schema

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

- name: Validate ${{ matrix.file }}
run: |
# See: https://github.com/ajv-validator/ajv-cli#readme
ajv validate \
--strict=false \
-s "${{ steps.download-schema.outputs.file-path }}" \
-d "${{ matrix.file }}"