Skip to content

Commit

Permalink
Refactor lint github action action.
Browse files Browse the repository at this point in the history
  • Loading branch information
m00g3n committed Feb 21, 2024
1 parent 424b851 commit e9ef894
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 7 deletions.
13 changes: 6 additions & 7 deletions .github/workflows/lint-compass-runtime-agent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,19 @@ name: Run golangci-lint on compass-runtime-agent
on:
push:
paths:
- '$LINTER_WORKING_DIRECTORY/**'
- 'components/compass-runtime-agent/**'
branches: [ "main" ]
pull_request:
paths:
- '$LINTER_WORKING_DIRECTORY/**'
- 'components/compass-runtime-agent/**'

jobs:
golangci-lint:
runs-on: ubuntu-latest
steps:
- name: lint
uses:
- .github/workflows/lint-template/template/golangci-lint
- uses: actions/checkout@v4
- uses: ./.github/workflows/template/golangci-lint
with:
GO_VERSION: '1.21'
LINTER_VERSION: v1.56.2
LINTER_VERSION: 'v1.56.2'
LINTER_WORKING_DIRECTORY: 'components/compass-runtime-agent'

55 changes: 55 additions & 0 deletions .github/workflows/lint-template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: golangci-lint template

inputs:
GO_VERSION:
required: true
LINTER_VERSION:
required: true
LINTER_WORKING_DIRECTORY:
required: true

permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
# pull-requests: read

runs:
using: "composite"
steps:
- uses: actions/setup-go@v5
with:
go-version: ${{ inputs.GO_VERSION }}
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v4
with:
# Require: The version of golangci-lint to use.
# When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
# When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
version: ${{ inputs.LINTER_VERSION }}

# Optional: working directory, useful for monorepos
working-directory: ${{ inputs.LINTER_WORKING_DIRECTORY }}

# Optional: golangci-lint command line arguments.
#
# Note: By default, the `.golangci.yml` file should be at the root of the repository.
# The location of the configuration file can be changed by using `--config=`
# args: --timeout=30m --config=/my/path/.golangci.yml --issues-exit-code=0
args: --timeout=5m

# Optional: show only new issues if it's a pull request. The default value is `false`.
only-new-issues: true

# Optional: if set to true, then all caching functionality will be completely disabled,
# takes precedence over all other caching options.
skip-cache: true

# Optional: if set to true, then the action won't cache or restore ~/go/pkg.
# skip-pkg-cache: true

# Optional: if set to true, then the action won't cache or restore ~/.cache/go-build.
# skip-build-cache: true

# Optional: The mode to install golangci-lint. It can be 'binary' or 'goinstall'.
# install-mode: "goinstall"

0 comments on commit e9ef894

Please sign in to comment.