Skip to content

Commit c3390eb

Browse files
authored
Merge branch 'main' into renovate/docker-digest
Signed-off-by: Francesco Canovai <[email protected]>
2 parents f75511c + 294942b commit c3390eb

File tree

13 files changed

+366
-317
lines changed

13 files changed

+366
-317
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ jobs:
3232
with:
3333
fetch-depth: 0
3434
ref: ${{ github.event.pull_request.head.sha }}
35-
# TODO: remove this when we daggerize the e2e
36-
- name: Setup Go
37-
uses: actions/setup-go@v5
38-
with:
39-
go-version: '1.23.x'
4035
- name: Install Task
4136
uses: arduino/setup-task@v2
4237
- name: Install Dagger

Taskfile.yml

Lines changed: 93 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
version: 3
22

3-
# Environment variables that are shared across tasks.
4-
env:
3+
# We have multiple parallel tasks that run for a long time. Prefix their output with the task name so we can understand
4+
# what task is writing.
5+
output: prefixed
6+
7+
# Variables that are shared across tasks.
8+
vars:
9+
# renovate: datasource=docker depName=kindest/node versioning=semver
10+
E2E_KUBERNETES_VERSION: v1.32.0
11+
E2E_CLUSTER_NAME: barman-cloud-plugin-e2e-{{.E2E_KUBERNETES_VERSION}}
512
REGISTRY_NETWORK: barman-cloud-plugin
613
REGISTRY_NAME: registry.barman-cloud-plugin
714
REGISTRY_PORT: 5000
@@ -89,8 +96,8 @@ tasks:
8996
openssl req -new -x509 -days 365 -key ca-key.pem -sha256 -out ca.pem \
9097
-subj "/O=CloudNativePG/OU=Barman Cloud Plugin Testing" &&
9198
openssl genrsa -out server-key.pem 4096 &&
92-
openssl req -subj "/CN=${REGISTRY_NAME}" -sha256 -new -key server-key.pem -out server.csr &&
93-
echo subjectAltName = DNS:${REGISTRY_NAME},IP:127.0.0.1 >> extfile.cnf &&
99+
openssl req -subj "/CN={{ .REGISTRY_NAME }}" -sha256 -new -key server-key.pem -out server.csr &&
100+
echo subjectAltName = DNS:{{ .REGISTRY_NAME }},IP:127.0.0.1 >> extfile.cnf &&
94101
echo extendedKeyUsage = serverAuth >> extfile.cnf &&
95102
openssl x509 -req -days 365 -sha256 -in server.csr -CA ca.pem -CAkey ca-key.pem \
96103
-CAcreateserial -out server-cert.pem -extfile extfile.cnf &&
@@ -106,9 +113,9 @@ tasks:
106113
desc: Create a docker network for image building used by the dagger engine and the registry
107114
run: once
108115
cmds:
109-
- docker network create ${REGISTRY_NETWORK}
116+
- docker network create {{ .REGISTRY_NETWORK}}
110117
status:
111-
- docker network inspect ${REGISTRY_NETWORK}
118+
- docker network inspect {{ .REGISTRY_NETWORK }}
112119

113120
start-registry:
114121
desc: Start a container registry
@@ -121,14 +128,14 @@ tasks:
121128
REGISTRY_VERSION: 2
122129
cmds:
123130
- >
124-
docker run -d --name ${REGISTRY_NAME}
125-
-p ${REGISTRY_PORT}:5000
126-
--network ${REGISTRY_NETWORK}
131+
docker run -d --name {{ .REGISTRY_NAME }}
132+
-p {{ .REGISTRY_PORT }}:5000
133+
--network {{ .REGISTRY_NETWORK }}
127134
-v $(pwd)/certs:/certs
128135
-e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/server-cert.pem -e REGISTRY_HTTP_TLS_KEY=/certs/server-key.pem
129136
registry:${REGISTRY_VERSION}
130137
status:
131-
- \[ "$(docker inspect -f {{`'{{.State.Running}}'`}} "${REGISTRY_NAME}" 2> /dev/null )" == 'true' \]
138+
- \[ "$(docker inspect -f {{`'{{.State.Running}}'`}} "{{ .REGISTRY_NAME }}" 2> /dev/null )" == 'true' \]
132139

