Skip to content

Commit 8011db0

Browse files
feat: add playwright skeleton
Signed-off-by: Carlos Feria <[email protected]>
1 parent bde872b commit 8011db0

File tree

12 files changed

+504
-25
lines changed

12 files changed

+504
-25
lines changed

.env

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
CONSOLE_IMAGE=quay.io/securesign/rhtas-console@sha256:75966d60ed709af33efd48c53b96ea7b2fcd4608f90ccc56885bf224e34b55f5
2-
CONSOLE_UI_IMAGE=quay.io/securesign/rhtas-console-ui@sha256:c0b0b2d76548c05efadb2425baf93609cf6c40180f170cb531fbb7689a91db31
3-
CONSOLE_DB_IMAGE=registry.redhat.io/rhel9/mariadb-105@sha256:050dd5a7a32395b73b8680570e967e55050b152727412fdd73a25d8816e62d53
1+
CONSOLE_IMAGE=ghcr.io/securesign/rhtas-console:latest
2+
CONSOLE_UI_IMAGE=ghcr.io/securesign/rhtas-console-ui:latest
3+
CONSOLE_DB_IMAGE=docker.io/library/mariadb:10.5
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Start console
2+
description: Start console using docker compose.
3+
inputs:
4+
ui_image:
5+
description: image uri for the ui (ie. ghcr.io/<namespace>/<image-name>:<tag>)
6+
type: string
7+
required: false
8+
default: ""
9+
server_image:
10+
description: image uri for the server (ie. ghcr.io/<namespace>/<image-name>:<tag>)
11+
type: string
12+
required: false
13+
default: ""
14+
server_db_image:
15+
description: image uri for server-postgres (ie. ghcr.io/<namespace>/<image-name>:<tag>)
16+
type: string
17+
required: false
18+
default: ""
19+
playwright_version:
20+
description: version of the playwright image to run
21+
type: string
22+
required: false
23+
default: ""
24+
outputs:
25+
server_port:
26+
description: Port where the server is running
27+
value: ${{ steps.set-output.outputs.server_port }}
28+
ui_port:
29+
description: Port where the UI is running
30+
value: ${{ steps.set-output.outputs.ui_port }}
31+
playwright_port:
32+
description: Port where the UI is running
33+
value: ${{ steps.set-output.outputs.playwright_port }}
34+
runs:
35+
using: "composite"
36+
steps:
37+
- name: Start console
38+
working-directory: ${{ github.action_path }}/../../..
39+
shell: bash
40+
run: |
41+
opts=""
42+
43+
if [ -n "${{ inputs.server_image }}" ]; then
44+
opts="${opts} CONSOLE_IMAGE=${{ inputs.server_image }}"
45+
fi
46+
if [ -n "${{ inputs.ui_image }}" ]; then
47+
opts="${opts} CONSOLE_UI_IMAGE=${{ inputs.ui_image }}"
48+
fi
49+
if [ -n "${{ inputs.server_db_image }}" ]; then
50+
opts="${opts} POSTGRESQL_IMAGE=${{ inputs.server_db_image }}"
51+
fi
52+
53+
if [ -n "${{ inputs.playwright_version }}" ]; then
54+
opts="${opts} PLAYWRIGHT_VERSION=${{ inputs.playwright_version }}"
55+
fi
56+
57+
echo "opts: $opts"
58+
59+
eval "${opts} docker compose up -d"
60+
61+
- name: Wait for services to be ready
62+
shell: bash
63+
run: |
64+
# Wait for backend
65+
until curl -s http://localhost:8087/healthz | jq -e '.status == "ok"' >/dev/null 2>&1; do
66+
echo "Waiting for healthy service response on port 8087..."
67+
sleep 2
68+
done
69+
70+
# Wait for ui
71+
until curl -s http://localhost:8088 | grep -qi "<html"; do
72+
echo "Waiting for HTML page on port 8088..."
73+
sleep 2
74+
done
75+
76+
- id: set-output
77+
shell: bash
78+
run: |
79+
echo "server_port=8087" >> $GITHUB_OUTPUT
80+
echo "ui_port=8088" >> $GITHUB_OUTPUT
81+
echo "playwright_port=5000" >> $GITHUB_OUTPUT
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
name: Run e2e RHTAS Console CI tests
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
artifact:
7+
description: |
8+
The name of the component being tested, ie server etc.
9+
Must correspond to an artifact storing the custom built image, named <artifact>,
10+
and should contain the file <artifact>.tar inside.
11+
required: false
12+
type: string
13+
ui_image:
14+
description: image uri for the ui (ie. ghcr.io/<namespace>/<image-name>:<tag>)
15+
type: string
16+
required: false
17+
default: ""
18+
server_image:
19+
description: image uri for the server (ie. ghcr.io/<namespace>/<image-name>:<tag>)
20+
type: string
21+
required: false
22+
default: ""
23+
server_db_image:
24+
description: image uri for server-postgres (ie. ghcr.io/<namespace>/<image-name>:<tag>)
25+
type: string
26+
required: false
27+
default: ""
28+
workflow_dispatch:
29+
inputs:
30+
artifact:
31+
description: |
32+
The name of the component being tested, ie server etc.
33+
Must correspond to an artifact storing the custom built image, named <artifact>,
34+
and should contain the file <artifact>.tar inside.
35+
required: false
36+
type: string
37+
ui_image:
38+
description: image uri for the ui (ie. ghcr.io/<namespace>/<image-name>:<tag>)
39+
type: string
40+
required: false
41+
default: ""
42+
server_image:
43+
description: image uri for the server (ie. ghcr.io/<namespace>/<image-name>:<tag>)
44+
type: string
45+
required: false
46+
default: ""
47+
server_db_image:
48+
description: image uri for server-postgres (ie. ghcr.io/<namespace>/<image-name>:<tag>)
49+
type: string
50+
required: false
51+
default: ""
52+
53+
jobs:
54+
check-images:
55+
runs-on: ubuntu-latest
56+
steps:
57+
- name: Download artifact
58+
if: "${{ inputs.artifact != '' }}"
59+
uses: actions/download-artifact@v5
60+
with:
61+
name: ${{ inputs.artifact }}
62+
path: /tmp
63+
- name: Load images
64+
if: ${{ inputs.artifact != '' }}
65+
run: |
66+
docker load --input /tmp/${{ inputs.artifact }}.tar
67+
- name: Check ui image exists
68+
if: ${{ inputs.ui_image != '' }}
69+
run: |
70+
if docker image inspect ${{ inputs.ui_image }} >/dev/null 2>&1; then
71+
echo "Image exists locally"
72+
docker image inspect ${{ inputs.ui_image }}
73+
else
74+
echo "Image does not exist locally"
75+
docker manifest inspect ${{ inputs.ui_image }}
76+
fi
77+
- name: Check server image exists
78+
if: ${{ inputs.server_image != '' }}
79+
run: |
80+
if docker image inspect ${{ inputs.server_image }} >/dev/null 2>&1; then
81+
echo "Image exists locally"
82+
docker image inspect ${{ inputs.server_image }}
83+
else
84+
echo "Image does not exist locally"
85+
docker manifest inspect ${{ inputs.server_image }}
86+
fi
87+
- name: Check server_db_image image exists
88+
if: ${{ inputs.server_db_image != '' }}
89+
run: |
90+
if docker image inspect ${{ inputs.server_db_image }} >/dev/null 2>&1; then
91+
echo "Image exists locally"
92+
docker image inspect ${{ inputs.server_db_image }}
93+
else
94+
echo "Image does not exist locally"
95+
docker manifest inspect ${{ inputs.server_db_image }}
96+
fi
97+
98+
e2e-integration-tests:
99+
needs: check-images
100+
runs-on: ubuntu-latest
101+
steps:
102+
- name: Download artifact
103+
if: "${{ inputs.artifact != '' }}"
104+
uses: actions/download-artifact@v5
105+
with:
106+
name: ${{ inputs.artifact }}
107+
path: /tmp
108+
- name: Load images
109+
if: ${{ inputs.artifact != '' }}
110+
run: |
111+
docker load --input /tmp/${{ inputs.artifact }}.tar
112+
113+
- name: Checkout ui repo
114+
uses: actions/checkout@v5
115+
- uses: actions/setup-node@v4
116+
with:
117+
node-version: 22
118+
cache: "npm"
119+
- name: Install dependencies
120+
run: npm ci --verbose --ignore-scripts --no-audit
121+
122+
- name: Start rhtas-console
123+
uses: ./.github/actions/start-console
124+
with:
125+
ui_image: ${{ inputs.ui_image }}
126+
server_image: ${{ inputs.server_image }}
127+
server_db_image: ${{ inputs.server_db_image }}
128+
129+
- name: Run Playwright tests
130+
run: |
131+
PW_TEST_CONNECT_WS_ENDPOINT=ws://localhost:5000/ CONSOLE_UI_URL=http://localhost:8088 AUTH_REQUIRED=false npm run -w e2e test
132+
133+
- name: Upload Playwright artifacts
134+
if: failure() # only upload if tests failed
135+
uses: actions/upload-artifact@v4
136+
with:
137+
name: playwright-artifacts
138+
path: |
139+
e2e/test-results
140+
e2e/playwright-report

