forked from arduino/compile-sketches
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update infrastructure for action metadata validation
A task and GitHub Actions workflow are provided here for validating the action.yml metadata file of GitHub Actions actions. On every push or pull request that affects the metadata file, and periodically, validate action.yml against its JSON schema.
- Loading branch information
Showing
7 changed files
with
657 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-action-metadata-task.md | ||
name: Check Action Metadata | ||
|
||
env: | ||
# See: https://github.com/actions/setup-node/#readme | ||
NODE_VERSION: 16.x | ||
|
||
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows | ||
on: | ||
create: | ||
push: | ||
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. | ||
- 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: | ||
needs: run-determination | ||
if: needs.run-determination.outputs.result == 'true' | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- 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: | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
version: 3.x | ||
|
||
- name: Validate action.yml | ||
run: task --silent action:validate |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,5 @@ venv/ | |
*.bak | ||
*.code-workspace | ||
*.sublime-workspace | ||
|
||
/node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# See: https://taskfile.dev/#/usage | ||
version: "3" | ||
|
||
tasks: | ||
check: | ||
desc: Check for problems with the project | ||
deps: | ||
- task: action:validate | ||
|
||
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-action-metadata-task/Taskfile.yml | ||
action:validate: | ||
desc: Validate GitHub Actions metadata against JSON schema | ||
vars: | ||
ACTION_METADATA_SCHEMA_PATH: | ||
sh: task utility:mktemp-file TEMPLATE="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" | ||
# 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 | ||
run: once | ||
cmds: | ||
- npm install | ||
|
||
# Make a temporary file named according to the passed TEMPLATE variable and print the path passed to stdout | ||
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/windows-task/Taskfile.yml | ||
utility:mktemp-file: | ||
vars: | ||
RAW_PATH: | ||
sh: mktemp --tmpdir "{{.TEMPLATE}}" | ||
cmds: | ||
- task: utility:normalize-path | ||
vars: | ||
RAW_PATH: "{{.RAW_PATH}}" | ||
|
||
# Make a temporary folder named according to the passed TEMPLATE variable and print the path passed to stdout | ||
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/windows-task/Taskfile.yml | ||
utility:mktemp-folder: | ||
vars: | ||
RAW_PATH: | ||
sh: mktemp --directory --tmpdir "{{.TEMPLATE}}" | ||
cmds: | ||
- task: utility:normalize-path | ||
vars: | ||
RAW_PATH: "{{.RAW_PATH}}" | ||
|
||
# Print a normalized version of the path passed via the RAW_PATH variable to stdout | ||
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/windows-task/Taskfile.yml | ||
utility:normalize-path: | ||
cmds: | ||
- | | ||
if [[ "{{.OS}}" == "Windows_NT" ]] && which cygpath &>/dev/null; then | ||
# Even though the shell handles POSIX format absolute paths as expected, external applications do not. | ||
# So paths passed to such applications must first be converted to Windows format. | ||
cygpath -w "{{.RAW_PATH}}" | ||
else | ||
echo "{{.RAW_PATH}}" | ||
fi |
Oops, something went wrong.