133140

134141
# Start a dagger engine that mounts the CA certificate for the local registry.
@@ -144,12 +151,12 @@ tasks:
144151
DAGGER_ENGINE_IMAGE: registry.dagger.io/engine:v{{ .DAGGER_VERSION }}
145152
cmds:
146153
- >
147-
docker run -d -v /var/lib/dagger --name "${DAGGER_ENGINE_CONTAINER_NAME}"
148-
--network=${REGISTRY_NETWORK}
154+
docker run -d -v /var/lib/dagger --name "{{ .DAGGER_ENGINE_CONTAINER_NAME }}"
155+
--network={{ .REGISTRY_NETWORK }}
149156
-v $(pwd)/certs/ca.pem:/usr/local/share/ca-certificates/ca.crt
150157
--privileged {{ .DAGGER_ENGINE_IMAGE }}
151158
status:
152-
- \[ "$(docker inspect -f {{`'{{.State.Running}}'`}} "${DAGGER_ENGINE_CONTAINER_NAME}" 2> /dev/null )" == 'true' \]
159+
- \[ "$(docker inspect -f {{`'{{.State.Running}}'`}} "{{ .DAGGER_ENGINE_CONTAINER_NAME }}" 2> /dev/null )" == 'true' \]
153160

154161
# We build an image and push it to a local registry.
155162
# The name is always `plugin-barman-cloud:testing`.
@@ -161,12 +168,12 @@ tasks:
161168
env:
162169
# renovate: datasource=git-refs depName=docker lookupName=https://github.com/purpleclay/daggerverse currentValue=main
163170
DAGGER_DOCKER_SHA: 910e1ac9754f208569ac4d65f1ef52d9a2301833
164-
_EXPERIMENTAL_DAGGER_RUNNER_HOST: docker-container://{{.DAGGER_ENGINE_CONTAINER_NAME}}
171+
_EXPERIMENTAL_DAGGER_RUNNER_HOST: docker-container://{{ .DAGGER_ENGINE_CONTAINER_NAME }}
165172
cmds:
166173
- >
167-
GITHUB_REF= dagger call -m github.com/purpleclay/daggerverse/docker@${DAGGER_DOCKER_SHA}
174+
GITHUB_REF= dagger -s call -m github.com/purpleclay/daggerverse/docker@${DAGGER_DOCKER_SHA}
168175
build --dir . --file containers/Dockerfile.plugin --platform linux/amd64
169-
publish --ref ${REGISTRY_NAME}:${REGISTRY_PORT}/plugin-barman-cloud --tags testing
176+
publish --ref {{ .REGISTRY_NAME }}:{{ .REGISTRY_PORT }}/plugin-barman-cloud --tags testing
170177
171178
# We build an image and push it to a local registry.
172179
# The name is always `sidecar-barman-cloud:testing`.
@@ -178,19 +185,52 @@ tasks:
178185
env:
179186
# renovate: datasource=git-refs depName=docker lookupName=https://github.com/purpleclay/daggerverse currentValue=main
180187
DAGGER_DOCKER_SHA: 910e1ac9754f208569ac4d65f1ef52d9a2301833
181-
_EXPERIMENTAL_DAGGER_RUNNER_HOST: docker-container://{{.DAGGER_ENGINE_CONTAINER_NAME}}
188+
_EXPERIMENTAL_DAGGER_RUNNER_HOST: docker-container://{{ .DAGGER_ENGINE_CONTAINER_NAME }}
182189
cmds:
183190
- >
184-
GITHUB_REF= dagger call -m github.com/purpleclay/daggerverse/docker@${DAGGER_DOCKER_SHA}
191+
GITHUB_REF= dagger -s call -m github.com/purpleclay/daggerverse/docker@${DAGGER_DOCKER_SHA}
185192
build --dir . --file containers/Dockerfile.sidecar --platform linux/amd64
186-
publish --ref ${REGISTRY_NAME}:${REGISTRY_PORT}/sidecar-barman-cloud --tags testing
193+
publish --ref {{ .REGISTRY_NAME }}:{{ .REGISTRY_PORT }}/sidecar-barman-cloud --tags testing
187194
188195
build-images:
189196
desc: Build the container images for the plugin
190197
deps:
191198
- build-plugin-image
192199
- build-sidecar-image
193200