.github/workflows/ci-e2e.yaml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: CI (e2e)
2+
3+
on:
4+
push:
5+
branches:
6+
- "main"
7+
- "release/*"
8+
pull_request:
9+
branches:
10+
- "main"
11+
- "release/*"
12+
workflow_call:
13+
merge_group:
14+
15+
concurrency:
16+
group: ci-e2e-${{ github.ref }}
17+
cancel-in-progress: true
18+
19+
jobs:
20+
build-and-upload-for-e2e-ci:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v5
24+
25+
- name: save rhtas-console-ui image
26+
run: |
27+
docker build . -t ghcr.io/securesign/rhtas-console-ui:pr-test -f Dockerfile
28+
docker save -o /tmp/rhtas-console-ui.tar ghcr.io/securesign/rhtas-console-ui:pr-test
29+
30+
- name: Upload console-ui image as artifact
31+
uses: actions/upload-artifact@v4
32+
with:
33+
name: rhtas-console-ui
34+
path: /tmp/rhtas-console-ui.tar
35+
retention-days: 1
36+
37+
discover-envs-for-e2e-ci:
38+
runs-on: ubuntu-latest
39+
outputs:
40+
image_tag: ${{ steps.set-outputs.outputs.image_tag }}
41+
steps:
42+
- name: Extract vars for Pull Request
43+
shell: bash
44+
if: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }}
45+
env:
46+
base_ref: ${{ github.event.pull_request.base.ref || github.event.merge_group.base_ref }}
47+
run: |
48+
branch=$base_ref
49+
branch=$(echo ${branch#refs/heads/})
50+
image_tag="latest"
51+
if [[ "$branch" != "main" ]]; then
52+
image_tag="${branch#release/}"
53+
fi
54+
echo "image_tag=$image_tag" >> $GITHUB_ENV
55+
- name: Extract vars for Push
56+
shell: bash
57+
if: ${{ github.event_name != 'pull_request' && github.event_name != 'merge_group' }}
58+
run: |
59+
branch=$(echo ${GITHUB_REF#refs/heads/})
60+
image_tag="latest"
61+
if [[ "$branch" != "main" ]]; then
62+
image_tag="${branch#release/}"
63+
fi
64+
echo "image_tag=$image_tag" >> $GITHUB_ENV
65+
- name: Set outputs
66+
id: set-outputs
67+
run: |
68+
echo ${{ env.image_tag }}
69+
echo "image_tag=${{ env.image_tag }}" >> "$GITHUB_OUTPUT"
70+
71+
run-e2e-ci:
72+
needs:
73+
- build-and-upload-for-e2e-ci
74+
- discover-envs-for-e2e-ci
75+
uses: ./.github/workflows/ci-e2e-template.yaml
76+
with:
77+
artifact: rhtas-console-ui
78+
ui_image: ghcr.io/securesign/rhtas-console-ui:pr-test
79+
server_image: ghcr.io/securesign/rhtas-console:${{ needs.discover-envs-for-e2e-ci.outputs.image_tag }}

README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ npm run start
5858
| --------------- | ----------------------------- | -------------------------------------- |
5959
| MOCK | Enables or disables mock data | `off` |
6060
| AUTH_REQUIRED | Enable/Disable authentication | false |
61+
| CONSOLE_API_URL | Enable/Disable authentication | http://localhost:8080 |
6162
| OIDC_CLIENT_ID | Set Oidc Client | frontend |
6263
| OIDC_SERVER_URL | Set Oidc Server URL | `http://localhost:8090/realms/console` |
6364
| OIDC_SCOPE | Set Oidc Scope | openid |
@@ -90,7 +91,7 @@ podman run -it $BASE_IMAGE cat /etc/yum.repos.d/ubi.repo > ubi.repo
9091

9192
Make sure the `ubi.repo` file has all repositories enabled `enabled = 1` and then:
9293

93-
Also make sure the `ubi.repo` contains only repositories from https://github.com/release-engineering/rhtap-ec-policy/blob/main/data/known_rpm_repositories.yml . Change the repository names manually if needed. E.g.
94+
Also make sure the `ubi.repo` contains only repositories from https://github.com/release-engineering/rhtap-ec-policy/blob/main/data/known_rpm_repositories.yml . Change the repository names manually if needed. E.g.
9495

9596
- `ubi-9-for-baseos-rpms` change it to `ubi-9-for-x86_64-baseos-rpms` as only the latter is an accepted repository in Konflux.
9697

@@ -128,13 +129,14 @@ The `overlays/dev/` directory contains a `kustomization.yaml` for environment-sp
128129
1. **Set TUF_REPO_URL using a ConfigMap**:
129130

130131
Before deploying, you need to retrieve the TUF repository URL from your running RHTAS instance. This value should be stored in a ConfigMap that the console backend can consume.
131-
132-
* Retrieve the TUF route URL from your running RHTAS instance:
132+
- Retrieve the TUF route URL from your running RHTAS instance:
133+
133134
```bash
134135
oc get tuf -o jsonpath='{.items[0].status.url}'
135136
```
136-
137-
* Create a ConfigMap with the retrieved URL:
137+
138+
- Create a ConfigMap with the retrieved URL:
139+
138140
```bash
139141
oc create configmap tuf-repo-config \
140142
--from-literal=TUF_REPO_URL=<output-from-above-command> \
@@ -151,7 +153,7 @@ The `overlays/dev/` directory contains a `kustomization.yaml` for environment-sp
151153
oc apply -k https://github.com/securesign/rhtas-console-ui/deployment/overlays/dev?ref=v0.1.0
152154
```
153155

154-
4. **Verify the Deployment**:
156+
3. **Verify the Deployment**:
155157

156158
Check the status of the deployed resources:
157159

@@ -160,11 +162,12 @@ The `overlays/dev/` directory contains a `kustomization.yaml` for environment-sp
160162
```
161163

162164
You can access the console via a browser using the UI route:
165+
163166
```bash
164167
oc get route console-ui -o jsonpath='https://{.spec.host}{"\n"}'
165168
```
166169

167-
5. **Deletion**:
170+
4. **Deletion**:
168171

169172
To delete the deployed resources:
170173

docker-compose.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,15 @@ services:
4343
depends_on:
4444
console:
4545
condition: service_started
46+
47+
playwright:
48+
image: mcr.microsoft.com/playwright:v1.56.1-jammy
49+
ports:
50+
- "5000:5000"
51+
network_mode: host
52+
working_dir: /home/pwuser
53+
command:
54+
- /bin/sh
55+
- -c
56+
- npx -y playwright run-server --port 5000
57+

e2e/.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
# Playwright
3+
node_modules/
4+
/test-results/
5+
/playwright-report/
6+
/blob-report/
7+
/playwright/.cache/
8+
/playwright/.auth/

0 commit comments

Comments
 (0)