From 4bde53614e151d78a131b80b3eb22752fd82afc8 Mon Sep 17 00:00:00 2001 From: Daniel Villanueva Date: Wed, 27 Nov 2024 16:23:23 +0100 Subject: [PATCH] test(e2e): draft of the tests on windows test(e2e): added windows to pr check test(e2e): fixed ubuntu error test(e2e): fixed windows error test(e2e): fixed windows error - part 2 test(e2e): fixed windows error - part 3 test(e2e): triggering pr-check test(e2e): ditch jq in windows test(e2e): testing why podman is not found Signed-off-by: Daniel Villanueva test(e2e): install podman in the tests workflow for windows Signed-off-by: Daniel Villanueva test(e2e): use docker to build extension image Signed-off-by: Daniel Villanueva test(e2e): swap docker's execution mode to linux Signed-off-by: Daniel Villanueva test(e2e): revert previous commit Signed-off-by: Daniel Villanueva test(e2e): new version of build step Signed-off-by: Daniel Villanueva test(e2e): building locally the extension Signed-off-by: Daniel Villanueva test(e2e): fix relative path Signed-off-by: Daniel Villanueva test(e2e): build extension once before test matrix Signed-off-by: Daniel Villanueva test(e2e): revert - build extension once before test matrix This reverts commit de5650bcf10758cd327c1490189a23f1e3de9980. test(e2e): swap pnpm to yarn Signed-off-by: Daniel Villanueva test(e2e): add cache management + frozen lockfile Signed-off-by: Daniel Villanueva test(e2e): remove frozen lockfile, add previous steps to run only on windows Signed-off-by: Daniel Villanueva test(e2e): try to sync yarn dependencies Signed-off-by: Daniel Villanueva test(e2e): fix encoding issue package.json Signed-off-by: Daniel Villanueva test(e2e): new version of getting podman desktop version Signed-off-by: Daniel Villanueva test(e2e): add missing working directory Signed-off-by: Daniel Villanueva test(e2e): add --platform to docker pull Signed-off-by: Daniel Villanueva test(e2e): add buildx to use linux images on windows Signed-off-by: Daniel Villanueva test(e2e): revert - add buildx to use linux images on windows This reverts commit 76ff1062c1c85360ec82e3290398960798ad0236. test(e2e): build sso image locally too Signed-off-by: Daniel Villanueva test(e2e): missing pnpm install on sso extension Signed-off-by: Daniel Villanueva test(e2e): clean up, fix artifact upload Signed-off-by: Daniel Villanueva test(e2e): more cleanup + squash Signed-off-by: Daniel Villanueva --- .github/workflows/e2e-main.yml | 21 ++++++++-- .github/workflows/pr-check.yaml | 74 +++++++++++++++++++++++++++++---- 2 files changed, 84 insertions(+), 11 deletions(-) diff --git a/.github/workflows/e2e-main.yml b/.github/workflows/e2e-main.yml index 76cd49d..0c54636 100644 --- a/.github/workflows/e2e-main.yml +++ b/.github/workflows/e2e-main.yml @@ -41,8 +41,12 @@ on: jobs: e2e-tests: - name: Run E2E tests - runs-on: ubuntu-24.04 + name: Run E2E tests on ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [windows-2022, ubuntu-24.04] #, macos-14 + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 if: github.event_name == 'workflow_dispatch' @@ -81,19 +85,30 @@ jobs: working-directory: ./podman-desktop run: pnpm test:e2e:build - - name: Ensure getting current HEAD version of the test framework + - name: Ensure getting current HEAD version of the test framework (windows) working-directory: ./crc-extension run: | # workaround for https://github.com/containers/podman-desktop-extension-bootc/issues/712 version=$(npm view @podman-desktop/tests-playwright@next version) echo "Version of @podman-desktop/tests-playwright to be used: $version" jq --arg version "$version" '.devDependencies."@podman-desktop/tests-playwright" = $version' package.json > package.json_tmp && mv package.json_tmp package.json + shell: powershell + + - name: Ensure getting current HEAD version of the test framework (ubuntu) + working-directory: ./crc-extension + run: | + # workaround for https://github.com/containers/podman-desktop-extension-bootc/issues/712 + version=$(npm view @podman-desktop/tests-playwright@next version) + echo "Version of @podman-desktop/tests-playwright to be used: $version" + jq --arg version "$version" '.devDependencies."@podman-desktop/tests-playwright" = $version' package.json > package.json_tmp && mv package.json_tmp package.json + shell: bash - name: Execute yarn in OpenShift Local Extension working-directory: ./crc-extension run: yarn - name: Revert unprivileged user namespace restrictions in Ubuntu 24.04 + if: matrix.os == 'ubuntu-24.04' run: | # allow unprivileged user namespace sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0 diff --git a/.github/workflows/pr-check.yaml b/.github/workflows/pr-check.yaml index 419a79a..ed46763 100644 --- a/.github/workflows/pr-check.yaml +++ b/.github/workflows/pr-check.yaml @@ -120,11 +120,16 @@ jobs: run: yarn test e2e-tests: - name: e2e tests - runs-on: ubuntu-24.04 #20.04? + name: e2e tests for ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [windows-2022, ubuntu-24.04] #, macos-14 + runs-on: ${{ matrix.os }} env: SKIP_INSTALLATION: true steps: + # Checkout crc extension - uses: actions/checkout@v4 with: path: crc-extension @@ -136,6 +141,13 @@ jobs: ref: main path: podman-desktop + # Checkout sso extension + - uses: actions/checkout@v4 + with: + repository: redhat-developer/podman-desktop-redhat-account-ext + ref: main + path: sso-extension + - uses: actions/setup-node@v4 with: node-version: 20 @@ -146,46 +158,92 @@ jobs: run_install: false package_json_file: ./podman-desktop/package.json - - name: Execute pnpm + - name: Install Podman Desktop dependencies working-directory: ./podman-desktop run: pnpm install + - name: Install SSO extension dependencies + working-directory: ./sso-extension + run: pnpm install + - name: Build Podman Desktop for E2E tests working-directory: ./podman-desktop run: pnpm test:e2e:build + + - name: Adjust/Downgrade local podman desktop version Windows + if: matrix.os == 'windows-2022' + working-directory: ./crc-extension + run: | + $version="1.0.0" + jq --arg version "$version" '.version = $version' package.json | Out-File -FilePath package.json_tmp + Move-Item -Path package.json_tmp -Destination package.json -Force - - name: Ensure getting current HEAD version of the test framework + - name: Ensure getting current HEAD version of the test framework (ubuntu) + if: matrix.os == 'ubuntu-24.04' working-directory: ./crc-extension run: | # workaround for https://github.com/containers/podman-desktop-extension-bootc/issues/712 version=$(npm view @podman-desktop/tests-playwright@next version) echo "Version of @podman-desktop/tests-playwright to be used: $version" jq --arg version "$version" '.devDependencies."@podman-desktop/tests-playwright" = $version' package.json > package.json_tmp && mv package.json_tmp package.json + shell: bash + + - name: Synchronize CRC extension dependencies + working-directory: ./crc-extension + run: yarn install --check-files - name: Execute yarn in OpenShift Local Extension working-directory: ./crc-extension - run: yarn + run: yarn --frozen-lockfile - name: Revert unprivileged user namespace restrictions in Ubuntu 24.04 + if: matrix.os == 'ubuntu-24.04' run: | # allow unprivileged user namespace sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0 - - name: Build OpenShift Local extension from container file + - name: Build OpenShift Local extension from container file and SSO dependency (Ubuntu, podman) + if: matrix.os == 'ubuntu-24.04' working-directory: ./crc-extension run: | + # build crc extension podman build -t openshift_local_image . -f ./oci/Containerfile.multistage CONTAINER_ID_CRC=$(podman create localhost/openshift_local_image --entrypoint "") podman export $CONTAINER_ID_CRC > /tmp/openshift_local_extension.tar - mkdir -p tests/playwright/output/crc-tests-pd/plugins + + # build sso extension podman pull ghcr.io/redhat-developer/podman-desktop-redhat-account-ext:latest CONTAINER_ID_SSO=$(podman create ghcr.io/redhat-developer/podman-desktop-redhat-account-ext --entrypoint "") podman export $CONTAINER_ID_SSO > /tmp/sso_extension.tar + + # move extension files to expected locations + mkdir -p tests/playwright/output/crc-tests-pd/plugins tar -xf /tmp/openshift_local_extension.tar -C tests/playwright/output/crc-tests-pd/plugins/ mv tests/playwright/output/crc-tests-pd/plugins/extension/ tests/playwright/output/crc-tests-pd/plugins/crcextension tar -xf /tmp/sso_extension.tar -C tests/playwright/output/crc-tests-pd/plugins/ mv tests/playwright/output/crc-tests-pd/plugins/extension/ tests/playwright/output/crc-tests-pd/plugins/ssoextension + - name: Build OpenShift Local extension locally (Windows, docker) #from container file is not available yet + if: matrix.os == 'windows-2022' + working-directory: ./crc-extension + shell: pwsh + run: | + # generate 'openshift-local.cdix': + yarn build + # put the contents into its expected folder: + New-Item -ItemType Directory -Path tests\playwright\output\crc-tests-pd\plugins -Force + Expand-Archive -Path "$(pwd)\openshift-local.cdix" -DestinationPath ".\tests\playwright\output\crc-tests-pd\plugins\crcextension" + + - name: Build SSO extension (crc dependency) locally (Windows, docker) #from container file is not available yet + if: matrix.os == 'windows-2022' + working-directory: ./sso-extension + shell: pwsh + run: | + # generate 'redhat-authentication.cdix': + pnpm build + # put the contents into its expected folder (parent folder created in previous step): + Expand-Archive -Path "$(pwd)\redhat-authentication.cdix" -DestinationPath ".\tests\playwright\output\crc-tests-pd\plugins\ssoextension" + - name: Run All E2E tests working-directory: ./crc-extension env: @@ -195,5 +253,5 @@ jobs: - uses: actions/upload-artifact@v4 if: always() with: - name: e2e-tests + name: e2e-tests-${{ matrix.os }} path: ./**/tests/**/output/