Skip to content

Commit

Permalink
Make the linter CI action reusable by other repos (grafana#3033)
Browse files Browse the repository at this point in the history
  • Loading branch information
na-- authored Apr 28, 2023
1 parent 948587b commit c6d8148
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 15 deletions.
28 changes: 28 additions & 0 deletions .github/actions/lint/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: golangci-lint-k6
description: Run golangci-lint with the k6 ruleset

runs:
using: composite
steps:
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: 1.20.x
check-latest: true
- name: Get golangci-lint version and download rules
shell: bash
env: #TODO: remove after https://github.com/actions/runner/issues/2473 is fixed
GITHUB_ACTION_REF: ${{ github.action_ref || github.head_ref }}
run: |
RulesURL="https://raw.githubusercontent.com/grafana/k6/${{ env.GITHUB_ACTION_REF }}/.golangci.yml"
echo "Downloading ${RulesURL}..."
curl --silent --show-error --fail --no-location "${RulesURL}" --output "${{ github.action_path }}/.golangci.yml"
echo "GolangCIVersion=$(head -n 1 "${{ github.action_path }}/.golangci.yml" | tr -d '# ')" >> "${GITHUB_OUTPUT}"
id: getenv
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: ${{ steps.getenv.outputs.GolangCIVersion }}
only-new-issues: true
args: "--config=${{ github.action_path }}/.golangci.yml"
17 changes: 2 additions & 15 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,5 @@ jobs:
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.20.x
check-latest: true
- name: Retrieve golangci-lint version
run: |
echo "Version=$(head -n 1 "${GITHUB_WORKSPACE}/.golangci.yml" | tr -d '# ')" >> $GITHUB_OUTPUT
id: version
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: ${{ steps.version.outputs.Version }}
only-new-issues: true
- name: Run linters
uses: ./.github/actions/lint/

0 comments on commit c6d8148

Please sign in to comment.