Skip to content
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: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ jobs:
key: ${{ runner.os }}-go-${{ matrix.go }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ matrix.go }}-
- name: Tidy for min version
- name: Tidy
run: make mod-tidy
if: ${{ matrix.go == '1.24' }}
if: ${{ matrix.go == '1.26' }}
- name: Build
run: make build
- name: Vet
Expand Down
44 changes: 37 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,16 @@ help: ## Show help
.PHONY: help

build: ## Build everything
set -e ; \
for dir in $(ALL_GO_MOD_DIRS); do \
cd "$${dir}"; \
MOD_GO=$$(sed -n 's/^go \([0-9]*\.[0-9]*\).*/\1/p' "$${dir}/go.mod"); \
CURRENT=$$($(GO) env GOVERSION | sed 's/^go//' | cut -d. -f1,2); \
if [ "$$(printf '%s\n%s' "$${MOD_GO}" "$${CURRENT}" | sort -V | head -n1)" != "$${MOD_GO}" ]; then \
echo ">>> Skipping $${dir} (requires Go $${MOD_GO}, have $${CURRENT})"; \
continue; \
fi; \
echo ">>> Running 'go build' for module: $${dir}"; \
go build ./...; \
(cd "$${dir}" && go build ./...); \
done;
.PHONY: build

Expand All @@ -28,9 +34,14 @@ $(TEST_TARGETS): test
test: $(ALL_GO_MOD_DIRS:%=test/%) ## Run tests
test/%: DIR=$*
test/%:
@echo ">>> Running tests for module: $(DIR)"
@# We use '-count=1' to disable test caching.
(cd $(DIR) && $(GO) test -count=1 -timeout $(TIMEOUT)s $(ARGS) ./...)
@MOD_GO=$$(sed -n 's/^go \([0-9]*\.[0-9]*\).*/\1/p' "$(DIR)/go.mod"); \
CURRENT=$$($(GO) env GOVERSION | sed 's/^go//' | cut -d. -f1,2); \
if [ "$$(printf '%s\n%s' "$$MOD_GO" "$$CURRENT" | sort -V | head -n1)" != "$$MOD_GO" ]; then \
echo ">>> Skipping tests for $(DIR) (requires Go $$MOD_GO, have $$CURRENT)"; \
else \
echo ">>> Running tests for module: $(DIR)"; \
(cd $(DIR) && $(GO) test -count=1 -timeout $(TIMEOUT)s $(ARGS) ./...); \
fi
.PHONY: $(TEST_TARGETS) test

# Coverage
Expand All @@ -45,6 +56,12 @@ clean-report-dir: $(COVERAGE_REPORT_DIR)
test-coverage: $(COVERAGE_REPORT_DIR) clean-report-dir ## Test with coverage enabled
set -e ; \
for dir in $(ALL_GO_MOD_DIRS); do \
MOD_GO=$$(sed -n 's/^go \([0-9]*\.[0-9]*\).*/\1/p' "$${dir}/go.mod"); \
CURRENT=$$($(GO) env GOVERSION | sed 's/^go//' | cut -d. -f1,2); \
if [ "$$(printf '%s\n%s' "$${MOD_GO}" "$${CURRENT}" | sort -V | head -n1)" != "$${MOD_GO}" ]; then \
echo ">>> Skipping $${dir} (requires Go $${MOD_GO}, have $${CURRENT})"; \
continue; \
fi; \
echo ">>> Running tests with coverage for module: $${dir}"; \
DIR_ABS=$$(python -c 'import os, sys; print(os.path.realpath(sys.argv[1]))' $${dir}) ; \
REPORT_NAME=$$(basename $${DIR_ABS}); \
Expand All @@ -57,6 +74,12 @@ test-coverage: $(COVERAGE_REPORT_DIR) clean-report-dir ## Test with coverage en
test-race-coverage: $(COVERAGE_REPORT_DIR) clean-report-dir ## Run tests with race detection and coverage
set -e ; \
for dir in $(ALL_GO_MOD_DIRS); do \
MOD_GO=$$(sed -n 's/^go \([0-9]*\.[0-9]*\).*/\1/p' "$${dir}/go.mod"); \
CURRENT=$$($(GO) env GOVERSION | sed 's/^go//' | cut -d. -f1,2); \
if [ "$$(printf '%s\n%s' "$${MOD_GO}" "$${CURRENT}" | sort -V | head -n1)" != "$${MOD_GO}" ]; then \
echo ">>> Skipping $${dir} (requires Go $${MOD_GO}, have $${CURRENT})"; \
continue; \
fi; \
echo ">>> Running tests with race detection and coverage for module: $${dir}"; \
DIR_ABS=$$(python -c 'import os, sys; print(os.path.realpath(sys.argv[1]))' $${dir}) ; \
REPORT_NAME=$$(basename $${DIR_ABS}); \
Expand All @@ -69,15 +92,22 @@ test-race-coverage: $(COVERAGE_REPORT_DIR) clean-report-dir ## Run tests with r
mod-tidy: ## Check go.mod tidiness
set -e ; \
for dir in $(ALL_GO_MOD_DIRS); do \
echo ">>> Running 'go mod tidy' for module: $${dir}"; \
(cd "$${dir}" && GOTOOLCHAIN=local go mod tidy -go=1.24.0 -compat=1.24.0); \
MOD_GO=$$(sed -n 's/^go \([0-9.]*\)/\1/p' "$${dir}/go.mod"); \
echo ">>> Running 'go mod tidy' for module: $${dir} (go $${MOD_GO})"; \
(cd "$${dir}" && GOTOOLCHAIN=local go mod tidy -go=$${MOD_GO} -compat=$${MOD_GO}); \
done; \
git diff --exit-code;
.PHONY: mod-tidy

vet: ## Run "go vet"
set -e ; \
for dir in $(ALL_GO_MOD_DIRS); do \
MOD_GO=$$(sed -n 's/^go \([0-9]*\.[0-9]*\).*/\1/p' "$${dir}/go.mod"); \
CURRENT=$$($(GO) env GOVERSION | sed 's/^go//' | cut -d. -f1,2); \
if [ "$$(printf '%s\n%s' "$${MOD_GO}" "$${CURRENT}" | sort -V | head -n1)" != "$${MOD_GO}" ]; then \
echo ">>> Skipping $${dir} (requires Go $${MOD_GO}, have $${CURRENT})"; \
continue; \
fi; \
echo ">>> Running 'go vet' for module: $${dir}"; \
(cd "$${dir}" && go vet ./...); \
done;
Expand Down
Loading