Skip to content

Commit 93eba3a

Browse files
committed
ci: e2e
Signed-off-by: Philippe Martin <[email protected]>
1 parent 9eb8cfd commit 93eba3a

File tree

12 files changed

+532
-5
lines changed

12 files changed

+532
-5
lines changed

.github/workflows/e2e-tests.yaml

Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
#
2+
# Copyright (C) 2025 Red Hat, Inc.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
# SPDX-License-Identifier: Apache-2.0
17+
18+
name: e2e-tests
19+
20+
on:
21+
pull_request:
22+
types: [labeled, synchronize, opened, ready_for_review, reopened]
23+
24+
jobs:
25+
# Dedicated step to build the extension image
26+
build-container:
27+
if: ${{ contains(github.event.pull_request.labels.*.name, 'ci/e2e') }}
28+
name: Build Extension Image
29+
runs-on: ubuntu-24.04
30+
steps:
31+
- uses: actions/checkout@v6
32+
- name: Build Image and Extract Files
33+
id: build-image
34+
run: |
35+
podman build -t local_image -f build/Containerfile ./
36+
CONTAINER_ID=$(podman create localhost/local_image --entrypoint "")
37+
mkdir -p output/plugins
38+
podman export $CONTAINER_ID | tar -x -C output/plugins/
39+
podman rm -f $CONTAINER_ID
40+
podman rmi -f localhost/local_image:latest
41+
- name: Upload Extension Image Artifact
42+
uses: actions/upload-artifact@v5
43+
with:
44+
name: extension-plugin
45+
path: output/plugins/
46+
47+
e2e-pr-check:
48+
name: e2e tests smoke / ${{ matrix.os }}
49+
needs: build-container
50+
runs-on: ${{ matrix.os }}
51+
strategy:
52+
fail-fast: false
53+
matrix:
54+
os: [ windows-2022, ubuntu-24.04 ]
55+
env:
56+
SKIP_INSTALLATION: true
57+
EXTENSION_PREINSTALLED: true
58+
PODMAN_DESKTOP_ARGS: ${{ github.workspace }}/podman-desktop
59+
# by default playwright cache browsers binaries in ~/.cache/ms-playwright on Linux and %USERPROFILE%\AppData\Local\ms-playwright on Windows
60+
PLAYWRIGHT_BROWSERS_PATH: ${{ github.workspace }}/podman-desktop/pw-browsers
61+
steps:
62+
- uses: actions/checkout@v6
63+
64+
# ==============================================
65+
# Installing Podman
66+
# ==============================================
67+
- name: Install podman to 5.x
68+
if: runner.os == 'Windows'
69+
shell: pwsh
70+
run: |
71+
echo Installing Podman
72+
curl --output .\podman-setup.exe -L https://github.com/containers/podman/releases/download/v5.3.2/podman-5.3.2-setup.exe
73+
# Start the installer and wait for it to complete
74+
Start-Process -FilePath .\podman-setup.exe -ArgumentList "/install", "/passive", "/norestart", "/log podman-logs.txt" -Wait
75+
# Check the logs for debugging purposes
76+
Get-Content podman-logs.txt
77+
78+
# Init Podman Machine
79+
- name: Init Podman Machine (Windows)
80+
if: runner.os == 'Windows'
81+
shell: pwsh
82+
run: |
83+
echo "Adding Podman to PATH"
84+
$env:PATH += ";C:\Program Files\RedHat\Podman"
85+
podman --version
86+
podman machine init --now
87+
88+
# Update Podman linux
89+
- name: Update podman to 5.x
90+
if: runner.os == 'Linux'
91+
run: |
92+
echo "ubuntu version from kubic repository to install podman we need (v5)"
93+
ubuntu_version='23.10'
94+
echo "Add unstable kubic repo into list of available sources and get the repo key"
95+
sudo sh -c "echo 'deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_${ubuntu_version}/ /' > /etc/apt/sources.list.d/devel:kubic:libcontainers:unstable.list"
96+
curl -L "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_${ubuntu_version}/Release.key" | sudo apt-key add -
97+
echo "Updating all dependencies..."
98+
sudo apt-get update -qq
99+
echo "install necessary dependencies for criu package which is not part of ${ubuntu_version}"
100+
sudo apt-get install -qq libprotobuf32t64 python3-protobuf libnet1
101+
echo "install criu manually from static location"
102+
curl -sLO http://archive.ubuntu.com/ubuntu/pool/universe/c/criu/criu_3.16.1-2_amd64.deb && sudo dpkg -i criu_3.16.1-2_amd64.deb
103+
echo "installing/update podman package..."
104+
sudo apt-get -qq -y install podman || { echo "Start fallback steps for podman nightly installation from a static mirror" && \
105+
sudo sh -c "echo 'deb http://ftp.lysator.liu.se/pub/opensuse/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_${ubuntu_version}/ /' > /etc/apt/sources.list.d/devel:kubic:libcontainers:unstable.list" && \
106+
curl -L "http://ftp.lysator.liu.se/pub/opensuse/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_${ubuntu_version}/Release.key" | sudo apt-key add - && \
107+
sudo apt-get update && \
108+
sudo apt-get -y install podman; }
109+
podman version
110+
111+
- name: Revert unprivileged user namespace restrictions in Ubuntu 24.04
112+
if: runner.os == 'Linux'
113+
run: |
114+
# allow unprivileged user namespace
115+
sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
116+
117+
- name: Set cgroup_manager to 'cgroupfs' instead of systemd
118+
if: runner.os == 'Linux'
119+
run: |
120+
mkdir -p ~/.config/containers
121+
cat <<EOT >> ~/.config/containers/containers.conf
122+
[engine]
123+
cgroup_manager="cgroupfs"
124+
EOT
125+
podman info
126+
127+
# ==============================================
128+
# Installing Podman Desktop
129+
# ==============================================
130+
- uses: pnpm/action-setup@v4
131+
name: Install pnpm
132+
with:
133+
run_install: false
134+
135+
# Install Node.js
136+
- uses: actions/setup-node@v6
137+
with:
138+
node-version: 22
139+
cache: 'pnpm'
140+
141+
# Install npm packages for extension
142+
- name: Execute pnpm in Extension
143+
run: pnpm install
144+
145+
# Extract @podman-desktop/api version used (and store to $GITHUB_OUTPUT)
146+
- name: Extract @podman-desktop/api version
147+
id: pd-api-version
148+
shell: bash
149+
run: |
150+
# Using pnpm list to get the resolved version (E.g. getting 1.15.0 when ^1.15.0)
151+
export PD_VERSION=$(pnpm list -C packages/extension/ --json | jq -r '.[0].devDependencies."@podman-desktop/api".version')
152+
echo "PD_VERSION=$PD_VERSION" >> $GITHUB_OUTPUT
153+
echo "Using @podman-desktop/api $PD_VERSION"
154+
155+
# Check cache for existing podman-desktop
156+
- name: Cache Podman Desktop
157+
id: cache-pd
158+
uses: actions/cache@v4
159+
with:
160+
path: ${{ github.workspace }}/podman-desktop
161+
key: pd-${{ steps.pd-api-version.outputs.PD_VERSION }}-${{ runner.os }}
162+
163+
# Download Podman Desktop repository based on version defined in package.json
164+
- name: Download Podman Desktop
165+
if: steps.cache-pd.outputs.cache-hit != 'true'
166+
shell: bash
167+
env:
168+
PD_VERSION: ${{ steps.pd-api-version.outputs.PD_VERSION }}
169+
run: |
170+
echo "Downloading PD desktop to ${{ github.workspace }}/podman-desktop"
171+
# Stable release are available podman-desktop/podman-desktop
172+
# Prerelease are available under podman-desktop/prereleases
173+
if [[ "$PD_VERSION" =~ - ]]; then
174+
curl -sL "https://github.com/podman-desktop/prereleases/archive/refs/tags/v$PD_VERSION.tar.gz" | tar xvz
175+
else
176+
curl -sL "https://github.com/podman-desktop/podman-desktop/archive/refs/tags/v$PD_VERSION.tar.gz" | tar xvz
177+
fi
178+
# Move the extracted folder to the podman-desktop folder
179+
mv podman-desktop-$PD_VERSION/ podman-desktop/
180+
181+
# Install and build podman-desktop
182+
- name: Install pnpm deps and build Podman Desktop
183+
if: steps.cache-pd.outputs.cache-hit != 'true'
184+
shell: bash
185+
working-directory: ${{ github.workspace }}/podman-desktop
186+
run: |
187+
pnpm install
188+
pnpm test:e2e:build
189+
190+
# Install the extension
191+
- name: Download Extension Plugin
192+
uses: actions/download-artifact@v6
193+
with:
194+
name: extension-plugin
195+
path: tests/playwright/tests/playwright/output/kubernetes-dashboard-tests/plugins/
196+
197+
- name: Run E2E Smoke tests
198+
shell: bash
199+
run: pnpm test:e2e:smoke
200+
env:
201+
NODE_OPTIONS: --no-experimental-strip-types
202+
203+
- uses: actions/upload-artifact@v5
204+
if: always()
205+
with:
206+
name: e2e-pr-check-${{ matrix.os }}
207+
path: |
208+
tests/playwright/output/
209+
tests/playwright/tests/

