From a30be5376b9c8a5b493b09a88f4b2de2b5c4f062 Mon Sep 17 00:00:00 2001 From: Dariusz Porowski <3431813+DariuszPorowski@users.noreply.github.com> Date: Fri, 12 Jul 2024 09:58:37 -0700 Subject: [PATCH] feat: switch to pipx & add github-token (#23) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 💌 Description - switch to pipx for deps install - deprecate `token` in favor of `github-token` - prep for v2 ## 🔗 Related issue Fixes: #21 ## 🏗️ Type of change - [ ] 📚 Examples/docs/tutorials - [ ] 🐛 Bug fix (non-breaking change which fixes an issue) - [ ] 🥂 Improvement (non-breaking change which improves an existing feature) - [ ] 🚀 New feature (non-breaking change which adds functionality) - [ ] 💥 Breaking change (fix or feature that would cause existing functionality to change) - [ ] 🚨 Security fix - [ ] ⬆️ Dependencies update ## ✅ Checklist - [ ] I've read the [`Code of Conduct`](https://github.com/raven-actions/actionlint/blob/main/.github/CODE_OF_CONDUCT.md) document. - [ ] I've read the [`Contributing`](https://github.com/raven-actions/actionlint/blob/main/.github/CONTRIBUTING.md) guide. --- .pre-commit-config.yaml | 4 ++-- README.md | 29 +++++++++++++++-------------- action.yml | 24 ++++++++++++++++-------- 3 files changed, 33 insertions(+), 24 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 30df3b0..04286a5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ repos: # files: .pre-commit-config.yaml - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v4.6.0 hooks: - id: check-symlinks - id: trailing-whitespace @@ -40,7 +40,7 @@ repos: exclude: package-lock.json - repo: https://github.com/gitleaks/gitleaks - rev: v8.18.0 + rev: v8.18.4 hooks: - id: gitleaks args: diff --git a/README.md b/README.md index fe80b0b..c12efa4 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ This [GitHub Action](https://github.com/features/actions) allows you to quickly - Action is platform-independent and tested on all the latest GitHub-hosted runners (`ubuntu-latest`, `macos-latest`, `windows-latest`). - Uses [GitHub cache](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows) for caching `actionlint` binaries for faster and more efficient workflow run. - - 3rd party `actionlint` dependencies like `shellcheck` or `pyflakes` are not cached, but action installs them if not present on the Runner. + - 3rd party `actionlint` dependencies like `shellcheck` or `pyflakes` are not cached, but action installs them if not present on the GitHub Runner using [pipx](https://pipx.pypa.io/) (make sure your GitHub Runner has it). ![demo-error](https://raw.githubusercontent.com/raven-actions/actionlint/main/assets/images/demo-error.png) @@ -33,7 +33,7 @@ Just place in your GitHub workflow steps: ```yaml - name: actionlint - uses: raven-actions/actionlint@v1 + uses: raven-actions/actionlint@v2 ``` ### Customization @@ -45,7 +45,7 @@ Action returns some basic information. For more details, follow [📤 Outputs](# ```yaml - name: actionlint id: actionlint #optional, id required only when outputs are used in the workflow steps later - uses: raven-actions/actionlint@v1 + uses: raven-actions/actionlint@v2 with: matcher: false # optional cache: false # optional @@ -68,17 +68,18 @@ Action returns some basic information. For more details, follow [📤 Outputs](# ## 📥 Inputs -| Name | Required | Type | Default value | Description | -| :-------------: | :------: | :------: | :-----------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `version` | false | `string` | `latest` | SemVer version of `actionlint`, recommended to keep default: latest | -| `matcher` | false | `bool` | `true` | Use matcher for GitHub annotations | -| `files` | false | `string` | *not set* | To lint different workflow files (default searching directory is `.github/workflows`), use comma-separated glob patterns, e.g., `tests/*.yml, tests/*.yaml` | -| `flags` | false | `string` | *not set* | Extra flags to use with `actionlint` | -| `group-result` | false | `bool` | `true` | Use the GitHub log grouping feature for failure actionlint results. | -| `fail-on-error` | false | `bool` | `true` | Fail action on `actionlint` errors | -| `shellcheck` | false | `bool` | `true` | Use `shellcheck` with `actionlint` (and install if it does not exist) | -| `pyflakes` | false | `bool` | `true` | Use `pyflakes` with `actionlint` (and install if it does not exist) | -| `cache` | false | `bool` | `true` | Use GitHub cache for caching binaries for the next runs | +| Name | Required | Type | Default value | Description | +| :--------------: | :------: | :------: | :--------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `version` | false | `string` | `latest` | SemVer version of `actionlint`, recommended to keep default: `latest` | +| `matcher` | false | `bool` | `true` | Use matcher for GitHub annotations. | +| `files` | false | `string` | _not set_ | To lint different workflow files (default searching directory is `.github/workflows`), use comma-separated glob patterns, e.g., `tests/*.yml, tests/*.yaml` | +| `flags` | false | `string` | _not set_ | Extra flags to use with `actionlint` | +| `group-result` | false | `bool` | `true` | Use the GitHub log grouping feature for failure actionlint results. | +| `fail-on-error` | false | `bool` | `true` | Fail action on `actionlint` errors. | +| `shellcheck` | false | `bool` | `true` | Use `shellcheck` with `actionlint` (and install if it does not exist) | +| `pyflakes` | false | `bool` | `true` | Use `pyflakes` with `actionlint` (and install if it does not exist) | +| `cache` | false | `bool` | `true` | Use GitHub cache for caching binaries for the next runs. | +| `github-token` | false | `string` | `github.token` | GitHub Token for API authentication. | ## 📤 Outputs diff --git a/action.yml b/action.yml index a2c597c..49c10eb 100644 --- a/action.yml +++ b/action.yml @@ -1,5 +1,6 @@ ---- +# yaml-language-server: $schema=https://json.schemastore.org/github-action.json # https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions +--- name: actionlint description: ✅ Run actionlint for validating your GitHub Actions workflow files. author: Dariusz Porowski @@ -56,6 +57,11 @@ inputs: description: GitHub Token required: false default: ${{ github.token }} + deprecationMessage: Use `github-token` input instead + github-token: + description: GitHub Token + required: false + default: ${{ github.token }} outputs: version-semver: description: SemVer version @@ -86,7 +92,7 @@ runs: uses: actions/github-script@v7 id: environment with: - github-token: ${{ inputs.token || env.GITHUB_TOKEN }} + github-token: ${{ inputs.github-token || inputs.token || env.GITHUB_TOKEN }} script: | // input envs const { INPUT_TOOL_NAME, INPUT_TOOL_SEMVER, INPUT_REPO_OWNER, INPUT_REPO_NAME, RUNNER_TEMP } = process.env @@ -202,10 +208,11 @@ runs: shell: ${{ (runner.os == 'Windows' && 'pwsh') || 'bash' }} working-directory: ${{ inputs.working-directory }} - - uses: actions/github-script@v7 + - name: Download tool + uses: actions/github-script@v7 if: ${{ steps.tool-cache.outputs.cache-hit != 'true' }} with: - github-token: ${{ inputs.token || env.GITHUB_TOKEN }} + github-token: ${{ inputs.github-token || inputs.token || env.GITHUB_TOKEN }} script: | // dependencies const tc = require('@actions/tool-cache') @@ -242,7 +249,7 @@ runs: if: ${{ inputs.pyflakes == 'true' || inputs.shellcheck == 'true' }} id: tool-dependencies with: - github-token: ${{ inputs.token || env.GITHUB_TOKEN }} + github-token: ${{ inputs.github-token || inputs.token || env.GITHUB_TOKEN }} script: | // input envs const { INPUT_PYFLAKES, INPUT_SHELLCHECK } = process.env @@ -268,7 +275,7 @@ runs: core.debug(`${pyflakesBinary} exists: ${pyflakesExists}`) if (pyflakesExists === false) { - await exec.exec('python3', ['-m', 'pip', 'install', '--upgrade', 'pyflakes']) + await exec.exec('pipx', ['install', 'pyflakes']) } } @@ -303,10 +310,11 @@ runs: INPUT_PYFLAKES: ${{ inputs.pyflakes }} INPUT_SHELLCHECK: ${{ inputs.shellcheck }} - - uses: actions/github-script@v7 + - name: Run tool + uses: actions/github-script@v7 id: tool-runner with: - github-token: ${{ inputs.token || env.GITHUB_TOKEN }} + github-token: ${{ inputs.github-token || inputs.token || env.GITHUB_TOKEN }} script: | // input envs const { INPUT_FILES, INPUT_FLAGS, INPUT_TOOL_NAME, INPUT_TOOL_DIR_PATH, INPUT_MATCHER, INPUT_MATCHER_PATH, INPUT_TOOL_EXECUTABLE, INPUT_JSON, INPUT_FAIL_ON_ERROR, INPUT_PYFLAKES, INPUT_SHELLCHECK, INPUT_GROUP_RESULT, DEBUG } = process.env