Skip to content

Add CI workflow to validate Taskfiles #7

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

env:
# See: https://github.com/actions/setup-node/#readme
NODE_VERSION: 16.x

# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
on:
create:
push:
paths:
- ".github/workflows/check-taskfiles.ya?ml"
- "package.json"
- "package-lock.json"
- "**/Taskfile.ya?ml"
pull_request:
paths:
- ".github/workflows/check-taskfiles.ya?ml"
- "package.json"
- "package-lock.json"
- "**/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:
run-determination:
runs-on: ubuntu-latest
outputs:
result: ${{ steps.determination.outputs.result }}
steps:
- name: Determine if the rest of the workflow should run
id: determination
run: |
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
if [[
"${{ github.event_name }}" != "create" ||
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
]]; then
# Run the other jobs.
RESULT="true"
else
# There is no need to run the other jobs.
RESULT="false"
fi

echo "result=$RESULT" >> $GITHUB_OUTPUT

validate:
name: Validate ${{ matrix.file }}
needs: run-determination
if: needs.run-determination.outputs.result == 'true'
runs-on: ubuntu-latest

strategy:
fail-fast: false

matrix:
file:
- ./**/Taskfile.yml

steps:
- 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 Taskfiles
id: download-schema
uses: carlosperate/download-file-action@v2
with:
# Source: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/taskfile.json
file-url: https://taskfile.dev/schema.json
location: ${{ runner.temp }}/taskfile-schema

- name: Install JSON schema validator
run: npm install

- name: Validate ${{ matrix.file }}
run: |
# See: https://github.com/ajv-validator/ajv-cli#readme
npx \
--package=ajv-cli \
--package=ajv-formats \
ajv validate \
--all-errors \
--strict=false \
-c ajv-formats \
-s "${{ steps.download-schema.outputs.file-path }}" \
-d "${{ matrix.file }}"
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# go-win32-utils
[![Sync Labels status](https://github.com/arduino/go-win32-utils/actions/workflows/sync-labels.yml/badge.svg)](https://github.com/arduino/go-win32-utils/actions/workflows/sync-labels.yml)
[![Check Markdown status](https://github.com/arduino/go-win32-utils/actions/workflows/check-markdown-task.yml/badge.svg)](https://github.com/arduino/go-win32-utils/actions/workflows/check-markdown-task.yml)
[![Check Taskfiles status](https://github.com/arduino/go-win32-utils/actions/workflows/check-taskfiles.yml/badge.svg)](https://github.com/arduino/go-win32-utils/actions/workflows/check-taskfiles.yml)

This library contains some useful calls to win32 API that are not available on the standard golang library.

Expand Down
Loading