Skip to content

Commit 715bce0

Browse files
committed
fix
Signed-off-by: Philippe Martin <[email protected]>
1 parent fdcb036 commit 715bce0

File tree

5 files changed

+228
-404
lines changed

5 files changed

+228
-404
lines changed

.github/workflows/e2e-tests.yaml

Lines changed: 128 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -15,34 +15,74 @@
1515
#
1616
# SPDX-License-Identifier: Apache-2.0
1717

18-
name: pr-check
19-
20-
permissions:
21-
contents: read
18+
name: e2e-tests
2219

2320
on: [pull_request]
2421

2522
jobs:
26-
e2e-tests:
27-
name: e2e tests
23+
# Dedicated step to build the extension image
24+
build-container:
25+
name: Build Extension Image
2826
runs-on: ubuntu-24.04
29-
strategy:
30-
fail-fast: true
3127
steps:
3228
- uses: actions/checkout@v6
29+
- name: Build Image and Extract Files
30+
id: build-image
31+
run: |
32+
podman build -t local_image -f build/Containerfile ./
33+
CONTAINER_ID=$(podman create localhost/local_image --entrypoint "")
34+
mkdir -p output/plugins
35+
podman export $CONTAINER_ID | tar -x -C output/plugins/
36+
podman rm -f $CONTAINER_ID
37+
podman rmi -f localhost/local_image:latest
38+
- name: Upload Extension Image Artifact
39+
uses: actions/upload-artifact@v5
3340
with:
34-
path: kubernetes-dashboard
41+
name: extension-plugin
42+
path: output/plugins/
3543

36-
- uses: pnpm/action-setup@v4
37-
name: Install pnpm
38-
with:
39-
run_install: false
40-
package_json_file: ./kubernetes-dashboard/package.json
44+
e2e-pr-check:
45+
name: e2e tests smoke / ${{ matrix.os }}
46+
needs: build-container
47+
runs-on: ${{ matrix.os }}
48+
strategy:
49+
fail-fast: true
50+
matrix:
51+
os: [ windows-2022, ubuntu-24.04 ]
52+
env:
53+
SKIP_INSTALLATION: true
54+
EXTENSION_PREINSTALLED: true
55+
PODMAN_DESKTOP_ARGS: ${{ github.workspace }}/podman-desktop
56+
# by default playwright cache browsers binaries in ~/.cache/ms-playwright on Linux and %USERPROFILE%\AppData\Local\ms-playwright on Windows
57+
PLAYWRIGHT_BROWSERS_PATH: ${{ github.workspace }}/podman-desktop/pw-browsers
58+
steps:
59+
- uses: actions/checkout@v6
4160

42-
- uses: actions/setup-node@v6
43-
with:
44-
node-version: 22
61+
# ==============================================
62+
# Installing Podman
63+
# ==============================================
64+
- name: Install podman to 5.x
65+
if: runner.os == 'Windows'
66+
shell: pwsh
67+
run: |
68+
echo Installing Podman
69+
curl --output .\podman-setup.exe -L https://github.com/containers/podman/releases/download/v5.3.2/podman-5.3.2-setup.exe
70+
# Start the installer and wait for it to complete
71+
Start-Process -FilePath .\podman-setup.exe -ArgumentList "/install", "/passive", "/norestart", "/log podman-logs.txt" -Wait
72+
# Check the logs for debugging purposes
73+
Get-Content podman-logs.txt
74+
75+
# Init Podman Machine
76+
- name: Init Podman Machine (Windows)
77+
if: runner.os == 'Windows'
78+
shell: pwsh
79+
run: |
80+
echo "Adding Podman to PATH"
81+
$env:PATH += ";C:\Program Files\RedHat\Podman"
82+
podman --version
83+
podman machine init --now
4584
85+
# Update Podman linux
4686
- name: Update podman to 5.x
4787
if: runner.os == 'Linux'
4888
run: |
@@ -65,18 +105,6 @@ jobs:
65105
sudo apt-get -y install podman; }
66106
podman version
67107
68-
- name: Set default browser desktop app and handlers
69-
run: |
70-
xdg-settings set default-web-browser firefox.desktop
71-
xdg-mime default firefox.desktop x-scheme-handler/https
72-
xdg-mime default firefox.desktop x-scheme-handler/http
73-
xvfb-run xdg-open 'https://developers.redhat.com/articles/faqs-no-cost-red-hat-enterprise-linux#general' & sleep 5; pkill Xvfb
74-
75-
# Install dbus-x11 package to allow dbus session for user for particular display (xvfb-maybe used in e2e test)
76-
# for reference, similar issue: https://github.com/actions/runner-images/issues/12127
77-
- name: Install dbus-x11 package
78-
run: sudo apt-get install dbus-x11
79-
80108
- name: Revert unprivileged user namespace restrictions in Ubuntu 24.04
81109
if: runner.os == 'Linux'
82110
run: |
@@ -93,48 +121,86 @@ jobs:
93121
EOT
94122
podman info
95123
96-
- name: Set Chromium policy for Podman Desktop app redirection from browser
124+
# ==============================================
125+
# Installing Podman Desktop
126+
# ==============================================
127+
- uses: pnpm/action-setup@v4
128+
name: Install pnpm
129+
with:
130+
run_install: false
131+
132+
# Install Node.js
133+
- uses: actions/setup-node@v6
134+
with:
135+
node-version: 22
136+
cache: 'pnpm'
137+
138+
# Install npm packages for extension
139+
- name: Execute pnpm in Extension
140+
run: pnpm install
141+
142+
# Extract @podman-desktop/api version used (and store to $GITHUB_OUTPUT)
143+
- name: Extract @podman-desktop/api version
144+
id: pd-api-version
145+
shell: bash
97146
run: |
98-
echo '{"URLAllowlist": ["podman-desktop:*"]}' > url_allow_list.json
99-
sudo mkdir -p /etc/chromium/policies/managed
100-
sudo cp url_allow_list.json /etc/chromium/policies/managed/url_allow_list.json
147+
# Using pnpm list to get the resolved version (E.g. getting 1.15.0 when ^1.15.0)
148+
export PD_VERSION=$(pnpm list -C packages/extension/ --json | jq -r '.[0].devDependencies."@podman-desktop/api".version')
149+
echo "PD_VERSION=$PD_VERSION" >> $GITHUB_OUTPUT
150+
echo "Using @podman-desktop/api $PD_VERSION"
151+
152+
# Check cache for existing podman-desktop
153+
- name: Cache Podman Desktop
154+
id: cache-pd
155+
uses: actions/cache@v4
156+
with:
157+
path: ${{ github.workspace }}/podman-desktop
158+
key: pd-${{ steps.pd-api-version.outputs.PD_VERSION }}-${{ runner.os }}
101159

