Skip to content

Commit 1b95b94

Browse files
authored
Go install gotestsum and golangci-lint (#2127)
* Update commons-test.mk * Update ci-test-go.yml * Update ci-windows.yml * Update commons-test.mk
1 parent 0907f2a commit 1b95b94

File tree

3 files changed

+24
-10
lines changed

3 files changed

+24
-10
lines changed

.github/workflows/ci-test-go.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,7 @@ jobs:
104104
if: ${{ inputs.run-tests }}
105105
working-directory: ./${{ inputs.project-directory }}
106106
timeout-minutes: 30
107-
run: |
108-
go install gotest.tools/gotestsum@latest
109-
make test-unit
107+
run: make test-unit
110108

111109
- name: Upload SonarCloud files
112110
if: ${{ github.ref_name == 'main' && github.repository_owner == 'testcontainers' && inputs.run-tests && !inputs.rootless-docker }}

.github/workflows/ci-windows.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ jobs:
5050

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

5755
- name: Create success status
5856
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1

commons-test.mk

+22-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,35 @@
11
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
2+
GOBIN= $(GOPATH)/bin
3+
4+
define go_install
5+
go install $(1)
6+
endef
7+
8+
$(GOBIN)/golangci-lint:
9+
$(call go_install,github.com/golangci/golangci-lint/cmd/golangci-lint@v1.55.2)
10+
11+
$(GOBIN)/gotestsum:
12+
$(call go_install,gotest.tools/gotestsum@latest)
13+
14+
.PHONY: install
15+
install: $(GOBIN)/golangci-lint $(GOBIN)/gotestsum
16+
17+
.PHONY: clean
18+
clean:
19+
rm $(GOBIN)/golangci-lint
20+
rm $(GOBIN)/gotestsum
221

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

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

1231
.PHONY: test-%
13-
test-%:
32+
test-%: $(GOBIN)/gotestsum
1433
@echo "Running $* tests..."
1534
gotestsum \
1635
--format short-verbose \
@@ -26,8 +45,7 @@ tools:
2645
go mod download
2746

2847
.PHONY: test-tools
29-
test-tools:
30-
go install gotest.tools/gotestsum@latest
48+
test-tools: $(GOBIN)/gotestsum
3149

3250
.PHONY: tools-tidy
3351
tools-tidy:

0 commit comments

Comments
 (0)