File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,18 @@ FROM gobase AS base
30
30
ARG TARGETPLATFORM
31
31
RUN xx-apk add musl-dev gcc libsecret-dev pass
32
32
33
+ FROM base AS test
34
+ RUN --mount=type=bind,target=. \
35
+ --mount=type=cache,target=/root/.cache \
36
+ --mount=type=cache,target=/go/pkg/mod <<EOT
37
+ set -e
38
+ xx-go test -short -v -coverprofile=/tmp/coverage.txt -covermode=atomic ./...
39
+ xx-go tool cover -func=/tmp/coverage.txt
40
+ EOT
41
+
42
+ FROM scratch AS test-coverage
43
+ COPY --from=test /tmp/coverage.txt /coverage.txt
44
+
33
45
FROM base AS build-linux
34
46
ARG TARGETOS
35
47
ARG TARGETARCH
Original file line number Diff line number Diff line change 1
1
variable "GO_VERSION" {
2
2
default = " 1.16.7"
3
3
}
4
+
5
+ # Defines the output folder
4
6
variable "DESTDIR" {
5
- default = " ./bin"
7
+ default = " "
8
+ }
9
+ function "bindir" {
10
+ params = [defaultdir ]
11
+ result = DESTDIR != " " ? DESTDIR : " ./bin/${ defaultdir } "
6
12
}
7
13
8
14
target "_common" {
@@ -15,10 +21,16 @@ group "default" {
15
21
targets = [" binaries" ]
16
22
}
17
23
24
+ target "test" {
25
+ inherits = [" _common" ]
26
+ target = " test-coverage"
27
+ output = [bindir (" coverage" )]
28
+ }
29
+
18
30
target "binaries" {
19
31
inherits = [" _common" ]
20
32
target = " binaries"
21
- output = [DESTDIR ]
33
+ output = [bindir ( " build " ) ]
22
34
platforms = [
23
35
" darwin/amd64" ,
24
36
" darwin/arm64" ,
You can’t perform that action at this time.
0 commit comments