.github/workflows/release.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,10 @@ jobs:
6969
sed -i "s#version\":\ \"\(.*\)\",#version\":\ \"${{ steps.TAG_UTIL.outputs.extVersion }}\",#g" packages/extension/package.json
7070
sed -i "s#version\":\ \"\(.*\)\",#version\":\ \"${{ steps.TAG_UTIL.outputs.extVersion }}\",#g" packages/webview/package.json
7171
sed -i "s#version\":\ \"\(.*\)\",#version\":\ \"${{ steps.TAG_UTIL.outputs.extVersion }}\",#g" packages/api/package.json
72+
sed -i "s#version\":\ \"\(.*\)\",#version\":\ \"${{ steps.TAG_UTIL.outputs.extVersion }}\",#g" tests/playwright/package.json
7273
sed -i "s#\(ghcr.io/podman-desktop/podman-desktop-extension-kubernetes-dashboard-builder:\)next#\1${{ steps.TAG_UTIL.outputs.extVersion }}#g" build/Containerfile
7374
74-
git add package.json packages/extension/package.json packages/webview/package.json build/Containerfile
75+
git add package.json packages/extension/package.json packages/webview/package.json packages/api/package.json tests/playwright/package.json build/Containerfile
7576
7677
# commit the changes
7778
git commit -m "chore: 🥁 tagging ${{ steps.TAG_UTIL.outputs.githubTag }} 🥳"
@@ -102,9 +103,11 @@ jobs:
102103
sed -i "s#version\":\ \"\(.*\)\",#version\":\ \"${bumpedVersion}-next\",#g" package.json
103104
sed -i "s#version\":\ \"\(.*\)\",#version\":\ \"${bumpedVersion}-next\",#g" packages/extension/package.json
104105
sed -i "s#version\":\ \"\(.*\)\",#version\":\ \"${bumpedVersion}-next\",#g" packages/webview/package.json
106+
sed -i "s#version\":\ \"\(.*\)\",#version\":\ \"${bumpedVersion}-next\",#g" packages/api/package.json
107+
sed -i "s#version\":\ \"\(.*\)\",#version\":\ \"${bumpedVersion}-next\",#g" tests/playwright/package.json
105108
# put back next as the version in the Containerfile
106109
sed -i "s|\(ghcr.io/podman-desktop/podman-desktop-extension-kubernetes-dashboard-builder:\)[^ ]*|\1next|" build/Containerfile
107-
git add package.json packages/extension/package.json packages/webview/package.json build/Containerfile
110+
git add package.json packages/extension/package.json packages/webview/package.json packages/api/package.json tests/playwright/package.json build/Containerfile
108111
109112
git commit -s --amend -m "chore: bump version to ${bumpedVersion}"
110113
git push origin "${bumpedBranchName}"

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,9 @@ You can now make changes to the sources. The project is composed of two parts, w
5959
> Note that when you only change code in the webview part, the webview is built, and the result is included in the extension, which triggers the rebuild of the extension.
6060
6161
After each change, you may have to restart the extension from the `Extensions > Local Extensions` page.
62+
63+
## Running e2e tests
64+
65+
### On the CI
66+
67+
When creating a PR on the GitHub repository, the e2e tests are not executed by default. To run the e2e tests, you need to add the `ci/e2e` label to the PR.

