Skip to content

Commit

Permalink
ci: add generate for mocks
Browse files Browse the repository at this point in the history
Add generation for mocks, which can be run using make generate or
go generate ./...

Correct output-format for golangci-lint as githubs-actions has been
replaced by colored-line-numbers.

Add pre-commit target to help check code is valid before pushing.

Ensure generate and mod tidy don't result in changes.

Implements: #2765
  • Loading branch information
stevenh committed Sep 9, 2024
1 parent 553afd3 commit cc6689c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/ci-test-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,23 @@ jobs:
# takes precedence over all other caching options.
skip-cache: true

- name: generate
working-directory: ./${{ inputs.project-directory }}
shell: bash
run: |
make generate
git --no-pager diff && [[ 0 -eq $(git status --porcelain | wc -l) ]]
- name: modVerify
working-directory: ./${{ inputs.project-directory }}
run: go mod verify

- name: modTidy
working-directory: ./${{ inputs.project-directory }}
run: make tidy
shell: bash
run: |
make tidy
git --no-pager diff && [[ 0 -eq $(git status --porcelain | wc -l) ]]
- name: ensure compilation
working-directory: ./${{ inputs.project-directory }}
Expand Down
15 changes: 13 additions & 2 deletions commons-test.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ $(GOBIN)/golangci-lint:
$(GOBIN)/gotestsum:
$(call go_install,gotest.tools/gotestsum@latest)

$(GOBIN)/mockery:
$(call go_install,github.com/vektra/mockery/[email protected])

.PHONY: install
install: $(GOBIN)/golangci-lint $(GOBIN)/gotestsum
install: $(GOBIN)/golangci-lint $(GOBIN)/gotestsum $(GOBIN)/mockery

.PHONY: clean
clean:
rm $(GOBIN)/golangci-lint
rm $(GOBIN)/gotestsum
rm $(GOBIN)/mockery

.PHONY: dependencies-scan
dependencies-scan:
Expand All @@ -26,7 +30,11 @@ dependencies-scan:

.PHONY: lint
lint: $(GOBIN)/golangci-lint
golangci-lint run --out-format=github-actions --path-prefix=. --verbose -c $(ROOT_DIR)/.golangci.yml --fix
golangci-lint run --out-format=colored-line-number --path-prefix=. --verbose -c $(ROOT_DIR)/.golangci.yml --fix

.PHONY: generate
generate: $(GOBIN)/mockery
go generate ./...

.PHONY: test-%
test-%: $(GOBIN)/gotestsum
Expand All @@ -51,3 +59,6 @@ test-tools: $(GOBIN)/gotestsum
.PHONY: tidy
tidy:
go mod tidy

.PHONY: pre-commit
pre-commit: generate tidy lint
3 changes: 3 additions & 0 deletions generate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package testcontainers

//go:generate mockery

0 comments on commit cc6689c

Please sign in to comment.