Skip to content

Commit 8f9f88e

Browse files
committed
fix: use local images in CI instead of pushing to ghcr.io
Fork PRs fail at "Push client image" because GITHUB_TOKEN is read-only for forked repositories. Instead of pushing images to ghcr.io and pulling them in the test job, build images locally and load them into minikube with registry="local" and pullPolicy="Never". - Merge build_images and run_tests into a single build_and_test job - Build images with `make client-image tel2-image` and load into minikube - Remove ghcr.io login/push/logout and docker buildx setup - Move image pruning to release.yaml where it runs after push-images - Fix pullPolicy in helm.go to set "Never" for local registry even in CI Signed-off-by: Thomas Hallgren <thomas@tada.se>
1 parent 43237bb commit 8f9f88e

File tree

3 files changed

+51
-81
lines changed

3 files changed

+51
-81
lines changed

.github/workflows/dev.yaml

Lines changed: 26 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,26 @@ on:
44
types:
55
- labeled
66

7+
permissions:
8+
contents: read
9+
pull-requests: write
10+
711
env:
8-
TELEPRESENCE_REGISTRY: ghcr.io/telepresenceio
12+
TELEPRESENCE_REGISTRY: local
913

1014
jobs:
11-
build_images:
15+
build_and_test:
1216
if: ${{ github.event.label.name == 'ok to test' || github.event.label.name == 'compatibility test' }}
13-
runs-on: ubuntu-latest
14-
outputs:
15-
telepresenceVersion: ${{ steps.version.outputs.version }}
16-
telepresenceSemver: ${{ steps.version.outputs.semver }}
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
runners:
21+
- ubuntu-latest
22+
# Re-enable when we can run a proper cluster. Colima almost works on macOS but the very limited
23+
# resources available make the test fail very often. On windows, we'll need WSL2
24+
# - macos-latest
25+
# - windows-latest
26+
runs-on: ${{ matrix.runners }}
1727
steps:
1828
- name: Remove ok to test label
1929
if: github.event.label.name == 'ok to test'
@@ -33,62 +43,27 @@ jobs:
3343
with:
3444
fetch-depth: 0
3545
ref: "${{ github.event.pull_request.head.sha }}"
46+
- name: install dependencies
47+
uses: ./.github/actions/install-dependencies
3648
- name: Get Telepresence Version
3749
id: version
3850
run: |
3951
v=$(go run build-aux/genversion/main.go ${{github.run_id}})
4052
echo "TELEPRESENCE_VERSION=$v" >> "$GITHUB_ENV"
4153
echo "TELEPRESENCE_SEMVER=${v#v}" >> "$GITHUB_ENV"
42-
echo "version=$v" >> $GITHUB_OUTPUT
43-
echo "semver=${v#v}" >> $GITHUB_OUTPUT
44-
- name: Setup docker buildx
45-
uses: docker/setup-buildx-action@v3
46-
with:
47-
platforms: linux/amd64,linux/arm64
48-
- name: Build image dependencies
49-
run: make images-deps
50-
- name: Log in to registry
51-
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
52-
- name: Push client image
53-
run: |
54-
docker buildx build --platform=linux/amd64,linux/arm64 --build-arg TELEPRESENCE_VERSION=${{env.TELEPRESENCE_SEMVER}} \
55-
--push --tag ${{env.TELEPRESENCE_REGISTRY}}/telepresence:${{env.TELEPRESENCE_SEMVER}} -f build-aux/docker/images/Dockerfile.client .
56-
- name: Push tel2 image
57-
run: |
58-
docker buildx build --platform=linux/amd64,linux/arm64 --build-arg TELEPRESENCE_VERSION=${{env.TELEPRESENCE_SEMVER}} \
59-
--push --tag ${{env.TELEPRESENCE_REGISTRY}}/tel2:${{env.TELEPRESENCE_SEMVER}} -f build-aux/docker/images/Dockerfile.traffic .
60-
- name: Log out from registry
61-
if: always()
62-
run: docker logout
63-
64-
run_tests:
65-
if: ${{ github.event.label.name == 'ok to test' || github.event.label.name == 'compatibility test' }}
66-
strategy:
67-
fail-fast: false
68-
matrix:
69-
runners:
70-
- ubuntu-latest
71-
# Re-enable when we can run a proper cluster. Colima almost works on macOS but the very limited
72-
# resources available make the test fail very often. On windows, we'll need WSL2
73-
# - macos-latest
74-
# - windows-latest
75-
runs-on: ${{ matrix.runners }}
76-
needs: build_images
77-
env:
78-
TELEPRESENCE_VERSION: ${{ needs.build_images.outputs.telepresenceVersion }}
79-
steps:
80-
- uses: actions/checkout@v4
81-
with:
82-
ref: "${{ github.event.pull_request.head.sha }}"
83-
- name: install dependencies
84-
uses: ./.github/actions/install-dependencies
8554
- name: Start minikube
8655
if: runner.os == 'Linux'
8756
uses: medyagh/setup-minikube@latest
8857
with:
8958
kubernetes-version: v1.33.5
9059
- name: Build client
9160
run: make build
61+
- name: Build images
62+
run: make client-image tel2-image
63+
- name: Load images into minikube
64+
run: |
65+
minikube image load ${{env.TELEPRESENCE_REGISTRY}}/telepresence:${{env.TELEPRESENCE_SEMVER}}
66+
minikube image load ${{env.TELEPRESENCE_REGISTRY}}/tel2:${{env.TELEPRESENCE_SEMVER}}
9267
- name: Run integration tests
9368
if: github.event.label.name == 'ok to test'
9469
uses: nick-fields/retry/@v3
@@ -106,6 +81,7 @@ jobs:
10681
if: ${{ github.event.label.name == 'compatibility test' }}
10782
env:
10883
DEV_MANAGER_VERSION: "2.24.1"
84+
DEV_MANAGER_REGISTRY: ghcr.io/telepresenceio
10985
uses: nick-fields/retry/@v3
11086
with:
11187
max_attempts: 3
@@ -121,6 +97,7 @@ jobs:
12197
if: ${{ github.event.label.name == 'compatibility test' }}
12298
env:
12399
DEV_CLIENT_VERSION: "2.24.1"
100+
DEV_CLIENT_REGISTRY: ghcr.io/telepresenceio
124101
uses: nick-fields/retry/@v3
125102
with:
126103
max_attempts: 3
@@ -136,30 +113,3 @@ jobs:
136113
env:
137114
LOG_SUFFIX: "${{ runner.os }}-${{ runner.arch }}-${{ matrix.clusters.distribution }}-${{ matrix.clusters.version }}"
138115
if: ${{ always() }}
139-
purge_images:
140-
if: ${{ always() }}
141-
runs-on: ubuntu-latest
142-
permissions:
143-
packages: write
144-
needs:
145-
- build_images
146-
- run_tests
147-
steps:
148-
- name: Delete tel2 and telepresence image
149-
uses: dataaxiom/ghcr-cleanup-action@v1
150-
continue-on-error: true
151-
with:
152-
owner: telepresenceio
153-
packages: tel2,telepresence
154-
token: ${{ secrets.GITHUB_TOKEN }}
155-
delete-tags: ${{ needs.build_images.outputs.telepresenceSemver }}
156-
- name: Prune tel2 and telepresence
157-
uses: dataaxiom/ghcr-cleanup-action@v1
158-
with:
159-
owner: telepresenceio
160-
packages: tel2,telepresence
161-
token: ${{ secrets.GITHUB_TOKEN }}
162-
delete-untagged: true
163-
delete-ghost-images: true
164-
delete-partial-images: true
165-
delete-orphaned-images: true

