Skip to content

Commit d6c9e32

Browse files
✨ feat(inputs): group-result (#10)
## 💌 Description <!-- Add a more detailed description of the changes if needed. --> Adds `group-result` feature, to skip GitHub grouping when actionlint fails. ## 🔗 Related issue <!-- If your PR refers to a related issue, link it here. --> Fixes: #8 ## 🏗️ 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) - [x] 🥂 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]`) --> - [x] I've read the [`Code of Conduct`](https://github.com/raven-actions/actionlint/blob/main/.github/CODE_OF_CONDUCT.md)> document. - [x] I've read the [`Contributing`](https://github.com/raven-actions/actionlint/blob/main/.github/CONTRIBUTING.md) guide.
1 parent 5f96b36 commit d6c9e32

File tree

7 files changed

+51
-90
lines changed

7 files changed

+51
-90
lines changed

.github/linters/.markdown-link-check.json

Lines changed: 0 additions & 28 deletions
This file was deleted.

.github/stale.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ jobs:
5959
files: "tests/fixtures/*.yml, tests/fixtures/*.yaml"
6060
flags: "-ignore SC2086"
6161
fail-on-error: false
62+
group-result: false
6263

6364
- name: actionlint Outputs
6465
if: ${{ steps.actionlint.outputs.exit-code != '0' }}

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ repos:
4444
- id: gitleaks
4545
args:
4646
- --config
47-
- ".github/linters/.gitleak.toml"
47+
- ".github/linters/.gitleaks.toml"
4848

4949
# - repo: https://github.com/rhysd/actionlint
5050
# rev: v1.6.24

README.md

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![GitHub - ci](https://img.shields.io/github/actions/workflow/status/raven-actions/actionlint/ci.yml?logo=github&label=CI&style=flat-square&branch=main&event=push)](https://github.com/raven-actions/actionlint/actions/workflows/ci.yml?query=branch%3Amain+event%3Apush)
66
[![GitHub - license](https://img.shields.io/github/license/raven-actions/actionlint?style=flat-square)](https://github.com/raven-actions/actionlint/blob/main/LICENSE)
77

8-
This [GitHub Action](https://github.com/features/actions) allows you to quickly and easily run [actionlint](https://github.com/rhysd/actionlint) in your GitHub workflow using native Runner OS without 3rd party dependencies. It is based on an official action lint usage proposal from [Use actionlint on GitHub Actions](https://github.com/rhysd/actionlint/blob/main/docs/usage.md#use-actionlint-on-github-actions) together with [Problem Matchers](https://github.com/rhysd/actionlint/blob/main/docs/usage.md#problem-matchers).
8+
This [GitHub Action](https://github.com/features/actions) allows you to quickly and easily run [actionlint](https://github.com/rhysd/actionlint) in your GitHub workflow using native Runner OS without installing 3rd party dependencies. It is based on an official action lint usage proposal from [Use actionlint on GitHub Actions](https://github.com/rhysd/actionlint/blob/main/docs/usage.md#use-actionlint-on-github-actions) together with [Problem Matchers](https://github.com/rhysd/actionlint/blob/main/docs/usage.md#problem-matchers).
99

1010
- Action is platform-independent and tested on all the latest GitHub-hosted runners (`ubuntu-latest`, `macos-latest`, `windows-latest`).
1111
- 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.
@@ -15,17 +15,17 @@ This [GitHub Action](https://github.com/features/actions) allows you to quickly
1515

1616
![demo-ok](https://raw.githubusercontent.com/raven-actions/actionlint/main/assets/images/demo-ok.png)
1717

18-
## Table of Contents <!-- omit in toc -->
18+
## 📑 Table of Contents <!-- omit in toc -->
1919

20-
- [🤔 Usage](#-usage)
20+
- [🛠️ Usage](#-usage)
2121
- [Quick Start](#quick-start)
2222
- [Customization](#customization)
2323
- [📥 Inputs](#-inputs)
2424
- [📤 Outputs](#-outputs)
2525
- [👥 Contributing](#-contributing)
26-
- [📄 License](#-license)
26+
- [🛡️ License](#-license)
2727

28-
## 🤔 Usage
28+
## 🛠️ Usage
2929

3030
### Quick Start
3131

@@ -68,33 +68,34 @@ Action returns some basic information. For more details, follow [📤 Outputs](#
6868
6969
## 📥 Inputs
7070
71-
| Name | Required | Type | Default value | Description |
72-
|-----------------|----------|----------|---------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------|
73-
| `version` | false | `string` | `latest` | SemVer version of `actionlint`, recommended to keep default: latest |
74-
| `matcher` | false | `bool` | `true` | Use matcher for GitHub annotations |
75-
| `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` |
76-
| `flags` | false | `string` | *not set* | Extra flags to use with `actionlint` |
77-
| `fail-on-error` | false | `bool` | `true` | Fail action on `actionlint` errors |
78-
| `shellcheck` | false | `bool` | `true` | Use `shellcheck` with `actionlint` (and install if it does not exist) |
79-
| `pyflakes` | false | `bool` | `true` | Use `pyflakes` with `actionlint` (and install if it does not exist) |
80-
| `cache` | false | `bool` | `true` | Use GitHub cache for caching binaries for the next runs |
71+
| Name | Required | Type | Default value | Description |
72+
|:---------------:|:--------:|:--------:|:-------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------|
73+
| `version` | false | `string` | `latest` | SemVer version of `actionlint`, recommended to keep default: latest |
74+
| `matcher` | false | `bool` | `true` | Use matcher for GitHub annotations |
75+
| `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` |
76+
| `flags` | false | `string` | *not set* | Extra flags to use with `actionlint` |
77+
| `group-result` | false | `bool` | `true` | Use the GitHub log grouping feature for failure actionlint results. |
78+
| `fail-on-error` | false | `bool` | `true` | Fail action on `actionlint` errors |
79+
| `shellcheck` | false | `bool` | `true` | Use `shellcheck` with `actionlint` (and install if it does not exist) |
80+
| `pyflakes` | false | `bool` | `true` | Use `pyflakes` with `actionlint` (and install if it does not exist) |
81+
| `cache` | false | `bool` | `true` | Use GitHub cache for caching binaries for the next runs |
8182

8283
## 📤 Outputs
8384

84-
| Name | Type | Description |
85-
|------------------|----------|--------------------------------------------------------------------------------------------------------------------------------|
85+
| Name | Type | Description |
86+
|:----------------:|:--------:|:-------------------------------------------------------------------------------------------------------------------------------|
8687
| `version-semver` | `string` | SemVer version of `actionlint`, recommended to keep default: latest |
87-
| `version-tag` | `string` | Use matcher for GitHub annotations |
88-
| `exit-code` | `int` | Exit status code based on [actionlint exit status](https://github.com/rhysd/actionlint/blob/main/docs/usage.md#exit-status) |
89-
| `exit-message` | `string` | Exit status message based on [actionlint exit status](https://github.com/rhysd/actionlint/blob/main/docs/usage.md#exit-status) |
90-
| `total-errors` | `int` | Total number of errors found during the linting |
91-
| `total-files` | `int` | Total number of checked files |
92-
| `cache-hit` | `bool` | GitHub cache has been used? |
88+
| `version-tag` | `string` | Use matcher for GitHub annotations |
89+
| `exit-code` | `int` | Exit status code based on [actionlint exit status](https://github.com/rhysd/actionlint/blob/main/docs/usage.md#exit-status) |
90+
| `exit-message` | `string` | Exit status message based on [actionlint exit status](https://github.com/rhysd/actionlint/blob/main/docs/usage.md#exit-status) |
91+
| `total-errors` | `int` | Total number of errors found during the linting |
92+
| `total-files` | `int` | Total number of checked files |
93+
| `cache-hit` | `bool` | GitHub cache has been used? |
9394

9495
## 👥 Contributing
9596

9697
Contributions to the project are welcome! Please follow [Contributing Guide](https://github.com/raven-actions/actionlint/blob/main/.github/CONTRIBUTING.md).
9798

98-
## 📄 License
99+
## 🛡️ License
99100

100101
This project is distributed under the terms of the [MIT](https://github.com/raven-actions/actionlint/blob/main/LICENSE) license.

action.yml

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions
22
name: actionlint
3-
description: Run actionlint in your GitHub workflow
3+
description: Run actionlint for validating your GitHub Actions workflow files.
44
author: Dariusz Porowski
55
branding:
6-
icon: check-circle # https://feathericons.com
6+
icon: check-circle
77
color: gray-dark
88

99
inputs:
@@ -39,6 +39,10 @@ inputs:
3939
description: Fail on error
4040
required: false
4141
default: ${{ true }}
42+
group-result:
43+
description: Group result
44+
required: false
45+
default: ${{ true }}
4246
cache:
4347
description: Cache tool
4448
required: false
@@ -81,6 +85,7 @@ runs:
8185
uses: actions/github-script@v6
8286
id: environment
8387
with:
88+
github-token: ${{ inputs.token || env.GITHUB_TOKEN }}
8489
script: |
8590
// input envs
8691
const { INPUT_TOOL_NAME, INPUT_TOOL_SEMVER, INPUT_REPO_OWNER, INPUT_REPO_NAME, RUNNER_TEMP } = process.env
@@ -177,7 +182,6 @@ runs:
177182
core.setOutput('tool-executable', toolExecutable)
178183
core.setOutput('tool-executable-path', core.toPlatformPath(`${toolDirPath}/${toolExecutable}`))
179184
env:
180-
GITHUB_TOKEN: ${{ inputs.token || env.GITHUB_TOKEN }}
181185
INPUT_TOOL_NAME: "actionlint"
182186
INPUT_REPO_OWNER: "rhysd"
183187
INPUT_REPO_NAME: "actionlint"
@@ -191,21 +195,16 @@ runs:
191195
path: ${{ steps.environment.outputs.tool-dir-path }}
192196
key: ${{ format('{0}-{1}-{2}-{3}', steps.environment.outputs.tool-name, steps.environment.outputs.tool-version-semver, runner.os, runner.arch) }}
193197

194-
- name: Install dependencies (Linux/macOS)
195-
if: ${{ steps.tool-cache.outputs.cache-hit != 'true' && runner.os != 'Windows' }}
196-
run: npm install @actions/tool-cache
197-
shell: bash
198-
working-directory: ${{ inputs.working-directory }}
199-
200-
- name: Install dependencies (Windows)
201-
if: ${{ steps.tool-cache.outputs.cache-hit != 'true' && runner.os == 'Windows' }}
198+
- name: Install dependencies
199+
if: ${{ steps.tool-cache.outputs.cache-hit != 'true' }}
202200
run: npm install @actions/tool-cache
203-
shell: pwsh
201+
shell: ${{ (runner.os == 'Windows' && 'pwsh') || 'bash' }}
204202
working-directory: ${{ inputs.working-directory }}
205203

206204
- uses: actions/github-script@v6
207205
if: ${{ steps.tool-cache.outputs.cache-hit != 'true' }}
208206
with:
207+
github-token: ${{ inputs.token || env.GITHUB_TOKEN }}
209208
script: |
210209
// dependencies
211210
const tc = require('@actions/tool-cache')
@@ -231,7 +230,6 @@ runs:
231230
const matcherTempPath = await tc.downloadTool(INPUT_MATCHER_DOWNLOAD_URL)
232231
await io.cp(matcherTempPath, INPUT_MATCHER_PATH, { force: true })
233232
env:
234-
GITHUB_TOKEN: ${{ inputs.token || env.GITHUB_TOKEN }}
235233
INPUT_TOOL_NAME: ${{ steps.environment.outputs.tool-name }}
236234
INPUT_TOOL_DIR_PATH: ${{ steps.environment.outputs.tool-dir-path }}
237235
INPUT_TOOL_DOWNLOAD_URL: ${{ steps.environment.outputs.tool-download-url }}
@@ -243,6 +241,7 @@ runs:
243241
if: ${{ inputs.pyflakes == 'true' || inputs.shellcheck == 'true' }}
244242
id: tool-dependencies
245243
with:
244+
github-token: ${{ inputs.token || env.GITHUB_TOKEN }}
246245
script: |
247246
// input envs
248247
const { INPUT_PYFLAKES, INPUT_SHELLCHECK } = process.env
@@ -298,16 +297,16 @@ runs:
298297
}
299298
}
300299
env:
301-
GITHUB_TOKEN: ${{ inputs.token || env.GITHUB_TOKEN }}
302300
INPUT_PYFLAKES: ${{ inputs.pyflakes }}
303301
INPUT_SHELLCHECK: ${{ inputs.shellcheck }}
304302

305303
- uses: actions/github-script@v6
306304
id: tool-runner
307305
with:
306+
github-token: ${{ inputs.token || env.GITHUB_TOKEN }}
308307
script: |
309308
// input envs
310-
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, DEBUG } = process.env
309+
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
311310
312311
// helpers
313312
function niceHeader(label, color, emoji, group = false) {
@@ -319,7 +318,6 @@ runs:
319318
}
320319
const emojis = {
321320
arrowDown: '⬇️',
322-
stop: '🛑',
323321
warning: '⚠️',
324322
error: '❌',
325323
check: '✅'
@@ -400,9 +398,14 @@ runs:
400398
core.debug(`[${INPUT_TOOL_NAME}] ${exitMessage} (exit code: ${exitCode})`)
401399
402400
if (exitCode !== 0) {
403-
await core.group(niceHeader(`Results`, 'red', 'stop', true), async () => {
401+
if (INPUT_GROUP_RESULT === 'true') {
402+
await core.group(niceHeader(`Results`, 'red', 'error', true), async () => {
403+
core.info(`${stdout.trim()}`)
404+
})
405+
} else {
406+
core.info(niceHeader(`Results`, 'red', 'error'))
404407
core.info(`${stdout.trim()}`)
405-
})
408+
}
406409
}
407410
408411
const outputVerbose = stderr.trim()
@@ -429,10 +432,10 @@ runs:
429432
}
430433
else {
431434
core.warning(niceHeader(`${exitMessage} (found ${totalErrors} errors, linted ${totalFiles} files), exit code: ${exitCode}`, 'yellow', 'warning'))
432-
process.exit(core.ExitCode.Success)}
435+
process.exit(core.ExitCode.Success)
436+
}
433437
}
434438
env:
435-
GITHUB_TOKEN: ${{ inputs.token || env.GITHUB_TOKEN }}
436439
INPUT_TOOL_NAME: ${{ steps.environment.outputs.tool-name }}
437440
INPUT_TOOL_DIR_PATH: ${{ steps.environment.outputs.tool-dir-path }}
438441
INPUT_TOOL_EXECUTABLE: ${{ steps.environment.outputs.tool-executable }}
@@ -444,3 +447,4 @@ runs:
444447
INPUT_SHELLCHECK: ${{ inputs.shellcheck }}
445448
INPUT_FILES: ${{ inputs.files }}
446449
INPUT_FLAGS: ${{ inputs.flags }}
450+
INPUT_GROUP_RESULT: ${{ inputs.group-result }}

0 commit comments

Comments
 (0)