Skip to content

Commit

Permalink
ci: Introduce more checks
Browse files Browse the repository at this point in the history
Improve development by extending `make check` target with:
- <https://github.com/dkorunic/betteralign> - improves structs memory alignment
- <https://github.com/kisielk/errcheck> - finds unhandled errors
- <https://staticcheck.dev> - finds common pitfails
- `mod verify` - verifies dependencies
- `mod tidy` - removes unused dependencies
- `go fmt` - formats code.
  • Loading branch information
macie committed Sep 8, 2024
1 parent 1c8e284 commit bbe39ef
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
github.com:443
objects.githubusercontent.com:443
proxy.golang.org:443
sum.golang.org:443
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4

Expand Down Expand Up @@ -54,6 +55,7 @@ jobs:
github.com:443
objects.githubusercontent.com:443
proxy.golang.org:443
sum.golang.org:443
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jobs:
github.com:443
objects.githubusercontent.com:443
proxy.golang.org:443
sum.golang.org:443
ppa.launchpadcontent.net:443
packages.microsoft.com:443
azure.archive.ubuntu.com:80
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
api.github.com:443
objects.githubusercontent.com:443
proxy.golang.org:443
sum.golang.org:443
ppa.launchpadcontent.net:443
packages.microsoft.com:443
azure.archive.ubuntu.com:80
Expand Down
20 changes: 19 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ GO = go
GOFLAGS =
LDFLAGS = -ldflags "-s -w -X main.AppVersion=$(CLI_VERSION)"

BETTERALIGN = $$($(GO) env GOPATH)/bin/betteralign
ERRCHECK = $$($(GO) env GOPATH)/bin/errcheck
STATICCHECK = $$($(GO) env GOPATH)/bin/staticcheck


#
# INTERNAL MACROS
Expand Down Expand Up @@ -53,13 +57,23 @@ info:
@uname -rsv;
@echo '# Development dependencies:'
@$(GO) version || true
@$(BETTERALIGN) -V=full || true
# @$(ERRCHECK) --version || true # not supported, see: https://github.com/kisielk/errcheck/issues/254
@$(STATICCHECK) --version || true
@echo '# Go environment variables:'
@$(GO) env || true

.PHONY: check
check:
@echo '# Static analysis' >&2
$(GO) vet
$(GO) vet ./...
$(STATICCHECK) ./...
$(ERRCHECK) ./...
$(BETTERALIGN) ./...
$(GO) mod verify
@echo '# Formatting' >&2
$(GO) fmt ./...
$(GO) mod tidy

.PHONY: test
test:
Expand Down Expand Up @@ -95,6 +109,10 @@ dist: sortof-linux_amd64 sortof-openbsd_amd64 sortof-windows_amd64.exe

.PHONY: install-dependencies
install-dependencies:
@echo '# Install development dependencies:' >&2
$(GO) install github.com/dkorunic/betteralign/cmd/betteralign@latest
$(GO) install github.com/kisielk/errcheck@latest
$(GO) install honnef.co/go/tools/cmd/staticcheck@latest
@echo '# Install CLI dependencies:' >&2
@GOFLAGS='-v -x' $(GO) get -C $(CLI_DIR) $(GOFLAGS) .

Expand Down

0 comments on commit bbe39ef

Please sign in to comment.