forked from dagger/dagger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ci.cue
189 lines (168 loc) · 5.04 KB
/
ci.cue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
package main
import (
"dagger.io/dagger"
"dagger.io/dagger/core"
"universe.dagger.io/go"
"github.com/dagger/dagger/ci/golangci"
"github.com/dagger/dagger/ci/shellcheck"
"github.com/dagger/dagger/ci/markdownlint"
"github.com/dagger/dagger/ci/cue"
"github.com/dagger/dagger/ci/bats"
"github.com/dagger/dagger/ci/gitpod"
)
dagger.#Plan & {
client: filesystem: ".": read: exclude: [
"bin",
"**/node_modules",
"cmd/dagger/dagger",
"cmd/dagger/dagger-debug",
"website",
]
client: filesystem: "./bin": write: contents: actions.build."go".output
client: network: "unix:///var/run/docker.sock": connect: dagger.#Socket
client: env: {
DAGGER_LOG_FORMAT: string | *"auto"
OTEL_EXPORTER_JAEGER_ENDPOINT: string | *""
JAEGER_TRACE: string | *""
BUILDKIT_HOST: string | *""
DAGGER_CACHE_FROM: string | *""
DAGGER_CACHE_TO: string | *""
GITHUB_ACTIONS: string | *""
ACTIONS_RUNTIME_TOKEN: string | *""
ACTIONS_CACHE_URL: string | *""
TESTDIR: string | *"."
}
actions: {
_source: client.filesystem["."].read.contents
build: {
"go": go.#Build & {
source: _source
package: "./cmd/dagger/"
os: *client.platform.os | "linux"
arch: client.platform.arch
ldflags: "-s -w"
env: {
CGO_ENABLED: "0"
// Makes sure the linter and unit tests complete before starting the build
// "__depends_lint": "\(goLint.exit)"
// "__depends_tests": "\(goTest.exit)"
}
}
docker: core.#Dockerfile & {
source: _source
dockerfile: path: "Dockerfile"
}
}
test: {
// Go unit tests
unit: go.#Test & {
source: _source
package: "./..."
command: flags: "-race": true
env: DAGGER_LOG_FORMAT: client.env.DAGGER_LOG_FORMAT
}
#BatsIntegrationTest: {
// Directory containing the basts files
path: string
// dagger binary
daggerBinary: _
_testDir: core.#Subdir & {
input: _source
"path": path
}
_mergeFS: core.#Merge & {
inputs: [
// directory containing integration tests
_testDir.output,
// dagger binary
daggerBinary.output,
]
}
bats.#Bats & {
env: {
DAGGER_BINARY: "/src/dagger"
DAGGER_LOG_FORMAT: client.env.DAGGER_LOG_FORMAT
BUILDKIT_HOST: client.env.BUILDKIT_HOST
OTEL_EXPORTER_JAEGER_ENDPOINT: client.env.OTEL_EXPORTER_JAEGER_ENDPOINT
JAEGER_TRACE: client.env.JAEGER_TRACE
DAGGER_CACHE_FROM: client.env.DAGGER_CACHE_FROM
DAGGER_CACHE_TO: client.env.DAGGER_CACHE_TO
GITHUB_ACTIONS: client.env.GITHUB_ACTIONS
ACTIONS_RUNTIME_TOKEN: client.env.ACTIONS_RUNTIME_TOKEN
ACTIONS_CACHE_URL: client.env.ACTIONS_CACHE_URL
}
source: _mergeFS.output
initScript: #"""
set -exu
[ -d cue.mod/pkg/ ] && {
# Remove the symlinked pkgs
rm -rf cue.mod/pkg/*
$DAGGER_BINARY project update
}
# Install sops
# FIXME: should be in its own package
curl -o /usr/bin/jq -sL \
https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 \
&& chmod +x /usr/bin/jq
curl -o /usr/bin/sops -sL \
https://github.com/mozilla/sops/releases/download/v3.7.2/sops-v3.7.2.linux \
&& chmod +x /usr/bin/sops
"""#
mounts: docker: {
dest: "/var/run/docker.sock"
contents: client.network."unix:///var/run/docker.sock".connect
}
}
}
integration: {
core: #BatsIntegrationTest & {
path: "tests"
daggerBinary: go.#Build & {
source: _source
package: "./cmd/dagger/"
arch: client.platform.arch
container: command: flags: "-race": true
}
}
// FIXME: docs integration tests were never ported after the Europa release (gh issue #2592)
// doc: #BatsIntegrationTest & {
// path: "docs/learn/tests"
// daggerBinary: build.go & {os: "linux"}
// }
universe: #BatsIntegrationTest & {
path: "pkg"
daggerBinary: build.go & {os: "linux"}
testDir: "universe.dagger.io"
env: TESTDIR: client.env.TESTDIR
extraArgs: "$(find ${TESTDIR:-.} -type f -name '*.bats' -not -path '*/node_modules/*' -not -path '*/cue.mod/*' -not -path '*/x/*')"
}
experimental: #BatsIntegrationTest & {
path: "pkg"
daggerBinary: build.go & {os: "linux"}
testDir: "universe.dagger.io/x"
env: TESTDIR: client.env.TESTDIR
extraArgs: "$(find ${TESTDIR:-.} -type f -name '*.bats' -not -path '*/node_modules/*' -not -path '*/cue.mod/*')"
}
}
}
lint: {
go: golangci.#Lint & {
source: _source
version: "1.45"
}
shell: shellcheck.#Lint & {
source: _source
}
markdown: markdownlint.#Lint & {
source: _source
files: ["./docs", "README.md"]
}
"cue": cue.#Lint & {
source: _source
}
}
"gitpod": gitpod.#Test & {
source: _source
}
}
}