Skip to content

Commit

Permalink
Adds golangci-lint job (#8)
Browse files Browse the repository at this point in the history
Uses golangci/golangci-lint-action for linting the golang code, and adds
a few additional linters.

Also builds the go binary to ensure there are no compilation errors.
  • Loading branch information
claudiubelu authored Aug 28, 2024
1 parent 1692853 commit cd60143
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/golangci-lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: golangci-lint
on:
push:
branches:
- main
pull_request:

permissions:
contents: read
pull-requests: read

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: stable
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.60

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: stable
- name: Build
run: go build -v -buildvcs=false -o bin/mutating-pebble-webhook ./cmd/
28 changes: 28 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
output:
print-linter-name: true

linters:
# Some linters are already enabled by default, no need to explicitly add them here.
# https://golangci-lint.run/usage/linters#enabled-by-default
enable:
# bugs / errors
- dupl
- gosec
- revive

# performance
- gocritic
- prealloc

# style, formatting
- goconst
- gofmt
- stylecheck
- tagliatelle

linters-settings:
errcheck:
# Report about not checking of errors in type assertions: `a := b.(MyStruct)`.
# Such cases aren't reported by default.
# Default: false
check-type-assertions: true

0 comments on commit cd60143

Please sign in to comment.