build/Containerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ WORKDIR /opt/app-root/extension-source
2121

2222
# copy source code
2323
COPY --chown=1001:root *.ts /opt/app-root/extension-source/
24-
COPY --chown=1001:root pnpm-workspace.yaml /opt/app-root/extension-source/
24+
COPY --chown=1001:root pnpm-workspace.yaml /opt/app-root/extension-source/pnpm-workspace.yaml
2525
COPY --chown=1001:root pnpm-lock.yaml /opt/app-root/extension-source/
2626
COPY --chown=1001:root .gitignore /opt/app-root/extension-source/
2727
COPY --chown=1001:root package.json /opt/app-root/extension-source/
@@ -54,7 +54,7 @@ RUN echo "node-linker=hoisted" >> /opt/app-root/extension/.npmrc
5454
RUN eval 'dep_version() { pnpm list -P $1 --json --depth 0 |jq -r ".[0].dependencies.\"$1\".version"; };' && \
5555
ISOMORPHIC_WS_VERSION=$(dep_version "isomorphic-ws") && \
5656
echo adding isomorphic-ws version ${ISOMORPHIC_WS_VERSION} && \
57-
pnpm --dir /opt/app-root/extension add isomorphic-ws@${ISOMORPHIC_WS_VERSION} --prod
57+
pnpm --dir /opt/app-root/extension --workspace-root add isomorphic-ws@${ISOMORPHIC_WS_VERSION} --prod
5858

5959
# Copy the extension to a new image
6060
FROM scratch

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
"test:webview": "vitest run --project webview --passWithNoTests",
2424
"test:channels": "vitest run --project channels --passWithNoTests",
2525
"test": "pnpm run test:extension && pnpm run test:webview && pnpm run test:channels",
26+
"test:e2e": "cd tests/playwright && npm run test:e2e",
27+
"test:e2e:smoke": "cd tests/playwright && npm run test:e2e:smoke",
2628
"typecheck:rpc": "tsc --noEmit --project packages/rpc",
2729
"typecheck:channels": "tsc --noEmit --project packages/channels",
2830
"typecheck:webview": "tsc --noEmit --project packages/webview",

0 commit comments

Comments
 (0)