Skip to content

Commit

Permalink
Update Makefile and GitHub Actions Workflows
Browse files Browse the repository at this point in the history
- echo hadolint version
- echo golangci-lint version
- echo staticcheck version
- echo markdownlint-cli version
- add `go_mod_changes` job to test for uncommitted `go mod tidy`
  and `go mod vendor` changes
- update repo-bundled golangci-lint configuration to replace (most)
  deprecated linters
  - `golint` to `revive`
  - `scopelint` to `exportloopref`
  • Loading branch information
atc0005 committed Sep 1, 2022
1 parent 784b893 commit a41fd79
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 7 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/lint-and-build-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,17 @@ jobs:
rm -vf .golangci.yml
- name: Run golangci-lint using container-provided config file settings
run: golangci-lint run -v
run: |
golangci-lint --version
golangci-lint run
# This is the very latest stable version of staticcheck provided by the
# atc0005/go-ci container. The version included with golangci-lint often
# lags behind the official stable releases.
- name: Run staticcheck
run: staticcheck $(go list -mod=vendor ./... | grep -v /vendor/)
run: |
staticcheck --version
staticcheck $(go list -mod=vendor ./... | grep -v /vendor/)
test_code:
name: Run tests
Expand Down
25 changes: 24 additions & 1 deletion .github/workflows/lint-and-test-only.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,30 @@ jobs:
rm -vf .golangci.yml
- name: Run golangci-lint using container-provided config file settings
run: golangci-lint run -v
run: |
golangci-lint --version
golangci-lint run
- name: Run all tests
run: go test -mod=vendor -v ./...

go_mod_changes:
name: Look for uncommitted Go module changes
runs-on: ubuntu-latest
timeout-minutes: 10
container:
image: ghcr.io/atc0005/go-ci:go-ci-lint-only

steps:
- name: Check out code
uses: actions/checkout@v3

- name: go mod tidy
run: |
go mod tidy
git diff --exit-code go.mod
- name: go mod vendor
run: |
go mod vendor
git diff --exit-code vendor/
1 change: 1 addition & 0 deletions .github/workflows/lint-docker-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ jobs:

- name: Run hadolint against all Dockerfile files
run: |
hadolint --version
hadolint dependabot/docker/go/Dockerfile
2 changes: 2 additions & 0 deletions .github/workflows/lint-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
run: |
npm install markdownlint --save-dev
npm install -g markdownlint-cli
echo "markdownlint version: $(markdownlint --version)"
- name: Check out code
uses: actions/checkout@v3
Expand All @@ -44,4 +45,5 @@ jobs:
# potential linting issues in bundled documentation to fail linting CI
# runs for *our* documentation
run: |
echo "markdownlint version: $(markdownlint --version)"
markdownlint '**/*.md' --ignore node_modules --ignore vendor
4 changes: 2 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ linters:
- depguard
- dogsled
- dupl
- exportloopref
- goconst
- gocritic
- gofmt
- goimports
- golint
- gosec
- maligned
- misspell
- prealloc
- scopelint
- revive
- stylecheck
- unconvert
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ lintinstall:

@export PATH="${PATH}:$(go env GOPATH)/bin"

@echo "Installing latest stable staticcheck version via go install command ..."
@go install honnef.co/go/tools/cmd/staticcheck@latest
@echo "Installing latest staticcheck version ..."
go install honnef.co/go/tools/cmd/staticcheck@latest
staticcheck --version

@echo Installing latest stable golangci-lint version per official installation script ...
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin
Expand All @@ -117,9 +118,11 @@ linting:
@go vet -mod=vendor $(shell go list -mod=vendor ./... | grep -v /vendor/)

@echo "Running golangci-lint ..."
@golangci-lint --version
@golangci-lint run

@echo "Running staticcheck ..."
@staticcheck --version
@staticcheck $(shell go list -mod=vendor ./... | grep -v /vendor/)

@echo "Finished running linting checks"
Expand Down

0 comments on commit a41fd79

Please sign in to comment.