ci: cleaner pattern for sharing base images across actions

Signed-off-by: Sam Alba <samalba@users.noreply.github.com>
This commit is contained in:
Sam Alba 2022-02-17 11:58:31 -08:00
parent f17c470feb
commit 8e2f3eb21d
2 changed files with 11 additions and 7 deletions

View File

@ -8,10 +8,11 @@ let GoVersion = "1.17"
let GolangCILintVersion = "1.44.0"
// Base container images used for the CI
images: {
#Images: {
// base image to build go binaries
goBuilder: docker.#Build & {
goBuilder: _goBuilder.output
_goBuilder: docker.#Build & {
_packages: ["bash", "git"]
steps: [
@ -35,7 +36,8 @@ images: {
// base image for the Go linter
// https://golangci-lint.run/usage/install/#docker
goLinter: docker.#Build & {
goLinter: _goLinter.output
_goLinter: docker.#Build & {
steps: [
docker.#Pull & {
source: "index.docker.io/golangci/golangci-lint:v\(GolangCILintVersion)"

View File

@ -24,8 +24,8 @@ engine.#Plan & {
}
outputs: directories: "go binaries": {
contents: actions.build.export.directories["/build"].contents
dest: "./build"
contents: actions.build.export.directories["/build"].contents
dest: "./build"
}
actions: {
@ -33,6 +33,8 @@ engine.#Plan & {
id: "go mod cache"
}
baseImages: #Images
source: "dagger source code": {
contents: inputs.directories.source.contents
dest: "/usr/src/dagger"
@ -40,7 +42,7 @@ engine.#Plan & {
// FIXME: build only if the linter passed
build: bash.#Run & {
input: images.goBuilder.output
input: baseImages.goBuilder
env: {
GOMODCACHE: mounts["go mod cache"].dest
@ -71,7 +73,7 @@ engine.#Plan & {
}
goLint: bash.#Run & {
input: images.goLinter.output
input: baseImages.goLinter
// FIXME: the source volume is too slow, taking >3m on docker for mac (vs < 2sec on the host machine)
script: contents: "golangci-lint run -v --timeout 5m"