Skip to content

Commit 6ece744

Browse files
authored
ci: add a validate-tests bake target (#145)
This enables running unit tests in pull requests and after merging to main or tagging a new release. - Add a test target to the Dockerfile - Add this new target to the validate group in bake
1 parent 08a8afe commit 6ece744

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,10 @@ RUN --mount=target=/context \
4747
exit 1
4848
fi
4949
EOT
50+
51+
FROM base AS test
52+
RUN apk add --no-cache make gcc musl-dev
53+
WORKDIR /src
54+
RUN --mount=target=. \
55+
--mount=target=/root/.cache,type=cache \
56+
CGO_ENABLED=1 make unit-tests

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ mock:
6060

6161
unit-tests:
6262
@echo "Running unit tests..."
63-
@go test -v ./...
63+
@go test -race -v ./...
6464
@echo "Unit tests completed!"
6565

6666
clean:

docker-bake.hcl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ group "default" {
1717
}
1818

1919
group "validate" {
20-
targets = ["validate-docs"]
20+
targets = [
21+
"validate-docs",
22+
"validate-tests"
23+
]
2124
}
2225

2326
target "validate-docs" {
@@ -37,3 +40,9 @@ target "update-docs" {
3740
target = "docs-update"
3841
output = ["./docs/reference"]
3942
}
43+
44+
target "validate-tests" {
45+
inherits = ["_common"]
46+
target = "test"
47+
output = ["type=cacheonly"]
48+
}

0 commit comments

Comments
 (0)