2022-02-10 05:48:22 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2022-02-24 00:15:44 +01:00
|
|
|
"dagger.io/dagger"
|
2022-04-01 04:21:54 +02:00
|
|
|
|
2022-02-10 05:48:22 +01:00
|
|
|
"universe.dagger.io/bash"
|
2022-04-01 04:21:54 +02:00
|
|
|
"universe.dagger.io/alpine"
|
|
|
|
"universe.dagger.io/go"
|
2022-04-01 20:33:18 +02:00
|
|
|
|
2022-04-05 02:40:16 +02:00
|
|
|
"github.com/dagger/dagger/ci/golangci"
|
|
|
|
"github.com/dagger/dagger/ci/shellcheck"
|
|
|
|
"github.com/dagger/dagger/ci/markdownlint"
|
2022-04-05 03:21:16 +02:00
|
|
|
"github.com/dagger/dagger/ci/cue"
|
2022-02-10 05:48:22 +01:00
|
|
|
)
|
|
|
|
|
2022-02-24 00:15:44 +01:00
|
|
|
dagger.#Plan & {
|
2022-02-18 05:39:40 +01:00
|
|
|
// FIXME: Ideally we would want to automatically set the platform's arch identical to the host
|
|
|
|
// to avoid the performance hit caused by qemu (linter goes from <3s to >3m when arch is x86)
|
2022-03-10 01:31:14 +01:00
|
|
|
// Uncomment if running locally on Mac M1 to bypass qemu
|
|
|
|
// platform: "linux/aarch64"
|
2022-04-05 21:10:54 +02:00
|
|
|
// platform: "linux/amd64"
|
2022-02-18 05:39:40 +01:00
|
|
|
|
2022-04-05 02:40:16 +02:00
|
|
|
client: filesystem: ".": read: exclude: [
|
|
|
|
"bin",
|
2022-04-01 04:21:54 +02:00
|
|
|
"**/node_modules",
|
|
|
|
"cmd/dagger/dagger",
|
|
|
|
"cmd/dagger/dagger-debug",
|
|
|
|
]
|
2022-04-05 02:40:16 +02:00
|
|
|
client: filesystem: "./bin": write: contents: actions.build.output
|
2022-02-10 05:48:22 +01:00
|
|
|
|
|
|
|
actions: {
|
2022-04-05 02:40:16 +02:00
|
|
|
_source: client.filesystem["."].read.contents
|
2022-04-01 04:21:54 +02:00
|
|
|
|
|
|
|
// FIXME: this can be removed once `go` supports built-in VCS info
|
|
|
|
version: {
|
|
|
|
_image: alpine.#Build & {
|
|
|
|
packages: bash: _
|
|
|
|
packages: curl: _
|
|
|
|
packages: git: _
|
2022-02-18 05:39:40 +01:00
|
|
|
}
|
2022-02-10 05:48:22 +01:00
|
|
|
|
2022-04-01 04:21:54 +02:00
|
|
|
_revision: bash.#Run & {
|
|
|
|
input: _image.output
|
|
|
|
workdir: "/src"
|
|
|
|
mounts: source: {
|
|
|
|
dest: "/src"
|
|
|
|
contents: _source
|
|
|
|
}
|
|
|
|
|
|
|
|
script: contents: #"""
|
|
|
|
printf "$(git rev-parse --short HEAD)" > /revision
|
|
|
|
"""#
|
|
|
|
export: files: "/revision": string
|
2022-03-01 02:46:29 +01:00
|
|
|
}
|
2022-02-11 02:18:57 +01:00
|
|
|
|
2022-04-01 04:21:54 +02:00
|
|
|
output: _revision.export.files["/revision"]
|
|
|
|
}
|
2022-03-01 02:46:29 +01:00
|
|
|
|
2022-04-01 04:21:54 +02:00
|
|
|
build: go.#Build & {
|
|
|
|
source: _source
|
|
|
|
package: "./cmd/dagger/"
|
|
|
|
os: client.platform.os
|
|
|
|
arch: client.platform.arch
|
2022-03-01 02:46:29 +01:00
|
|
|
|
2022-04-01 04:21:54 +02:00
|
|
|
ldflags: "-s -w -X go.dagger.io/dagger/version.Revision=\(version.output)"
|
2022-02-10 05:48:22 +01:00
|
|
|
|
2022-02-11 01:09:08 +01:00
|
|
|
env: {
|
2022-03-01 23:48:50 +01:00
|
|
|
CGO_ENABLED: "0"
|
|
|
|
// Makes sure the linter and unit tests complete before starting the build
|
2022-04-01 04:21:54 +02:00
|
|
|
// "__depends_lint": "\(goLint.exit)"
|
|
|
|
// "__depends_tests": "\(goTest.exit)"
|
2022-02-11 01:09:08 +01:00
|
|
|
}
|
2022-02-10 05:48:22 +01:00
|
|
|
}
|
2022-02-11 02:18:57 +01:00
|
|
|
|
2022-03-01 23:48:50 +01:00
|
|
|
// Go unit tests
|
2022-04-01 04:21:54 +02:00
|
|
|
test: go.#Test & {
|
|
|
|
// container: image: _goImage.output
|
|
|
|
source: _source
|
|
|
|
package: "./..."
|
2022-03-01 23:48:50 +01:00
|
|
|
|
2022-04-01 04:21:54 +02:00
|
|
|
// FIXME: doesn't work with CGO_ENABLED=0
|
|
|
|
// command: flags: "-race": true
|
2022-03-01 02:46:29 +01:00
|
|
|
|
2022-04-01 04:21:54 +02:00
|
|
|
env: {
|
|
|
|
// FIXME: removing this complains about lack of gcc
|
|
|
|
CGO_ENABLED: "0"
|
|
|
|
}
|
2022-02-11 02:18:57 +01:00
|
|
|
}
|
2022-02-24 00:15:44 +01:00
|
|
|
|
2022-04-01 04:21:54 +02:00
|
|
|
lint: {
|
|
|
|
go: golangci.#Lint & {
|
|
|
|
source: _source
|
|
|
|
version: "1.45"
|
|
|
|
}
|
|
|
|
|
2022-04-01 20:33:18 +02:00
|
|
|
shell: shellcheck.#Lint & {
|
|
|
|
source: _source
|
|
|
|
}
|
|
|
|
|
2022-04-01 21:07:55 +02:00
|
|
|
markdown: markdownlint.#Lint & {
|
|
|
|
source: _source
|
|
|
|
files: ["./docs", "README.md"]
|
|
|
|
}
|
|
|
|
|
2022-04-05 03:21:16 +02:00
|
|
|
"cue": cue.#Lint & {
|
|
|
|
source: _source
|
2022-04-01 04:21:54 +02:00
|
|
|
}
|
2022-02-24 00:15:44 +01:00
|
|
|
}
|
2022-02-10 05:48:22 +01:00
|
|
|
}
|
|
|
|
}
|