.github/workflows/release.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,25 @@ jobs:
215215
v=${{ github.ref_name }}
216216
packaging/homebrew-package.sh "${v#v}" "${{ vars.GH_BOT_USER }}" "${{ vars.GH_BOT_EMAIL }}" "${{ secrets.HOMEBREW_TAP_TOKEN }}"
217217
218+
prune-images:
219+
if: ${{ always() }}
220+
runs-on: ubuntu-latest
221+
permissions:
222+
packages: write
223+
needs:
224+
- push-images
225+
steps:
226+
- name: Prune tel2 and telepresence
227+
uses: dataaxiom/ghcr-cleanup-action@v1
228+
with:
229+
owner: telepresenceio
230+
packages: tel2,telepresence
231+
token: ${{ secrets.GITHUB_TOKEN }}
232+
delete-untagged: true
233+
delete-ghost-images: true
234+
delete-partial-images: true
235+
delete-orphaned-images: true
236+
218237
test-release:
219238
needs:
220239
- push-images

integration_test/itest/helm.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -260,15 +260,16 @@ func (s *cluster) TelepresenceHelmInstall(ctx context.Context, upgrade bool, set
260260
}
261261

262262
vx.Image = GetImage(ctx)
263-
if !s.isCI && s.ManagerVersion().EQ(s.ClientVersion()) {
264-
pp := "Always"
263+
if s.ManagerVersion().EQ(s.ClientVersion()) {
265264
if s.ManagerRegistry() == "local" {
266265
// Using minikube with local images.
267266
// They are automatically present and must not be pulled.
268-
pp = "Never"
267+
vx.Image.PullPolicy = "Never"
268+
vx.Agent.Image.PullPolicy = "Never"
269+
} else if !s.isCI {
270+
vx.Image.PullPolicy = "Always"
271+
vx.Agent.Image.PullPolicy = "Always"
269272
}
270-
vx.Image.PullPolicy = pp
271-
vx.Agent.Image.PullPolicy = pp
272273
}
273274

274275
ss, err := yaml.Marshal(&vx)

0 commit comments

Comments
 (0)