Skip to content

Commit

Permalink
feat: switch to pipx & add github-token (#23)
Browse files Browse the repository at this point in the history
## πŸ’Œ Description

- switch to pipx for deps install
- deprecate `token` in favor of `github-token`
- prep for v2

## πŸ”— Related issue

<!-- If your PR refers to a related issue, link it here. -->
Fixes: #21

## πŸ—οΈ Type of change

<!-- Mark with an `x` all the checkboxes that apply (like `[x]`) -->

- [ ] πŸ“š 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

<!-- Mark with an `x` all the checkboxes that apply (like `[x]`) -->

- [ ] 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.
  • Loading branch information
DariuszPorowski authored Jul 12, 2024
1 parent ea4eb57 commit a30be53
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 24 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
29 changes: 15 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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

Expand Down
24 changes: 16 additions & 8 deletions action.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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
Expand All @@ -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'])
}
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a30be53

Please sign in to comment.