Skip to content

Commit 4387b51

Browse files
authored
chore(ci): experiment with dagger (#1179)
* chore(ci): experiment with dagger * f * f * f * f * f * f
1 parent 6a7a9fb commit 4387b51

File tree

15 files changed

+363
-6
lines changed

15 files changed

+363
-6
lines changed

.github/workflows/ci.yaml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ jobs:
9898

9999
build-current:
100100
name: Build current
101-
runs-on: ubuntu-latest
101+
runs-on: embedded-cluster
102102
needs:
103103
- git-sha
104104
outputs:
@@ -135,6 +135,11 @@ jobs:
135135
with:
136136
setup-go: false
137137

138+
- name: Install dagger
139+
run: |
140+
curl -fsSL https://dl.dagger.io/dagger/install.sh | sh
141+
sudo mv ./bin/dagger /usr/local/bin/dagger
142+
138143
- name: Build
139144
env:
140145
APP_CHANNEL_ID: 2cHXb1RCttzpR0xvnNWyaZCgDBP
@@ -174,7 +179,7 @@ jobs:
174179
175180
build-previous-k0s:
176181
name: Build previous k0s
177-
runs-on: ubuntu-latest
182+
runs-on: embedded-cluster
178183
needs:
179184
- git-sha
180185
outputs:
@@ -211,6 +216,11 @@ jobs:
211216
with:
212217
setup-go: false
213218

219+
- name: Install dagger
220+
run: |
221+
curl -fsSL https://dl.dagger.io/dagger/install.sh | sh
222+
sudo mv ./bin/dagger /usr/local/bin/dagger
223+
214224
- name: Build
215225
env:
216226
APP_CHANNEL_ID: 2cHXb1RCttzpR0xvnNWyaZCgDBP
@@ -248,7 +258,7 @@ jobs:
248258
249259
build-upgrade:
250260
name: Build upgrade
251-
runs-on: ubuntu-latest
261+
runs-on: embedded-cluster
252262
needs:
253263
- git-sha
254264
outputs:
@@ -285,6 +295,11 @@ jobs:
285295
with:
286296
setup-go: false
287297

298+
- name: Install dagger
299+
run: |
300+
curl -fsSL https://dl.dagger.io/dagger/install.sh | sh
301+
sudo mv ./bin/dagger /usr/local/bin/dagger
302+
288303
- name: Build
289304
env:
290305
APP_CHANNEL_ID: 2cHXb1RCttzpR0xvnNWyaZCgDBP

.github/workflows/image-scan.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ jobs:
3939
- name: Setup melange
4040
uses: ./.github/actions/setup-melange
4141

42+
- name: Install dagger
43+
run: |
44+
curl -fsSL https://dl.dagger.io/dagger/install.sh | sh
45+
sudo mv ./bin/dagger /usr/local/bin/dagger
46+
4247
- name: Build and push local-artifact-mirror image
4348
id: local-artifact-mirror
4449
run: |

.github/workflows/release-prod.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ jobs:
6969
- name: Setup melange
7070
uses: ./.github/actions/setup-melange
7171

72+
- name: Install dagger
73+
run: |
74+
curl -fsSL https://dl.dagger.io/dagger/install.sh | sh
75+
sudo mv ./bin/dagger /usr/local/bin/dagger
76+
7277
- name: Build and push operator image
7378
id: operator-image
7479
env:
@@ -119,6 +124,11 @@ jobs:
119124
- name: Setup melange
120125
uses: ./.github/actions/setup-melange
121126

127+
- name: Install dagger
128+
run: |
129+
curl -fsSL https://dl.dagger.io/dagger/install.sh | sh
130+
sudo mv ./bin/dagger /usr/local/bin/dagger
131+
122132
- name: Build and push local-artifact-mirror image
123133
id: local-artifact-mirror
124134
env:

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Additionally, it includes a Registry when deployed in air gap mode.
2121
- Helm CLI
2222
- AWS CLI
2323
- jq
24+
- Dagger
2425

2526
### Running the Development Environment
2627

dagger.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "embedded-cluster",
3+
"sdk": "go",
4+
"source": "dagger",
5+
"engineVersion": "v0.13.0"
6+
}

