Skip to content

Commit

Permalink
Clean up Makefile recipes and CI workflow
Browse files Browse the repository at this point in the history
Fix previous commit based on review feedback
  • Loading branch information
lrettig committed May 13, 2023
1 parent 281c8f6 commit c7cbcd4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
go-version: ${{ env.go-version }}
- name: fmt, tidy
run: |
make install
make test-fmt
make test-tidy
- name: staticcheck
Expand All @@ -39,7 +40,9 @@ jobs:
with:
go-version: ${{ env.go-version }}
- name: lint
run: make lint-github-action
run: |
make install
make lint-github-action
build:
runs-on: ubuntu-latest
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ deps/
go.work

.idea

# Default build artifact
smcli
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ $(DOWNLOAD_DEST):
curl -sSfL $(DEPLOC)/v$(DEPTAG)/$(FN) -o $(DOWNLOAD_DEST)

.PHONY: install
install: $(UNZIP_DEST)
install:
go mod download
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.52.0
go install gotest.tools/gotestsum@v1.9.0
Expand All @@ -128,37 +128,37 @@ test: $(UNZIP_DEST)
go test -v -count 1 -ldflags "-extldflags \"$(STATICLDFLAGS)\"" ./...

.PHONY: test-tidy
test-tidy: install
test-tidy:
# Working directory must be clean, or this test would be destructive
git diff --quiet || (echo "\033[0;31mWorking directory not clean!\033[0m" && git --no-pager diff && exit 1)
# We expect `go mod tidy` not to change anything, the test should fail otherwise
make tidy
git diff --exit-code || (git --no-pager diff && git checkout . && exit 1)

.PHONY: test-fmt
test-fmt: install
test-fmt:
git diff --quiet || (echo "\033[0;31mWorking directory not clean!\033[0m" && git --no-pager diff && exit 1)
# We expect `go fmt` not to change anything, the test should fail otherwise
go fmt ./...
git diff --exit-code || (git --no-pager diff && git checkout . && exit 1)

.PHONY: lint
lint: install
lint:
CGO_CFLAGS="-I$(REAL_DEST)" \
CGO_LDFLAGS="-L$(REAL_DEST)" \
LD_LIBRARY_PATH=$(REAL_DEST) \
./bin/golangci-lint run --config .golangci.yml

# Auto-fixes golangci-lint issues where possible.
.PHONY: lint-fix
lint-fix: install
lint-fix:
CGO_CFLAGS="-I$(REAL_DEST)" \
CGO_LDFLAGS="-L$(REAL_DEST)" \
LD_LIBRARY_PATH=$(REAL_DEST) \
./bin/golangci-lint run --config .golangci.yml --fix

.PHONY: lint-github-action
lint-github-action: install
lint-github-action:
CGO_CFLAGS="-I$(REAL_DEST)" \
CGO_LDFLAGS="-L$(REAL_DEST)" \
LD_LIBRARY_PATH=$(REAL_DEST) \
Expand Down

0 comments on commit c7cbcd4

Please sign in to comment.