160+
# Download Podman Desktop repository based on version defined in package.json
102161
- name: Download Podman Desktop
162+
if: steps.cache-pd.outputs.cache-hit != 'true'
103163
shell: bash
164+
env:
165+
PD_VERSION: ${{ steps.pd-api-version.outputs.PD_VERSION }}
104166
run: |
105-
PD_VERSION=1.24.0-202512010926-c9f179c28b7
106167
echo "Downloading PD desktop to ${{ github.workspace }}/podman-desktop"
107-
curl -sL "https://github.com/podman-desktop/testing-prereleases/releases/download/v${PD_VERSION}/podman-desktop-${PD_VERSION}.tar.gz" | tar xvz
168+
# Stable release are available podman-desktop/podman-desktop
169+
# Prerelease are available under podman-desktop/prereleases
170+
if [[ "$PD_VERSION" =~ - ]]; then
171+
curl -sL "https://github.com/podman-desktop/prereleases/archive/refs/tags/v$PD_VERSION.tar.gz" | tar xvz
172+
else
173+
curl -sL "https://github.com/podman-desktop/podman-desktop/archive/refs/tags/v$PD_VERSION.tar.gz" | tar xvz
174+
fi
108175
# Move the extracted folder to the podman-desktop folder
109-
mv podman-desktop-${PD_VERSION}/ podman-desktop/
110-
echo "PODMAN_DESKTOP_BINARY_PATH=$(pwd)/podman-desktop/podman-desktop" >> $GITHUB_ENV
111-
112-
- name: Execute pnpm in extension
113-
working-directory: ./kubernetes-dashboard
114-
run: pnpm install --no-frozen-lockfile
176+
mv podman-desktop-$PD_VERSION/ podman-desktop/
115177
116-
- name: Build Image
117-
working-directory: ./kubernetes-dashboard
118-
id: build-image
178+
# Install and build podman-desktop
179+
- name: Install pnpm deps and build Podman Desktop
180+
if: steps.cache-pd.outputs.cache-hit != 'true'
181+
shell: bash
182+
working-directory: ${{ github.workspace }}/podman-desktop
119183
run: |
120-
pnpm build
121-
podman build -t local_extension_image -f build/Containerfile ./
122-
CONTAINER_ID=$(podman create localhost/local_extension_image --entrypoint "")
123-
mkdir -p tests/extension_sources/
124-
podman export $CONTAINER_ID | tar -x -C tests/extension_sources/
125-
podman rm -f $CONTAINER_ID
126-
podman rmi -f localhost/local_extension_image:latest
184+
pnpm install
185+
pnpm test:e2e:build
127186
128-
- name: show extension files
129-
working-directory: ./kubernetes-dashboard
130-
run: |
131-
ls -laR tests/extension_sources/
187+
# Install the extension
188+
- name: Download Extension Plugin
189+
uses: actions/download-artifact@v6
190+
with:
191+
name: extension-plugin
192+
path: tests/playwright/tests/playwright/output/kubernetes-dashboard-tests/plugins/
132193

133-
- name: Execute e2e tests
134-
working-directory: ./kubernetes-dashboard/tests/playwright
194+
- name: Run E2E Smoke tests
195+
shell: bash
196+
run: pnpm test:e2e:smoke
135197
env:
136-
PODMAN_DESKTOP_BINARY: ${{ env.PODMAN_DESKTOP_BINARY_PATH }}
137-
run: |
138-
dbus-launch
139-
export $(dbus-launch)
140-
pnpm test:e2e
198+
NODE_OPTIONS: --no-experimental-strip-types
199+
200+
- uses: actions/upload-artifact@v5
201+
if: always()
202+
with:
203+
name: e2e-pr-check-${{ matrix.os }}
204+
path: |
205+
tests/playwright/output/
206+
tests/playwright/tests/

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",

tests/playwright/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"description": "Kubernetes Dashboard extension Playwright E2E tests",
55
"scripts": {
66
"test:e2e:setup": "xvfb-maybe --auto-servernum --server-args='-screen 0 1280x960x24' --",
7-
"test:e2e": "npm run test:e2e:setup playwright test src/"
7+
"test:e2e": "npm run test:e2e:setup playwright test src/",
8+
"test:e2e:smoke": "npm run test:e2e:setup playwright test src/ --grep @smoke"
89
},
910
"publisher": "redhat",
1011
"license": "Apache-2.0",

0 commit comments

Comments
 (0)