Skip to content

Commit

Permalink
Replace golangci-lint action
Browse files Browse the repository at this point in the history
  • Loading branch information
tsaarni committed Oct 26, 2024
1 parent 1e18a61 commit c9d8eb7
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 19 deletions.
18 changes: 18 additions & 0 deletions .github/actions/golangci-lint/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# This action runs golangci-lint using Makefile.
# It ensures the same version of golangci-lint is used in CI as in local development.
name: golangci-lint
description: 'Run golangci-lint'
inputs:
working-directory:
description: 'Working directory'
required: false
default: '.'
runs:
using: 'composite'
steps:
- name: Run golangci-lint
run: |
echo "::add-matcher::${{ inputs.working-directory }}/.github/actions/golangi-lint/matcher.json"
make lint
echo "::remove-matcher owner=golangci-lint::"
shell: bash
17 changes: 17 additions & 0 deletions .github/actions/golangci-lint/matcher.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"problemMatcher": [
{
"owner": "golangci-lint-colored-line-number",
"severity": "error",
"pattern": [
{
"regexp": "^([^:]+):(\\d+):(?:(\\d+):)?\\s+(.+ \\(.+\\))$",
"file": 1,
"line": 2,
"column": 3,
"message": 4
}
]
}
]
}
12 changes: 1 addition & 11 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,8 @@ jobs:
go-version: "stable"
id: go

- name: Get dependencies
run: |
go get -v -t -d ./...
# https://github.com/golangci/golangci-lint-action
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.61.0
# Workaround for "file exists" errors while running tar.
# golangci-lint-action conflicts with caching in setup-go
skip-pkg-cache: true
uses: ./.github/actions/golangci-lint

- name: Build
run: make build
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
# Local History for Visual Studio Code
.history/

./certyaml
certyaml
14 changes: 14 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
linters:
# https://golangci-lint.run/usage/linters/#enabled-by-default
enable:
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- unused
- gosec
- gofmt
- goimports
- misspell
- revive
11 changes: 4 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
all: check build

check: test lint

test:
go test --race -v ./...

check: test
golangci-lint run
gosec -quiet ./...
lint:
go run github.com/golangci/golangci-lint/cmd/[email protected] run

build:
go build -v ./cmd/certyaml

install:
go install -v ./cmd/certyaml

install-tools:
go install github.com/golangci/golangci-lint/cmd/[email protected]
go install github.com/securego/gosec/v2/cmd/[email protected]

update-modules:
go get -u -t ./... && go mod tidy

0 comments on commit c9d8eb7

Please sign in to comment.