Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow actionlint to run shellcheck on run blocks #481

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion linters/actionlint/plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ lint:
- name: actionlint
files: [github-workflow]
# Custom parser/trigger type defined in the trunk cli.
tools: [actionlint]
tools: [actionlint, shellcheck]
commands:
- name: lint
output: actionlint
Expand Down
24 changes: 24 additions & 0 deletions linters/actionlint/test_data/actionlint_v1.6.21_CUSTOM.check.shot
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,30 @@
exports[`Testing linter actionlint test CUSTOM 1`] = `
{
"issues": [
{
"code": "shellcheck",
"column": "9",
"file": ".github/workflows/bad.in.yaml",
"issueClass": "ISSUE_CLASS_NEW",
"issueUrl": "https://github.com/rhysd/actionlint/blob/main/docs/checks.md",
"level": "LEVEL_HIGH",
"line": "12",
"linter": "actionlint",
"message": "shellcheck reported issue in this script: SC2086:info:1:4: Double quote to prevent globbing and word splitting",
"targetType": "github-workflow",
},
{
"code": "shellcheck",
"column": "9",
"file": ".github/workflows/bad.in.yaml",
"issueClass": "ISSUE_CLASS_NEW",
"issueUrl": "https://github.com/rhysd/actionlint/blob/main/docs/checks.md",
"level": "LEVEL_HIGH",
"line": "12",
"linter": "actionlint",
"message": "shellcheck reported issue in this script: SC2086:info:1:9: Double quote to prevent globbing and word splitting",
"targetType": "github-workflow",
},
{
"code": "events",
"column": "13",
Expand Down
90 changes: 90 additions & 0 deletions linters/actionlint/test_data/actionlint_v1.6.26_CUSTOM.check.shot
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Testing linter actionlint test CUSTOM 1`] = `
{
"issues": [
{
"code": "shellcheck",
"column": "9",
"file": ".github/workflows/bad.in.yaml",
"issueClass": "ISSUE_CLASS_NEW",
"issueUrl": "https://github.com/rhysd/actionlint/blob/main/docs/checks.md",
"level": "LEVEL_HIGH",
"line": "12",
"linter": "actionlint",
"message": "shellcheck reported issue in this script: SC2086:info:1:4: Double quote to prevent globbing and word splitting",
"targetType": "github-workflow",
},
{
"code": "shellcheck",
"column": "9",
"file": ".github/workflows/bad.in.yaml",
"issueClass": "ISSUE_CLASS_NEW",
"issueUrl": "https://github.com/rhysd/actionlint/blob/main/docs/checks.md",
"level": "LEVEL_HIGH",
"line": "12",
"linter": "actionlint",
"message": "shellcheck reported issue in this script: SC2086:info:1:9: Double quote to prevent globbing and word splitting",
"targetType": "github-workflow",
},
{
"code": "events",
"column": "13",
"file": ".github/workflows/bad.in.yaml",
"issueClass": "ISSUE_CLASS_NEW",
"issueUrl": "https://github.com/rhysd/actionlint/blob/main/docs/checks.md",
"level": "LEVEL_HIGH",
"line": "4",
"linter": "actionlint",
"message": "invalid CRON format "0 */3 * *" in schedule event: expected exactly 5 fields, found 4: [0 */3 * *]",
"targetType": "github-workflow",
},
{
"code": "events",
"column": "13",
"file": ".github/workflows/bad.in.yaml",
"issueClass": "ISSUE_CLASS_NEW",
"issueUrl": "https://github.com/rhysd/actionlint/blob/main/docs/checks.md",
"level": "LEVEL_HIGH",
"line": "6",
"linter": "actionlint",
"message": "scheduled job runs too frequently. it runs once per 60 seconds. the shortest interval is once every 5 minutes",
"targetType": "github-workflow",
},
{
"code": "syntax-check",
"column": "1",
"file": ".github/workflows/empty.in.yaml",
"issueClass": "ISSUE_CLASS_NEW",
"issueUrl": "https://github.com/rhysd/actionlint/blob/main/docs/checks.md",
"level": "LEVEL_HIGH",
"line": "1",
"linter": "actionlint",
"message": "workflow is empty",
"targetType": "github-workflow",
},
],
"lintActions": [
{
"command": "lint",
"fileGroupName": "github-workflow",
"linter": "actionlint",
"paths": [
".github/workflows/bad.in.yaml",
],
"verb": "TRUNK_VERB_CHECK",
},
{
"command": "lint",
"fileGroupName": "github-workflow",
"linter": "actionlint",
"paths": [
".github/workflows/empty.in.yaml",
],
"verb": "TRUNK_VERB_CHECK",
},
],
"taskFailures": [],
"unformattedFiles": [],
}
`;
24 changes: 24 additions & 0 deletions linters/actionlint/test_data/actionlint_v1.6.9_CUSTOM.check.shot
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,30 @@
exports[`Testing linter actionlint test CUSTOM 1`] = `
{
"issues": [
{
"code": "shellcheck",
"column": "9",
"file": ".github/workflows/bad.in.yaml",
"issueClass": "ISSUE_CLASS_NEW",
"issueUrl": "https://github.com/rhysd/actionlint/blob/main/docs/checks.md",
"level": "LEVEL_HIGH",
"line": "12",
"linter": "actionlint",
"message": "shellcheck reported issue in this script: SC2086:info:1:4: Double quote to prevent globbing and word splitting",
"targetType": "github-workflow",
},
{
"code": "shellcheck",
"column": "9",
"file": ".github/workflows/bad.in.yaml",
"issueClass": "ISSUE_CLASS_NEW",
"issueUrl": "https://github.com/rhysd/actionlint/blob/main/docs/checks.md",
"level": "LEVEL_HIGH",
"line": "12",
"linter": "actionlint",
"message": "shellcheck reported issue in this script: SC2086:info:1:9: Double quote to prevent globbing and word splitting",
"targetType": "github-workflow",
},
{
"code": "events",
"column": "13",
Expand Down
2 changes: 1 addition & 1 deletion linters/actionlint/test_data/bad.in.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- run: echo ...
- run: cp $foo $bar