-
Notifications
You must be signed in to change notification settings - Fork 1
/
project.cue
188 lines (164 loc) · 3.45 KB
/
project.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
// project cuefile for Dagger CI and other development tooling related to this project.
package main
import "dagger.io/dagger"
import "universe.dagger.io/bash"
import "universe.dagger.io/docker"
// Convenience cuelang build for formatting, etc.
#CueBuild: {
// client filesystem
filesystem: dagger.#FS
// output from the build
output: _cue_build.output
// cuelang pre-build
_cue_pre_build: docker.#Build & {
steps: [
docker.#Pull & {
source: "golang:latest"
},
docker.#Run & {
command: {
name: "mkdir"
args: ["/workdir"]
}
},
docker.#Run & {
command: {
name: "go"
args: ["install", "cuelang.org/go/cmd/cue@latest"]
}
},
]
}
// cue build for actions in this plan
_cue_build: docker.#Build & {
steps: [
docker.#Copy & {
input: _cue_pre_build.output
contents: filesystem
source: "./project.cue"
dest: "/workdir/project.cue"
},
]
}
}
#TFLintBuild: {
// client filesystem
filesystem: dagger.#FS
// output from the build
output: _tf_build.output
// tf build
_tf_pre_build: docker.#Build & {
steps: [
docker.#Pull & {
source: "ghcr.io/antonbabenko/pre-commit-terraform:v1.89.0"
},
docker.#Set & {
config: {
workdir: "/lint"
}
},
// git init for pre-commit caching
bash.#Run & {
script: contents: """
git init
"""
},
docker.#Copy & {
contents: filesystem
source: "./.pre-commit-config.yaml"
dest: "/lint/.pre-commit-config.yaml"
},
docker.#Run & {
command: {
name: "install-hooks"
}
},
]
}
// cue build for actions in this plan
_tf_build: docker.#Build & {
steps: [
docker.#Copy & {
input: _tf_pre_build.output
contents: filesystem
source: "./"
dest: "/lint"
exclude: ["./.pre-commit-config.yaml"]
},
]
}
}
// Convenience terraform build for implementation
#TerraformBuild: {
// client filesystem
filesystem: dagger.#FS
// output from the build
output: _tf_build.output
// tf build
_tf_build: docker.#Build & {
steps: [
docker.#Pull & {
source: "hashicorp/terraform:1.4.6"
},
docker.#Run & {
command: {
name: "mkdir"
args: ["/workdir"]
}
},
docker.#Copy & {
contents: filesystem
source: "./"
dest: "/workdir/"
},
]
}
}
dagger.#Plan & {
client: {
filesystem: {
"./": read: contents: dagger.#FS
"./project.cue": write: contents: actions.format.cue.export.files."/workdir/project.cue"
}
}
actions: {
// an internal cue build for formatting/cleanliness
_cue_build: #CueBuild & {
filesystem: client.filesystem."./".read.contents
}
// an internal terraform build for use with this repo
_tf_build: #TerraformBuild & {
filesystem: client.filesystem."./".read.contents
}
// an internal terraform build for use with this repo
_tf_lint_build: #TFLintBuild & {
filesystem: client.filesystem."./".read.contents
}
// applied code and/or file formatting
format: {
// code formatting for cuelang
cue: docker.#Run & {
input: _cue_build.output
workdir: "/workdir"
command: {
name: "cue"
args: ["fmt", "/workdir/project.cue"]
}
export: {
files: "/workdir/project.cue": _
}
}
}
// various tests for this repo
test: {
// run pre-commit checks
test_pre_commit: docker.#Run & {
input: _tf_lint_build.output
command: {
name: "run"
args: ["--all-files"]
}
}
}
}
}