| 1 |
variable "GO_VERSION" { |
| 2 |
default = null |
| 3 |
} |
| 4 |
|
| 5 |
variable "DESTDIR" { |
| 6 |
default = "./bin" |
| 7 |
} |
| 8 |
|
| 9 |
target "_platforms" { |
| 10 |
platforms = [ |
| 11 |
"darwin/amd64", |
| 12 |
"darwin/arm64", |
| 13 |
"freebsd/amd64", |
| 14 |
"freebsd/arm64", |
| 15 |
"linux/386", |
| 16 |
"linux/amd64", |
| 17 |
"linux/arm", |
| 18 |
"linux/arm64", |
| 19 |
"linux/ppc64le", |
| 20 |
"linux/s390x", |
| 21 |
"netbsd/amd64", |
| 22 |
"netbsd/arm64", |
| 23 |
"openbsd/amd64", |
| 24 |
"openbsd/arm64", |
| 25 |
"windows/amd64", |
| 26 |
"windows/arm64" |
| 27 |
] |
| 28 |
} |
| 29 |
|
| 30 |
target "_common" { |
| 31 |
args = { |
| 32 |
BUILDKIT_CONTEXT_KEEP_GIT_DIR = 1 |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
group "default" { |
| 37 |
targets = ["build"] |
| 38 |
} |
| 39 |
|
| 40 |
target "build" { |
| 41 |
inherits = ["_common"] |
| 42 |
args = { |
| 43 |
GO_VERSION = "${GO_VERSION}" |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
group "test" { |
| 48 |
targets = ["test-root", "test-noroot"] |
| 49 |
} |
| 50 |
|
| 51 |
target "test-root" { |
| 52 |
inherits = ["build"] |
| 53 |
target = "test-coverage" |
| 54 |
output = ["${DESTDIR}/coverage"] |
| 55 |
} |
| 56 |
|
| 57 |
target "test-noroot" { |
| 58 |
inherits = ["build"] |
| 59 |
target = "test-noroot-coverage" |
| 60 |
output = ["${DESTDIR}/coverage"] |
| 61 |
} |
| 62 |
|
| 63 |
group "lint" { |
| 64 |
targets = ["lint-golangci", "lint-gopls"] |
| 65 |
} |
| 66 |
|
| 67 |
group "lint-cross" { |
| 68 |
targets = ["lint-golangci-cross", "lint-gopls-cross"] |
| 69 |
} |
| 70 |
|
| 71 |
target "lint-golangci" { |
| 72 |
inherits = ["_common"] |
| 73 |
dockerfile = "./hack/dockerfiles/lint.Dockerfile" |
| 74 |
output = ["type=cacheonly"] |
| 75 |
args = { |
| 76 |
GO_VERSION = "${GO_VERSION}" |
| 77 |
} |
| 78 |
} |
| 79 |
|
| 80 |
target "lint-gopls" { |
| 81 |
inherits = ["lint-golangci"] |
| 82 |
target = "gopls-analyze" |
| 83 |
} |
| 84 |
|
| 85 |
target "lint-golangci-cross" { |
| 86 |
inherits = ["lint-golangci", "_platforms"] |
| 87 |
} |
| 88 |
|
| 89 |
target "lint-gopls-cross" { |
| 90 |
inherits = ["lint-gopls", "_platforms"] |
| 91 |
} |
| 92 |
|
| 93 |
target "validate-generated-files" { |
| 94 |
inherits = ["_common"] |
| 95 |
dockerfile = "./hack/dockerfiles/generated-files.Dockerfile" |
| 96 |
output = ["type=cacheonly"] |
| 97 |
target = "validate" |
| 98 |
args = { |
| 99 |
GO_VERSION = "${GO_VERSION}" |
| 100 |
} |
| 101 |
} |
| 102 |
|
| 103 |
target "generated-files" { |
| 104 |
inherits = ["validate-generated-files"] |
| 105 |
output = ["."] |
| 106 |
target = "update" |
| 107 |
} |
| 108 |
|
| 109 |
target "validate-gomod" { |
| 110 |
inherits = ["_common"] |
| 111 |
dockerfile = "./hack/dockerfiles/gomod.Dockerfile" |
| 112 |
output = ["type=cacheonly"] |
| 113 |
target = "validate" |
| 114 |
args = { |
| 115 |
# go mod may produce different results between go versions, |
| 116 |
# if this becomes a problem, this should be switched to use |
| 117 |
# a fixed go version. |
| 118 |
GO_VERSION = "${GO_VERSION}" |
| 119 |
} |
| 120 |
} |
| 121 |
|
| 122 |
target "gomod" { |
| 123 |
inherits = ["validate-gomod"] |
| 124 |
output = ["."] |
| 125 |
target = "update" |
| 126 |
} |
| 127 |
|
| 128 |
target "validate-shfmt" { |
| 129 |
inherits = ["_common"] |
| 130 |
dockerfile = "./hack/dockerfiles/shfmt.Dockerfile" |
| 131 |
output = ["type=cacheonly"] |
| 132 |
target = "validate" |
| 133 |
} |
| 134 |
|
| 135 |
target "shfmt" { |
| 136 |
inherits = ["validate-shfmt"] |
| 137 |
output = ["."] |
| 138 |
target = "update" |
| 139 |
} |
| 140 |
|
| 141 |
target "cross" { |
| 142 |
inherits = ["build", "_platforms"] |
| 143 |
} |