From 0018721275f522d8e06a6066c19e8d519100ac84 Mon Sep 17 00:00:00 2001 From: Daniel Villanueva Date: Wed, 27 Nov 2024 16:23:23 +0100 Subject: [PATCH] test(e2e): job to run the e2e 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 test(e2e): added stacktrace to check why the test breaks Signed-off-by: Daniel Villanueva test(e2e): change path of sso extension build to correct one Signed-off-by: Daniel Villanueva test(e2e): revert try-catch clause, added e2e-tests job to e2e-main Signed-off-by: Daniel Villanueva test(e2e): removed unnecesary 'page' Signed-off-by: Daniel Villanueva test(e2e): skip local build on linux Signed-off-by: Daniel Villanueva test(e2e): build crc extension from dockerfile (test) Signed-off-by: Daniel Villanueva test(e2e): new version of local build Signed-off-by: Daniel Villanueva test(e2e): new version of local build but for sso extension as well Signed-off-by: Daniel Villanueva test(e2e): fixed path on previous commit Signed-off-by: Daniel Villanueva test(e2e): added missing folder Signed-off-by: Daniel Villanueva test(e2e): fixed target path Signed-off-by: Daniel Villanueva test(e2e): added target folder properly Signed-off-by: Daniel Villanueva test(e2e): print extension error during tests Signed-off-by: Daniel Villanueva test(e2e): revert - print extension error during tests This reverts commit e9a3566f31e57b3e289f64a2deda92824e8c97ff. test(e2e): fixed pathing issue? Signed-off-by: Daniel Villanueva test(e2e): fixed pathing issue (this time for real) Signed-off-by: Daniel Villanueva test(e2e): clean up, add previous changes to e2e-main.yaml Signed-off-by: Daniel Villanueva --- .github/workflows/e2e-main.yml | 110 +++++++++++++++++--- .github/workflows/pr-check.yaml | 85 +++++++++++++-- tests/src/openshift-local-extension.spec.ts | 2 +- 3 files changed, 172 insertions(+), 25 deletions(-) diff --git a/.github/workflows/e2e-main.yml b/.github/workflows/e2e-main.yml index a26a073c..5f6e9611 100644 --- a/.github/workflows/e2e-main.yml +++ b/.github/workflows/e2e-main.yml @@ -41,19 +41,18 @@ on: jobs: e2e-tests: - name: Run E2E tests - runs-on: ubuntu-24.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 - if: github.event_name == 'workflow_dispatch' with: - repository: ${{ github.event.inputs.organization }}/${{ github.event.inputs.repositoryName }} - ref: ${{ github.event.inputs.branch }} - path: ${{ github.event.inputs.repositoryName }} - - - uses: actions/checkout@v4 - if: github.event_name == 'schedule' - with: path: crc-extension # Checkout podman desktop @@ -63,6 +62,14 @@ jobs: ref: main path: podman-desktop + # Checkout sso extension + - uses: actions/checkout@v4 + if: matrix.os == 'windows-2022' + with: + repository: redhat-developer/podman-desktop-redhat-account-ext + ref: main + path: sso-extension + - uses: actions/setup-node@v4 with: node-version: 20 @@ -73,37 +80,108 @@ 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 + if: matrix.os == 'windows-2022' + working-directory: ./sso-extension + run: pnpm install + - name: Build Podman Desktop for E2E tests working-directory: ./podman-desktop run: pnpm test:e2e:build - - name: Ensure getting current HEAD version of the test framework + - 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 (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 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 + # 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: | + # -- following https://github.com/crc-org/crc-extension/blob/main/oci/Containerfile.multistage -- + # build extension + yarn build + # make expected test folders + New-Item -ItemType Directory -Path "tests\playwright\output\crc-tests-pd\plugins" -Force + New-Item -ItemType Directory -Path "tests\playwright\output\crc-tests-pd\plugins\crcextension" -Force + New-Item -ItemType Directory -Path "tests\playwright\output\crc-tests-pd\plugins\ssoextension" -Force + # move necessary files there + Copy-Item -Path "./package.json" -Destination ".\tests\playwright\output\crc-tests-pd\plugins\crcextension" -Force + Copy-Item -Path "./LICENSE" -Destination ".\tests\playwright\output\crc-tests-pd\plugins\crcextension" -Force + Copy-Item -Path "./icon.png" -Destination ".\tests\playwright\output\crc-tests-pd\plugins\crcextension" -Force + Copy-Item -Path "./README.md" -Destination ".\tests\playwright\output\crc-tests-pd\plugins\crcextension" -Force + Copy-Item -Path "./dist" -Destination ".\tests\playwright\output\crc-tests-pd\plugins\crcextension" -Recurse -Force + + - 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: | + # -- following https://github.com/redhat-developer/podman-desktop-redhat-account-ext/blob/main/Containerfile -- + # build extension + pnpm build + # put the contents into its expected folder (parent folder created in previous step): + Copy-Item -Path "./builtin/redhat-authentication.cdix/*" -Destination "..\crc-extension\tests\playwright\output\crc-tests-pd\plugins\ssoextension" -Recurse -Force + - name: Run All E2E tests working-directory: ./crc-extension env: PODMAN_DESKTOP_ARGS: ${{ github.workspace }}/podman-desktop run: yarn test:e2e - + - name: Publish Test Report uses: mikepenz/action-junit-report@v5 if: always() # always run even if the previous step fails @@ -118,5 +196,5 @@ jobs: - uses: actions/upload-artifact@v4 if: always() with: - name: e2e-tests + name: e2e-tests-${{ matrix.os }} path: ./**/tests/**/output/ diff --git a/.github/workflows/pr-check.yaml b/.github/workflows/pr-check.yaml index e85f0138..74992a9f 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,14 @@ jobs: ref: main path: podman-desktop + # Checkout sso extension + - uses: actions/checkout@v4 + if: matrix.os == 'windows-2022' + 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 +159,102 @@ 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 + if: matrix.os == 'windows-2022' + 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: | + # -- following https://github.com/crc-org/crc-extension/blob/main/oci/Containerfile.multistage -- + # build extension + yarn build + # make expected test folders + New-Item -ItemType Directory -Path "tests\playwright\output\crc-tests-pd\plugins" -Force + New-Item -ItemType Directory -Path "tests\playwright\output\crc-tests-pd\plugins\crcextension" -Force + New-Item -ItemType Directory -Path "tests\playwright\output\crc-tests-pd\plugins\ssoextension" -Force + # move necessary files there + Copy-Item -Path "./package.json" -Destination ".\tests\playwright\output\crc-tests-pd\plugins\crcextension" -Force + Copy-Item -Path "./LICENSE" -Destination ".\tests\playwright\output\crc-tests-pd\plugins\crcextension" -Force + Copy-Item -Path "./icon.png" -Destination ".\tests\playwright\output\crc-tests-pd\plugins\crcextension" -Force + Copy-Item -Path "./README.md" -Destination ".\tests\playwright\output\crc-tests-pd\plugins\crcextension" -Force + Copy-Item -Path "./dist" -Destination ".\tests\playwright\output\crc-tests-pd\plugins\crcextension" -Recurse -Force + + - 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: | + # -- following https://github.com/redhat-developer/podman-desktop-redhat-account-ext/blob/main/Containerfile -- + # build extension + pnpm build + # put the contents into its expected folder (parent folder created in previous step): + Copy-Item -Path "./builtin/redhat-authentication.cdix/*" -Destination "..\crc-extension\tests\playwright\output\crc-tests-pd\plugins\ssoextension" -Recurse -Force + - name: Run All E2E tests working-directory: ./crc-extension env: @@ -206,5 +275,5 @@ jobs: - uses: actions/upload-artifact@v4 if: always() with: - name: e2e-tests + name: e2e-tests-${{ matrix.os }} path: ./**/tests/**/output/ diff --git a/tests/src/openshift-local-extension.spec.ts b/tests/src/openshift-local-extension.spec.ts index fe0cbda9..2c563f13 100644 --- a/tests/src/openshift-local-extension.spec.ts +++ b/tests/src/openshift-local-extension.spec.ts @@ -98,7 +98,7 @@ test.describe.serial('Red Hat OpenShift Local extension verification', () => { test('Extension\'s details show correct status, no error', async ({ page,navigationBar }) => { const extensions = await navigationBar.openExtensions(); const extensionCard = await extensions.getInstalledExtension(extensionLabelNameCrc, extensionLabelCrc); - await extensionCard.openExtensionDetails('Red Hat Authentication'); + await extensionCard.openExtensionDetails('Red Hat OpenShift Local'); const details = new OpenShiftLocalExtensionPage(page); await playExpect(details.heading).toBeVisible(); await playExpect(details.status).toHaveText(activeExtensionStatus);