Skip to content

Commit

Permalink
Go install gotestsum and golangci-lint (#2127)
Browse files Browse the repository at this point in the history
* Update commons-test.mk

* Update ci-test-go.yml

* Update ci-windows.yml

* Update commons-test.mk
  • Loading branch information
mmorel-35 authored Jan 18, 2024
1 parent 0907f2a commit 1b95b94
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
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/[email protected])

$(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

0 comments on commit 1b95b94

Please sign in to comment.