ci: simplify code and reduce boiler plate + fixed caching
Signed-off-by: Sam Alba <samalba@users.noreply.github.com>
This commit is contained in:
parent
555966d040
commit
029a0d270f
45
ci/main.cue
45
ci/main.cue
@ -25,7 +25,10 @@ dagger.#Plan & {
|
|||||||
|
|
||||||
directories: {
|
directories: {
|
||||||
// dagger repository
|
// dagger repository
|
||||||
source: path: "../"
|
source: {
|
||||||
|
path: "../"
|
||||||
|
exclude: ["./ci"]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,25 +38,33 @@ dagger.#Plan & {
|
|||||||
}
|
}
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
_goModCache: "go mod cache": {
|
_mountGoCache: {
|
||||||
dest: "/gomodcache"
|
mounts: "go mod cache": {
|
||||||
|
dest: "/root/.gocache"
|
||||||
contents: dagger.#CacheDir & {
|
contents: dagger.#CacheDir & {
|
||||||
id: "go mod cache"
|
id: "go mod cache"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
env: GOMODCACHE: mounts["go mod cache"].dest
|
||||||
|
}
|
||||||
|
|
||||||
_baseImages: #Images
|
_mountSourceCode: {
|
||||||
|
mounts: "dagger source code": {
|
||||||
_sourceCode: "dagger source code": {
|
|
||||||
contents: inputs.directories.source.contents
|
contents: inputs.directories.source.contents
|
||||||
dest: "/usr/src/dagger"
|
dest: "/usr/src/dagger"
|
||||||
}
|
}
|
||||||
|
workdir: mounts["dagger source code"].dest
|
||||||
|
}
|
||||||
|
|
||||||
|
_baseImages: #Images
|
||||||
|
|
||||||
build: bash.#Run & {
|
build: bash.#Run & {
|
||||||
|
_mountSourceCode
|
||||||
|
_mountGoCache
|
||||||
|
|
||||||
input: _baseImages.goBuilder
|
input: _baseImages.goBuilder
|
||||||
|
|
||||||
env: {
|
env: {
|
||||||
GOMODCACHE: mounts["go mod cache"].dest
|
|
||||||
GOOS: strings.ToLower(inputs.params.os)
|
GOOS: strings.ToLower(inputs.params.os)
|
||||||
GOARCH: strings.ToLower(inputs.params.arch)
|
GOARCH: strings.ToLower(inputs.params.arch)
|
||||||
// Makes sure the linter completes before starting the build
|
// Makes sure the linter completes before starting the build
|
||||||
@ -69,27 +80,21 @@ dagger.#Plan & {
|
|||||||
./cmd/dagger/
|
./cmd/dagger/
|
||||||
"""#
|
"""#
|
||||||
|
|
||||||
workdir: mounts["dagger source code"].dest
|
|
||||||
mounts: {
|
|
||||||
_sourceCode
|
|
||||||
_goModCache
|
|
||||||
}
|
|
||||||
|
|
||||||
export: directories: "/build": _
|
export: directories: "/build": _
|
||||||
}
|
}
|
||||||
|
|
||||||
goLint: bash.#Run & {
|
goLint: bash.#Run & {
|
||||||
|
_mountSourceCode
|
||||||
|
_mountGoCache
|
||||||
|
|
||||||
input: _baseImages.goLinter
|
input: _baseImages.goLinter
|
||||||
|
|
||||||
script: contents: "golangci-lint run -v --timeout 5m"
|
script: contents: "golangci-lint run -v --timeout 5m"
|
||||||
workdir: mounts["dagger source code"].dest
|
|
||||||
mounts: {
|
|
||||||
_sourceCode
|
|
||||||
_goModCache
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cueLint: bash.#Run & {
|
cueLint: bash.#Run & {
|
||||||
|
_mountSourceCode
|
||||||
|
|
||||||
input: _baseImages.cue
|
input: _baseImages.cue
|
||||||
|
|
||||||
script: contents: #"""
|
script: contents: #"""
|
||||||
@ -98,10 +103,6 @@ dagger.#Plan & {
|
|||||||
# Check that all formatted files where committed
|
# Check that all formatted files where committed
|
||||||
test -z $(git status -s . | grep -e '^ M' | grep .cue | cut -d ' ' -f3)
|
test -z $(git status -s . | grep -e '^ M' | grep .cue | cut -d ' ' -f3)
|
||||||
"""#
|
"""#
|
||||||
workdir: mounts["dagger source code"].dest
|
|
||||||
mounts: {
|
|
||||||
_sourceCode
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user