From 0f16fc9413a2001dbebe34568a5c05fab15107cb Mon Sep 17 00:00:00 2001 From: per1234 Date: Sat, 24 Oct 2020 21:53:21 -0700 Subject: [PATCH 1/2] Add CI workflow to validate action.yml against JSON schema This uses a community-generated schema, but it's well done and actively maintained. --- .github/workflows/validate-action_yml.yml | 47 +++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/validate-action_yml.yml diff --git a/.github/workflows/validate-action_yml.yml b/.github/workflows/validate-action_yml.yml new file mode 100644 index 00000000..ea20dbce --- /dev/null +++ b/.github/workflows/validate-action_yml.yml @@ -0,0 +1,47 @@ +name: Validate action.yml + +on: + pull_request: + paths: + - ".github/workflows/validate-action_yml.yml" + - "action.yml" + push: + paths: + - ".github/workflows/validate-action_yml.yml" + - "action.yml" + # Scheduled trigger to catch workflow failure resulting from changes to the JSON schema + schedule: + # run every Tuesday at 3 AM UTC + - cron: "0 3 * * 2" + # See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows#workflow_dispatch + workflow_dispatch: + # See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows#repository_dispatch + repository_dispatch: + +jobs: + validate: + runs-on: ubuntu-latest + + env: + JSON_SCHEMA_FOLDER: etc/github-action-json-schema + JSON_SCHEMA_FILENAME: github-action.json + + steps: + - name: Checkout local repository + uses: actions/checkout@v2 + + # See: https://github.com/carlosperate/download-file-action/blob/master/README.md + - name: Download JSON schema for action.yml + uses: carlosperate/download-file-action@v1.0.3 + with: + # See: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/github-action.json + file-url: https://json.schemastore.org/github-action + location: ${{ env.JSON_SCHEMA_FOLDER }} + file-name: ${{ env.JSON_SCHEMA_FILENAME }} + + - name: Install JSON schema validator + run: sudo npm install --global ajv-cli + + # See: https://github.com/ajv-validator/ajv-cli/blob/master/README.md + - name: Validate action.yml + run: ajv -s "${{ env.JSON_SCHEMA_FOLDER }}/${{ env.JSON_SCHEMA_FILENAME }}" -d action.yml From 8dd052fe77eebccaf4835a77c93a0b8760cff635 Mon Sep 17 00:00:00 2001 From: per1234 Date: Sat, 24 Oct 2020 21:54:48 -0700 Subject: [PATCH 2/2] Make action.yml compliant with JSON schema These changes seem a bit silly, but they are indeed required by the official specification (even though even GitHub doesn't bother to specify the `inputs..required` value for inputs with an `inputs..default` key in their official workflows). --- action.yml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index e173acc1..d0966048 100644 --- a/action.yml +++ b/action.yml @@ -4,33 +4,43 @@ inputs: cli-version: description: 'Version of Arduino CLI to use when building' default: 'latest' + required: true fqbn: description: 'Full qualified board name, with Boards Manager URL if needed' default: 'arduino:avr:uno' + required: true libraries: description: 'YAML-format list of library dependencies to install' default: '- source-path: ./' + required: true platforms: description: 'YAML-format list of platform dependencies to install' default: '' + required: true sketch-paths: description: 'YAML-format list of paths containing sketches to compile.' default: '- examples' + required: true verbose: description: 'Set to true to show verbose output in the log' - default: false + default: 'false' + required: true sketches-report-path: description: 'Path in which to save a JSON formatted file containing data from the sketch compilations' default: 'sketches-reports' + required: true github-token: description: 'GitHub access token used to get information from the GitHub API. Only needed if you are using the deltas report feature in a private repository.' default: '' + required: true enable-deltas-report: description: 'Set to true to cause the action to determine the change in memory usage and compiler warnings of the compiled sketches between the head and base refs of a PR and the immediate parent commit of a push' - default: false + default: 'false' + required: true enable-warnings-report: description: 'Set to true to cause the action to record the compiler warning count for each sketch compilation in the sketches report' - default: false + default: 'false' + required: true runs: using: 'docker'