1
- name : Build, Test, and Publish Container Images
1
+ name : " Test and Publish BeeGFS CSI Driver "
2
2
3
3
on :
4
4
workflow_dispatch :
12
12
- " master"
13
13
14
14
env :
15
- # Container image registry to publish images to.
15
+ # Container image registry to publish images to:
16
16
REGISTRY : ghcr.io
17
- # The name of the image without a specific tag.
17
+ # Where to push an image of the CSI driver that will be retained (for master builds or releases) without a specific tag:
18
18
IMAGE_NAME : ghcr.io/thinkparq/beegfs-csi-driver
19
+ # Where to push an image of the CSI driver for testing (including the operator) without a specific tag:
20
+ TEST_IMAGE_NAME : ghcr.io/thinkparq/test-beegfs-csi-driver
21
+
22
+ # Note for all test images the github.sha will be used as the tag.
19
23
20
24
jobs :
21
25
build-and-unit-test :
@@ -57,35 +61,19 @@ jobs:
57
61
# TODO: Can we cache anything here? test-vendor downloads a lot of stuff.
58
62
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go#caching-dependencies
59
63
60
- - name : Set up Docker Buildx
61
- uses : docker/setup-buildx-action@v2
62
-
63
- # For now just tag with the commit ID to ensure subsequent jobs in this workflow run use the correct image.
64
- - name : Extract metadata for container image ${{ env.IMAGE_NAME }}
65
- id : meta
66
- uses : docker/metadata-action@v4
67
- with :
68
- images : |
69
- ${{ env.IMAGE_NAME }}
70
- tags : |
71
- type=sha,prefix=,format=long
72
-
73
- # We already built the image but this allows us to easily apply the appropriate labels and export the image.
74
- # It'll end up just reusing the local cache so it will complete very fast anyway.
75
- - name : Build and export image ${{ env.IMAGE_NAME }}
76
- uses : docker/build-push-action@v4
64
+ - name : Log into the GitHub Container Registry
65
+ uses : docker/login-action@v2
77
66
with :
78
- context : .
79
- push : false
80
- tags : ${{ steps.meta.outputs.tags }}
81
- labels : ${{ steps.meta.outputs.labels }}
82
- outputs : type=docker,dest=/tmp/beegfs-csi-driver.tar
67
+ registry : ${{ env.REGISTRY }}
68
+ username : ${{ github.actor }}
69
+ password : ${{ secrets.GITHUB_TOKEN }}
83
70
84
- - name : Upload the exported container image as an artifact for reuse in subsequent jobs
85
- uses : actions/upload-artifact@v3
86
- with :
87
- name : beegfs-csi-driver-image
88
- path : /tmp/beegfs-csi-driver.tar
71
+ # Push the image for reuse in subsequent steps, jobs, and workflows.
72
+ # For now just tag with the commit ID to ensure subsequent jobs in this workflow run use the correct image.
73
+ - name : Tag and push the CSI driver as a test package
74
+ run : |
75
+ docker tag beegfs-csi-driver:latest ${{ env.TEST_IMAGE_NAME }}:${{ github.sha }}
76
+ docker push ${{ env.TEST_IMAGE_NAME }}:${{ github.sha }}
89
77
90
78
e2e-tests :
91
79
runs-on : ubuntu-22.04
95
83
fail-fast : true
96
84
matrix :
97
85
k8s-version : [1.24.15, 1.25.11, 1.26.3, 1.27.3]
98
- beegfs-version : [7.3.3] # TODO: Expand tested versions
86
+ beegfs-version : [7.3.4]
99
87
permissions :
100
88
packages : read
101
89
contents : read
@@ -105,17 +93,6 @@ jobs:
105
93
- name : Set up Docker Buildx
106
94
uses : docker/setup-buildx-action@v2
107
95
108
- - name : Download the container image artifact built in the previous job
109
- uses : actions/download-artifact@v3
110
- with :
111
- name : beegfs-csi-driver-image
112
- path : /tmp
113
-
114
- - name : Load the downloaded container image into the local Docker cache
115
- run : |
116
- docker load --input /tmp/beegfs-csi-driver.tar
117
- docker image ls -a
118
-
119
96
- name : Deploy Kubernetes ${{ matrix.k8s-version }} using Minikube
120
97
uses : medyagh/setup-minikube@latest
121
98
with :
@@ -145,7 +122,7 @@ jobs:
145
122
envsubst < test/env/beegfs-ubuntu/csi-beegfs-connauth.yaml > deploy/k8s/overlays/default/csi-beegfs-connauth.yaml
146
123
# TODO: Enable once the K8s versions in the matrix are added to versions/
147
124
# sed -i 's?/versions/latest?/versions/v${{ matrix.k8s-version }}?g' deploy/k8s/overlays/default/kustomization.yaml
148
- echo -e "\nimages:\n - name: ${{ env.IMAGE_NAME }}\n newTag: ${{ github.sha }}" >> deploy/k8s/overlays/default/kustomization.yaml
125
+ echo -e "\nimages:\n - name: ${{ env.IMAGE_NAME }}\n newName: ${{ env.TEST_IMAGE_NAME }}\n newTag: ${{ github.sha }}" >> deploy/k8s/overlays/default/kustomization.yaml
149
126
kubectl apply -k deploy/k8s/overlays/default
150
127
151
128
# TODO (BCSI-7): Actually run e2e tests using Ginko with an appropriate timeout.
@@ -197,7 +174,6 @@ jobs:
197
174
runs-on : ubuntu-22.04
198
175
timeout-minutes : 5
199
176
needs : e2e-tests
200
- # TODO: Consider if we want to continue publishing images on pull requests.
201
177
if : github.event_name != 'pull_request'
202
178
permissions :
203
179
packages : write
@@ -213,16 +189,9 @@ jobs:
213
189
with :
214
190
cosign-release : " v2.1.1"
215
191
216
- - name : Download BeeGFS CSI driver image artifact
217
- uses : actions/download-artifact@v3
218
- with :
219
- name : beegfs-csi-driver-image
220
- path : /tmp
221
-
222
- - name : Load image
192
+ - name : Pull tested CSI driver image from ghcr.io
223
193
run : |
224
- docker load --input /tmp/beegfs-csi-driver.tar
225
- docker image ls -a
194
+ docker pull ${{ env.TEST_IMAGE_NAME }}:${{ github.sha }}
226
195
227
196
- name : Log in to the GitHub Container Registry
228
197
uses : docker/login-action@v2
@@ -244,11 +213,12 @@ jobs:
244
213
type=semver,pattern={{version}},prefix=v
245
214
type=semver,pattern={{major}}.{{minor}},prefix=v
246
215
216
+ # TODO: Consider adding labels available as steps.meta.output.labels.
247
217
- name : Tag and push the image to GitHub Container Registry
248
218
run : |
249
219
tags=$(echo "${{ steps.meta.outputs.tags }}" | tr '\n' ' ')
250
220
for tag in $tags; do
251
- docker tag ${{ env.IMAGE_NAME }}:${{ github.sha }} $tag
221
+ docker tag ${{ env.TEST_IMAGE_NAME }}:${{ github.sha }} $tag
252
222
docker push $tag
253
223
done
254
224
@@ -269,3 +239,24 @@ jobs:
269
239
env :
270
240
COSIGN_PRIVATE_KEY : ${{ secrets.COSIGN_PRIVATE_KEY }}
271
241
COSIGN_PASSWORD : ${{ secrets.COSIGN_PASSWORD }}
242
+
243
+ # We'll keep around a few old test packages to (a) avoid deleting image for workflows running in parallel,
244
+ # and (b) it may be useful to pull a package to troubleshoot workflow failures.
245
+ cleanup-test-images :
246
+ runs-on : ubuntu-22.04
247
+ timeout-minutes : 3
248
+ needs : publish-images
249
+ if : always()
250
+ steps :
251
+ - name : Extract package names
252
+ run : |
253
+ test_image_name="${{ env.TEST_IMAGE_NAME }}"
254
+ test_image_pkg=${test_image_name##*/}
255
+ echo "TEST_IMAGE_PKG=$test_image_pkg" >> $GITHUB_ENV
256
+
257
+ - name : Cleanup old ${{ env.TEST_IMAGE_PKG }} packages
258
+ uses : actions/delete-package-versions@v4
259
+ with :
260
+ package-name : " ${{ env.TEST_IMAGE_PKG }}"
261
+ package-type : " container"
262
+ min-versions-to-keep : 5
0 commit comments