201+
# Install kind if not at the expected version.
202+
install-kind:
203+
desc: Install kind
204+
run: once
205+
vars:
206+
# renovate: datasource=git-refs depName=kind lookupName=https://github.com/kubernetes-sigs/kind versioning=semver
207+
KIND_VERSION: v0.26.0
208+
cmds:
209+
- go install sigs.k8s.io/kind@{{.KIND_VERSION}}
210+
- kind version | grep -q {{.KIND_VERSION}}
211+
status:
212+
- kind version | grep -q {{.KIND_VERSION}}
213+
214+
start-kind-cluster:
215+
desc: Start a kind cluster
216+
deps:
217+
- install-kind
218+
- start-build-network
219+
run: once
220+
cmds:
221+
- >
222+
kind create cluster --name {{ .E2E_CLUSTER_NAME }}
223+
--image kindest/node:{{ .E2E_KUBERNETES_VERSION }}
224+
--config hack/kind-config.yaml
225+
--wait 5m
226+
- >
227+
for node in $(kind get nodes --name {{ .E2E_CLUSTER_NAME }} ); do
228+
docker network connect {{ .REGISTRY_NETWORK }} $node;
229+
docker exec $node sh -c "update-ca-certificates";
230+
done
231+
status:
232+
- kind get clusters | grep -q {{ .E2E_CLUSTER_NAME }}
233+
194234
# TODO: see if it is possible to daggerize this. It will have to manage docker to make kind work.
195235
# TODO: add a task to clean up the kind cluster for new test runs.
196236
# Run the e2e tests. This task will start a kind cluster, deploy the plugin, and run the tests.
@@ -199,22 +239,42 @@ tasks:
199239
# * The registry to be in the same network of the dagger-engine.
200240
# * The dagger-engine to mount the CA.
201241
# * The kind cluster to mount the CA.
202-
e2e:
203-
desc: Run e2e tests
242+
e2e-external-kind:
243+
desc: Run e2e tests in a local kind cluster
204244
deps:
205245
- build-images
246+
- start-kind-cluster
247+
vars:
248+
# renovate: datasource=docker depName=golang versioning=semver
249+
GOLANG_IMAGE_VERSION: 1.23.4
250+
KUBECONFIG_PATH:
251+
sh: mktemp -t kubeconfig-XXXXX
252+
env:
253+
_EXPERIMENTAL_DAGGER_RUNNER_HOST: docker-container://{{ .DAGGER_ENGINE_CONTAINER_NAME }}
254+
cmds:
255+
- kind get kubeconfig --internal --name {{ .E2E_CLUSTER_NAME }} > {{ .KUBECONFIG_PATH }}
256+
- >
257+
GITHUB_REF= dagger call -m dagger/e2e/ run
258+
--source .
259+
--kubeconfig {{.KUBECONFIG_PATH}}
260+
--go-version {{ .GOLANG_IMAGE_VERSION }}
261+
262+
e2e-ephemeral:
263+
desc: Run e2e tests in an ephemeral k3s cluster
264+
deps:
265+
- build-images
266+
vars:
267+
# renovate: datasource=docker depName=golang versioning=semver
268+
GOLANG_IMAGE_VERSION: 1.23.4
269+
env:
270+
_EXPERIMENTAL_DAGGER_RUNNER_HOST: docker-container://{{ .DAGGER_ENGINE_CONTAINER_NAME }}
206271
cmds:
207272
- >
208-
go run github.com/onsi/ginkgo/v2/ginkgo
209-
--procs=8
210-
--randomize-all
211-
--randomize-suites
212-
--fail-on-pending
213-
--fail-on-empty
214-
--keep-going
215-
--timeout=30m
216-
--github-output
217-
./test/e2e
273+
GITHUB_REF= dagger call -m dagger/e2e/ run-ephemeral
274+
--source .
275+
--ca certs/ca.pem
276+
--registry {{.REGISTRY_NAME}}:{{.REGISTRY_PORT}}
277+
--go-version {{ .GOLANG_IMAGE_VERSION }}
218278
219279
ci:
220280
desc: Run the CI pipeline
@@ -224,7 +284,7 @@ tasks:
224284
- uncommitted
225285
- lint
226286
- go-test
227-
- e2e
287+
- e2e-ephemeral
228288

