mirror of https://github.com/grafana/grafana
Actions: Introduce actionlint (#105224)
parent
99273f15eb
commit
c92ff0ca75
@ -0,0 +1,66 @@ |
||||
{ |
||||
"$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json", |
||||
"version": "2.1.0", |
||||
"runs": [ |
||||
{ |
||||
"tool": { |
||||
"driver": { |
||||
"name": "GitHub Actions lint", |
||||
"version": {{ getVersion | json }}, |
||||
"informationUri": "https://github.com/rhysd/actionlint", |
||||
"rules": [ |
||||
{{$first := true}} |
||||
{{range $ := allKinds }} |
||||
{{if $first}}{{$first = false}}{{else}},{{end}} |
||||
{ |
||||
"id": {{json $.Name}}, |
||||
"name": {{$.Name | toPascalCase | json}}, |
||||
"defaultConfiguration": { |
||||
"level": "error" |
||||
}, |
||||
"properties": { |
||||
"description": {{json $.Description}}, |
||||
"queryURI": "https://github.com/rhysd/actionlint/blob/main/docs/checks.md" |
||||
}, |
||||
"fullDescription": { |
||||
"text": {{json $.Description}} |
||||
}, |
||||
"helpUri": "https://github.com/rhysd/actionlint/blob/main/docs/checks.md" |
||||
} |
||||
{{end}} |
||||
] |
||||
} |
||||
}, |
||||
"results": [ |
||||
{{$first := true}} |
||||
{{range $ := .}} |
||||
{{if $first}}{{$first = false}}{{else}},{{end}} |
||||
{ |
||||
"ruleId": {{json $.Kind}}, |
||||
"message": { |
||||
"text": {{json $.Message}} |
||||
}, |
||||
"locations": [ |
||||
{ |
||||
"physicalLocation": { |
||||
"artifactLocation": { |
||||
"uri": {{json $.Filepath}}, |
||||
"uriBaseId": "%SRCROOT%" |
||||
}, |
||||
"region": { |
||||
"startLine": {{$.Line}}, |
||||
"startColumn": {{$.Column}}, |
||||
"endColumn": {{$.EndColumn}}, |
||||
"snippet": { |
||||
"text": {{json $.Snippet}} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
] |
||||
} |
||||
{{end}} |
||||
] |
||||
} |
||||
] |
||||
} |
@ -0,0 +1,60 @@ |
||||
# This workflow depends on the ./actionlint-format.txt file. It is MIT licensed (thanks, rhysd!): https://github.com/rhysd/actionlint/blob/2ab3a12c7848f6c15faca9a92612ef4261d0e370/testdata/format/sarif_template.txt |
||||
name: Actionlint |
||||
|
||||
on: |
||||
push: |
||||
branches: |
||||
- main |
||||
- release-* |
||||
pull_request: |
||||
types: |
||||
- opened |
||||
- synchronize |
||||
- reopened |
||||
|
||||
permissions: {} |
||||
|
||||
concurrency: |
||||
group: ${{ github.workflow }}-${{ github.ref }} |
||||
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} |
||||
|
||||
jobs: |
||||
run-actionlint: |
||||
name: Lint GitHub Actions files |
||||
runs-on: ubuntu-latest |
||||
permissions: |
||||
contents: read # to check out the code |
||||
actions: read # to read the workflow files |
||||
security-events: write # for uploading the SARIF report |
||||
|
||||
env: |
||||
ACTIONLINT_VERSION: 1.7.7 |
||||
# curl -LXGET https://github.com/rhysd/actionlint/releases/download/v${ACTIONLINT_VERSION}/actionlint_${ACTIONLINT_VERSION}_checksums.txt | grep linux_amd64 |
||||
CHECKSUM: 023070a287cd8cccd71515fedc843f1985bf96c436b7effaecce67290e7e0757 |
||||
|
||||
steps: |
||||
- name: Checkout code |
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 |
||||
with: |
||||
persist-credentials: false |
||||
|
||||
# GitHub Actions only runs x86_64. This will break if that assumption changes. |
||||
- name: Download Actionlint |
||||
run: | |
||||
set -euo pipefail |
||||
curl -OLXGET https://github.com/rhysd/actionlint/releases/download/v"${ACTIONLINT_VERSION}"/actionlint_"${ACTIONLINT_VERSION}"_linux_amd64.tar.gz |
||||
echo "${CHECKSUM} actionlint_${ACTIONLINT_VERSION}_linux_amd64.tar.gz" | sha256sum -c - |
||||
tar xzf actionlint_"${ACTIONLINT_VERSION}"_linux_amd64.tar.gz |
||||
test -f actionlint |
||||
chmod +x actionlint |
||||
|
||||
- name: Run Actionlint |
||||
run: ./actionlint -format "$(cat .github/workflows/actionlint-format.txt)" | tee results.sarif |
||||
|
||||
- name: Upload to GitHub security events |
||||
if: success() || failure() |
||||
# If there are security problems, GitHub will automatically comment on the PR for us. |
||||
uses: github/codeql-action/upload-sarif@28deaeda66b76a05916b6923827895f2b14ab387 # v3.28.16 |
||||
with: |
||||
sarif_file: results.sarif |
||||
category: actionlint |
Loading…
Reference in new issue