Skip to content

Commit

Permalink
feat: removed the deprecated pre-commit repo pre-commit-golang. Added…
Browse files Browse the repository at this point in the history
… new CI step to run golangci-lint using the github action
  • Loading branch information
aarmoa committed Feb 13, 2025
1 parent 49b9c7f commit 73bbcef
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 11 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: golangci-lint
on:
pull_request:
push:
branches: [master, dev]
permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
pull-requests: read

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
check-latest: true
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: latest

# Optional: working directory, useful for monorepos
# working-directory: somedir

# Optional: golangci-lint command line arguments.
args: --timeout=15m -v

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

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

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

# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
# skip-build-cache: true
5 changes: 1 addition & 4 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@ jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v4
- uses: actions/checkout@master
- uses: actions/checkout@v3
with:
fetch-depth: 2
- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
check-latest: true
- run: go install golang.org/x/tools/cmd/goimports@latest
- run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.59.0
- uses: pre-commit/action@v2.0.2
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"errorlint",
"gas",
"gocritic",
"gofmt",
"goimports",
"gosimple",
"govet",
"ineffassign",
Expand Down
7 changes: 0 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,3 @@ repos:
- id: end-of-file-fixer
- id: end-of-file-fixer
- id: check-yaml
- repo: https://github.com/dnephin/pre-commit-golang
rev: master
hooks:
- id: go-fmt
- id: go-imports
- id: golangci-lint
args: [--timeout=15m]

0 comments on commit 73bbcef

Please sign in to comment.