229289
publish:
230290
desc: Build and publish a container image for the plugin
@@ -284,7 +344,7 @@ tasks:
284344
- controller-gen
285345
desc: Generate the manifest for the main branch
286346
vars:
287-
GITHUB_REPOSITORY: '{{ default "cloudnative-pg/plugin-barman-cloud" .GITHUB_REPOSITORY }}'
347+
GITHUB_REPOSITORY: cloudnative-pg/plugin-barman-cloud
288348
GITHUB_REF: main
289349
GITHUB_REF_NAME: main
290350
cmds:

dagger/e2e/.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/e2e/.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/e2e/dagger.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "e2e",
3+
"engineVersion": "v0.15.1",
4+
"sdk": "go",
5+
"dependencies": [
6+
{
7+
"name": "go",
8+
"source": "github.com/sagikazarmark/daggerverse/go@go/v0.9.0",
9+
"pin": "d9ba06776c4c1ccf6f329bd862b9b439c4582ab6"
10+
},
11+
{
12+
"name": "k3s",
13+
"source": "github.com/marcosnils/daggerverse/k3s@k3s/v0.1.7",
14+
"pin": "833ec36632b2457862f6e3bf1f7107ad65e3e515"
15+
}
16+
],
17+
"source": "."
18+
}

dagger/e2e/go.mod

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
module dagger/e-2-e
2+
3+
go 1.23.2
4+
5+
require (
6+
github.com/99designs/gqlgen v0.17.57
7+
github.com/Khan/genqlient v0.7.0
8+
github.com/vektah/gqlparser/v2 v2.5.19
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/otlpmetric/otlpmetricgrpc v1.27.0
13+
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.27.0
14+
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.27.0
15+
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.27.0
16+
go.opentelemetry.io/otel/log v0.3.0
17+
go.opentelemetry.io/otel/metric v1.27.0
18+
go.opentelemetry.io/otel/sdk v1.27.0
19+
go.opentelemetry.io/otel/sdk/log v0.3.0
20+
go.opentelemetry.io/otel/sdk/metric v1.27.0
21+
go.opentelemetry.io/otel/trace v1.27.0
22+
go.opentelemetry.io/proto/otlp v1.3.1
23+
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa
24+
golang.org/x/sync v0.10.0
25+
google.golang.org/grpc v1.68.0
26+
)
27+
28+
require (
29+
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
30+
github.com/go-logr/logr v1.4.2 // indirect
31+
github.com/go-logr/stdr v1.2.2 // indirect
32+
github.com/google/uuid v1.6.0 // indirect
33+
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect
34+
github.com/sosodev/duration v1.3.1 // indirect
35+
github.com/stretchr/testify v1.10.0 // indirect
36+
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.27.0 // indirect
37+
golang.org/x/net v0.29.0 // indirect
38+
golang.org/x/sys v0.28.0 // indirect
39+
golang.org/x/text v0.21.0 // indirect
40+
google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 // indirect
41+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect
42+
google.golang.org/protobuf v1.35.2 // indirect
43+
)
44+
45+
replace go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc => go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240518090000-14441aefdf88
46+
47+
replace go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp => go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.3.0
48+
49+
replace go.opentelemetry.io/otel/log => go.opentelemetry.io/otel/log v0.3.0
50+
51+
replace go.opentelemetry.io/otel/sdk/log => go.opentelemetry.io/otel/sdk/log v0.3.0

0 commit comments

Comments
 (0)