dagger/.gitattributes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/dagger.gen.go linguist-generated
2+
/internal/dagger/** linguist-generated
3+
/internal/querybuilder/** linguist-generated
4+
/internal/telemetry/** linguist-generated

dagger/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/dagger.gen.go
2+
/internal/dagger
3+
/internal/querybuilder
4+
/internal/telemetry

dagger/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Development
2+
3+
Install dagger.
4+
5+
```bash
6+
brew install dagger/tap/dagger
7+
```
8+
9+
Run the `dagger develop` command to ensure that the SDK is installed, configured, and all its files re-generated.
10+
11+
```bash
12+
dagger develop
13+
```

dagger/common.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package main
2+
3+
import (
4+
"dagger/embedded-cluster/internal/dagger"
5+
"fmt"
6+
"strings"
7+
)
8+
9+
type common struct {
10+
}
11+
12+
func (m *common) renderTemplate(
13+
src *dagger.Directory,
14+
vars map[string]string,
15+
inFile string,
16+
outFile string,
17+
) *dagger.File {
18+
c := dag.Container().
19+
From("ubuntu:latest").
20+
WithExec([]string{"apt-get", "update"}).
21+
WithExec([]string{"apt-get", "install", "-y", "gettext"}).
22+
WithWorkdir("/workspace").
23+
WithDirectory("/workspace", src)
24+
25+
keys := make([]string, 0, len(vars))
26+
for k, v := range vars {
27+
keys = append(keys, k)
28+
c = c.WithEnvVariable(k, v)
29+
}
30+
31+
c = c.WithExec([]string{
32+
"sh",
33+
"-c",
34+
fmt.Sprintf("envsubst \"$(printf '${%%s} ' %s)\" < %s > %s", strings.Join(keys, " "), inFile, outFile),
35+
})
36+
37+
return c.File(outFile)
38+
}

dagger/go.mod

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
module dagger/embedded-cluster
2+
3+
go 1.23.1
4+
5+
require (
6+
github.com/99designs/gqlgen v0.17.49
7+
github.com/Khan/genqlient v0.7.0
8+
github.com/vektah/gqlparser/v2 v2.5.16
9+
go.opentelemetry.io/otel v1.27.0
10+
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240518090000-14441aefdf88
11+
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.3.0
12+
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.27.0
13+
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.27.0
14+
go.opentelemetry.io/otel/log v0.3.0
15+
go.opentelemetry.io/otel/sdk v1.27.0
16+
go.opentelemetry.io/otel/sdk/log v0.3.0
17+
go.opentelemetry.io/otel/trace v1.27.0
18+
go.opentelemetry.io/proto/otlp v1.3.1
19+
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa
20+
golang.org/x/sync v0.7.0
21+
google.golang.org/grpc v1.64.0
22+
)
23+
24+
require (
25+
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
26+
github.com/go-logr/logr v1.4.1 // indirect
27+
github.com/go-logr/stdr v1.2.2 // indirect
28+
github.com/google/uuid v1.6.0 // indirect
29+
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
30+
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
31+
github.com/sosodev/duration v1.3.1 // indirect
32+
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.27.0 // indirect
33+
go.opentelemetry.io/otel/metric v1.27.0 // indirect
34+
golang.org/x/net v0.26.0 // indirect
35+
golang.org/x/sys v0.21.0 // indirect
36+
golang.org/x/text v0.16.0 // indirect
37+
google.golang.org/genproto/googleapis/api v0.0.0-20240520151616-dc85e6b867a5 // indirect
38+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240515191416-fc5f0ca64291 // indirect
39+
google.golang.org/protobuf v1.34.1 // indirect
40+
)
41+
42+
replace go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc => go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240518090000-14441aefdf88
43+
44+
replace go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp => go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.3.0
45+
46+
replace go.opentelemetry.io/otel/log => go.opentelemetry.io/otel/log v0.3.0
47+
48+
replace go.opentelemetry.io/otel/sdk/log => go.opentelemetry.io/otel/sdk/log v0.3.0

0 commit comments

Comments
 (0)