Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Go install gotestsum and golangci-lint #2127

Merged
merged 4 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/ci-test-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,7 @@ jobs:
if: ${{ inputs.run-tests }}
working-directory: ./${{ inputs.project-directory }}
timeout-minutes: 30
run: |
go install gotest.tools/gotestsum@latest
make test-unit
run: make test-unit

- name: Upload SonarCloud files
if: ${{ github.ref_name == 'main' && github.repository_owner == 'testcontainers' && inputs.run-tests && !inputs.rootless-docker }}
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/ci-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ jobs:

- name: go test
timeout-minutes: 30
run: |
go install gotest.tools/gotestsum@latest
gotestsum --format short-verbose --rerun-fails=5 --packages="./..." --junitfile TEST-unit.xml -- -timeout=30m
run: make test-unit

- name: Create success status
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
Expand Down
26 changes: 22 additions & 4 deletions commons-test.mk
Original file line number Diff line number Diff line change
@@ -1,16 +1,35 @@
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
GOBIN= $(GOPATH)/bin

define go_install
go install $(1)
endef

$(GOBIN)/golangci-lint:
$(call go_install,github.com/golangci/golangci-lint/cmd/golangci-lint@v1.55.2)

$(GOBIN)/gotestsum:
$(call go_install,gotest.tools/gotestsum@latest)

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

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

.PHONY: dependencies-scan
dependencies-scan:
@echo ">> Scanning dependencies in $(CURDIR)..."
go list -json -m all | docker run --rm -i sonatypecommunity/nancy:latest sleuth --skip-update-check

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

.PHONY: test-%
test-%:
test-%: $(GOBIN)/gotestsum
@echo "Running $* tests..."
gotestsum \
--format short-verbose \
Expand All @@ -26,8 +45,7 @@ tools:
go mod download

.PHONY: test-tools
test-tools:
go install gotest.tools/gotestsum@latest
test-tools: $(GOBIN)/gotestsum

.PHONY: tools-tidy
tools-tidy:
Expand Down
Loading