Skip to content

Commit fdf3115

Browse files
committed
.github: Use devcontainer to run integration UI tests
1 parent f98dd64 commit fdf3115

File tree

1 file changed

+34
-40
lines changed

1 file changed

+34
-40
lines changed

.github/workflows/pre-merge.yaml

Lines changed: 34 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -358,32 +358,29 @@ jobs:
358358
run: poetry run pytest -vv
359359

360360
build_integration_container_nginx:
361-
needs: changed-files
361+
runs-on: ubuntu-latest
362+
needs:
363+
- build-devcontainer
364+
- changed-files
365+
container:
366+
image: ghcr.io/${{ github.repository }}/devcontainer:${{ github.sha }}
367+
# We have to use `root` for the moment
368+
# Sees: https://github.com/actions/checkout/issues/1575
369+
# Could work with a user with 1001 id but not for docker
370+
options: --user root
371+
credentials:
372+
username: ${{ github.repository_owner }}
373+
password: ${{ secrets.GITHUB_TOKEN }}
374+
defaults:
375+
run:
376+
shell: bash
362377
if: needs.changed-files.outputs.integration-tests-ui == 'true'
363-
runs-on: ubuntu-20.04
364378
permissions: write-all
365379
steps:
366380
- name: Checkout
367381
uses: actions/checkout@v4
368-
- name: Set up Docker Buildx
369-
uses: docker/setup-buildx-action@v3
370-
- name: Install node
371-
uses: actions/setup-node@v4
372-
with:
373-
node-version: "20"
374-
- name: Cache node modules
375-
id: cache-npm
376-
uses: actions/cache@v4
377-
env:
378-
cache-name: cache-node-modules
379-
with:
380-
# npm cache files are stored in `~/.npm` on Linux/macOS
381-
path: ~/.npm
382-
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
383-
restore-keys: |
384-
${{ runner.os }}-build-${{ env.cache-name }}-
385-
${{ runner.os }}-build-
386-
${{ runner.os }}-
382+
- name: Set safe directory (since container is root and not user 1001)
383+
run: git config --global --add safe.directory $GITHUB_WORKSPACE
387384
- name: Install Shell UI dependencies
388385
run: |
389386
cd shell-ui
@@ -420,7 +417,6 @@ jobs:
420417
registry: ghcr.io
421418
username: ${{ github.repository_owner }}
422419
password: ${{ secrets.GITHUB_TOKEN }}
423-
424420
- uses: docker/build-push-action@v6
425421
with:
426422
push: true
@@ -429,10 +425,23 @@ jobs:
429425
tags: ghcr.io/${{ github.repository_owner }}/metalk8s-nginx-integration-tests:${{ github.sha }}
430426

431427
integration_tests_ui:
432-
runs-on: ubuntu-20.04
428+
runs-on: ubuntu-latest
433429
needs:
430+
- build-devcontainer
434431
- build_integration_container_nginx
435432
- changed-files
433+
container:
434+
image: ghcr.io/${{ github.repository }}/devcontainer:${{ github.sha }}
435+
# We have to use `root` for the moment
436+
# Sees: https://github.com/actions/checkout/issues/1575
437+
# Could work with a user with 1001 id but not for docker
438+
options: --user root
439+
credentials:
440+
username: ${{ github.repository_owner }}
441+
password: ${{ secrets.GITHUB_TOKEN }}
442+
defaults:
443+
run:
444+
shell: bash
436445
if: needs.changed-files.outputs.integration-tests-ui == 'true'
437446
services:
438447
app:
@@ -445,23 +454,8 @@ jobs:
445454
steps:
446455
- name: Checkout
447456
uses: actions/checkout@v4
448-
- name: Install node
449-
uses: actions/setup-node@v4
450-
with:
451-
node-version: "20"
452-
- name: Cache node modules
453-
id: cache-npm
454-
uses: actions/cache@v4
455-
env:
456-
cache-name: cache-node-modules
457-
with:
458-
# npm cache files are stored in `~/.npm` on Linux/macOS
459-
path: ~/.npm
460-
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
461-
restore-keys: |
462-
${{ runner.os }}-build-${{ env.cache-name }}-
463-
${{ runner.os }}-build-
464-
${{ runner.os }}-
457+
- name: Set safe directory (since container is root and not user 1001)
458+
run: git config --global --add safe.directory $GITHUB_WORKSPACE
465459
- name: Install Cypress and its dependencies
466460
run: |
467461
cd ui

0 commit comments

Comments
 (0)