Skip to content

Commit bbd02de

Browse files
Merge branch 'main' into fix/filter-date
2 parents bb57bb6 + 9d94f09 commit bbd02de

File tree

111 files changed

+8696
-139
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+8696
-139
lines changed

.devcontainer/Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Image tag should match package.json > @playwright/test
2+
FROM mcr.microsoft.com/playwright:v1.55.0-jammy
3+
4+
RUN apt update && \
5+
apt install sudo && \
6+
usermod -aG sudo pwuser && \
7+
echo "%sudo ALL=(ALL) NOPASSWD:ALL" | tee -a /etc/sudoers > /dev/null
8+
9+
RUN chown pwuser:pwuser -R /home/pwuser
10+
USER pwuser

.devcontainer/README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Devcontainers
2+
3+
Use [Devcontainers](https://code.visualstudio.com/docs/devcontainers/containers) to prepare a fully automated working environment.
4+
5+
Generate the `devcontainer.json` executing:
6+
7+
```shell
8+
cd .devcontainer
9+
./generate_devcontainer.sh
10+
```
11+
12+
Now you should see the file `.devcontainer/devcontainer.json`. At this point you can use your favorite IDE to run Devcontainers
13+
14+
## VSCode
15+
16+
Install the extension https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers
17+
18+
To open the repository with DevContainers do `Ctrl + Shift + P` and enter `Dev Containers: Rebuild and Reopen in Container`. For more options see the Extension documentations.
19+
20+
### Docker
21+
22+
Docker defaults should work fine therefore there is nothing to do.
23+
24+
### Podman
25+
26+
Start Podman service for a regular user (rootless) and make it listen to a socket:
27+
28+
```shell
29+
systemctl --user enable --now podman.socket
30+
```
31+
32+
Restart your OS if necessary and verify that podman listens:
33+
34+
```shell
35+
systemctl --user status podman.socket
36+
```
37+
38+
Go to the Extension Settings:
39+
40+
- `Dev › Containers: Docker Compose Path` set `podman-compose`
41+
- `Dev › Containers: Docker Path` set `podman`
42+
- `Dev › Containers: Docker Socket Path` set `/run/podman/podman.sock`
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
HOSTNAME=$(hostname)
4+
envsubst '${HOSTNAME}' < template.json > devcontainer.json

.devcontainer/template.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "playwright",
3+
"image": "mcr.microsoft.com/playwright:v1.55.0-jammy",
4+
"workspaceFolder": "/workspaces/trustify-ui/e2e",
5+
"runArgs": [
6+
"--privileged",
7+
"--userns=keep-id",
8+
"--network=host",
9+
"--add-host=${HOSTNAME}:127.0.0.1",
10+
"-e DISPLAY=:2"
11+
],
12+
"remoteUser": "pwuser",
13+
"features": {
14+
"ghcr.io/devcontainers/features/desktop-lite:1": {
15+
"VNC_RESOLUTION": "1920x1200x16"
16+
}
17+
},
18+
"forwardPorts": [6080, 5901],
19+
"portsAttributes": {
20+
"6080": {
21+
"label": "browser vnc"
22+
},
23+
"5901": {
24+
"label": "real vnc"
25+
}
26+
},
27+
"customizations": {
28+
"vscode": {
29+
"extensions": [
30+
"ms-playwright.playwright"
31+
]
32+
}
33+
}
34+
}

.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ TRUSTIFY_UI_IMAGE=ghcr.io/trustification/trustify-ui:latest
44
POSTGRESQL_IMAGE=postgres:16
55

66
PLAYWRIGHT_IMAGE=mcr.microsoft.com/playwright
7-
PLAYWRIGHT_VERSION=v1.49.1
7+
PLAYWRIGHT_VERSION=v1.55.0
88
UBUNTU_VERSION_ALIAS=-jammy
99
PLAYWRIGHT_PORT=5000
1010
PLAYWRIGHT_HOME=/home/pwuser

.github/actions/start-trustify/action.yml

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ inputs:
1616
type: string
1717
required: false
1818
default: ""
19+
playwright_version:
20+
description: version of the playwright image to run
21+
type: string
22+
required: false
23+
default: ""
1924
outputs:
2025
server_port:
2126
description: Port where the server is running
@@ -33,18 +38,25 @@ runs:
3338
working-directory: ${{ github.action_path }}/../../..
3439
shell: bash
3540
run: |
36-
images=""
41+
opts=""
42+
3743
if [ -n "${{ inputs.server_image }}" ]; then
38-
images="${images} TRUSTIFY_IMAGE=${{ inputs.server_image }}"
39-
elif [ -n "${{ inputs.ui_image }}" ]; then
40-
images="${images} TRUSTIFY_UI_IMAGE=${{ inputs.ui_image }}"
41-
elif [ -n "${{ inputs.server_db_image }}" ]; then
42-
images="${images} POSTGRESQL_IMAGE=${{ inputs.server_db_image }}"
44+
opts="${opts} TRUSTIFY_IMAGE=${{ inputs.server_image }}"
45+
fi
46+
if [ -n "${{ inputs.ui_image }}" ]; then
47+
opts="${opts} TRUSTIFY_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 }}"
4355
fi
4456
45-
echo "images to overwrite: $images"
57+
echo "opts: $opts"
4658
47-
eval "${images} docker compose up -d"
59+
eval "${opts} docker compose up -d"
4860
4961
- name: Wait for services to be ready
5062
shell: bash
@@ -55,7 +67,7 @@ runs:
5567
sleep 2
5668
done
5769
done
58-
70+
5971
- id: set-output
6072
shell: bash
6173
run: |

.github/workflows/ci-coverage.yaml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: CI Coverage
2+
3+
on:
4+
push:
5+
branches:
6+
- "main"
7+
pull_request:
8+
branches:
9+
- "main"
10+
workflow_call:
11+
merge_group:
12+
13+
concurrency:
14+
group: ci-coverage-e2e-${{ github.ref }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
coverage:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
- uses: actions/setup-node@v4
23+
with:
24+
node-version: 22
25+
cache: npm
26+
- name: install dependencies
27+
run: npm ci
28+
29+
- name: install trustify
30+
id: install-trustify
31+
uses: ./.github/actions/start-trustify
32+
with:
33+
ui_image: ${{ inputs.ui_image }}
34+
server_image: ${{ inputs.server_image }}
35+
server_db_image: ${{ inputs.server_db_image }}
36+
37+
- name: trustify-ui - start in dev mode
38+
run: |
39+
AUTH_REQUIRED=false npm run start:dev & echo "dev ui started"
40+
- name: trustify-ui - wait
41+
run: |
42+
until curl -s http://localhost:3000 | grep -qi "<html"; do
43+
echo "Waiting for HTML page"
44+
sleep 2
45+
done
46+
47+
- name: Tests with coverage
48+
working-directory: e2e
49+
run: |
50+
PW_TEST_CONNECT_WS_ENDPOINT=ws://localhost:${{ steps.install-trustify.outputs.playwright_port }}/ TRUSTIFY_UI_URL=http://localhost:3000 AUTH_REQUIRED=false npm run test:ui
51+
ls -la .nyc_output
52+
53+
- name: Generate coverage report
54+
run: |
55+
npx nyc report --temp-dir e2e/.nyc_output --reporter=html --reporter=text --reporter=lcov
56+
- name: Upload coverage report
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: coverage-report
60+
path: coverage
61+
- name: Upload coverage reports to Codecov
62+
uses: codecov/codecov-action@v5
63+
with:
64+
token: ${{ secrets.CODECOV_TOKEN }}
65+
slug: trustification/trustify-ui

.github/workflows/ci-global-template.yaml renamed to .github/workflows/ci-e2e-template.yaml

Lines changed: 12 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Run global Trustify CI tests
1+
name: Run e2e Trustify CI tests
22

33
on:
44
workflow_call:
@@ -37,18 +37,6 @@ on:
3737
type: boolean
3838
required: false
3939
default: true
40-
tests_ref:
41-
description: |
42-
The branch or PR of the trustify-tests repository to clone.
43-
For a pull request, the reference format would be "refs/pull/${PR_NUMBER}/merge".
44-
For a branch, the reference format would just be the branch name.
45-
This input can be set automatically on a pull request by adding a string of the format:
46-
UI tests PR: 140
47-
replacing "140" with the appropriate PR number. This will make it easier to coordinate changes
48-
that require updating the global tests as well.
49-
required: false
50-
type: string
51-
default: main
5240
workflow_dispatch:
5341
inputs:
5442
artifact:
@@ -85,26 +73,14 @@ on:
8573
type: boolean
8674
required: false
8775
default: true
88-
tests_ref:
89-
description: |
90-
The branch or PR of the trustify-tests repository to clone.
91-
For a pull request, the reference format would be "refs/pull/${PR_NUMBER}/merge".
92-
For a branch, the reference format would just be the branch name.
93-
This input can be set automatically on a pull request by adding a string of the format:
94-
UI tests PR: 140
95-
replacing "140" with the appropriate PR number. This will make it easier to coordinate changes
96-
that require updating the global tests as well.
97-
required: false
98-
type: string
99-
default: main
10076

10177
jobs:
10278
check-images:
10379
runs-on: ubuntu-latest
10480
steps:
10581
- name: Download artifact
10682
if: "${{ inputs.artifact != '' }}"
107-
uses: actions/download-artifact@v5
83+
uses: actions/download-artifact@v4
10884
with:
10985
name: ${{ inputs.artifact }}
11086
path: /tmp
@@ -147,36 +123,9 @@ jobs:
147123
needs: check-images
148124
runs-on: ubuntu-latest
149125
steps:
150-
- name: Extract pull request number from inputs or PR description
151-
env:
152-
body: ${{ github.event.pull_request.body }}
153-
run: |
154-
PULL_REQUEST_NUMBER=$(echo ${body} | grep -oP '[T|t]ests [P|p][R|r]: \K\d+' || true)
155-
[ -z "$PULL_REQUEST_NUMBER" ] \
156-
&& TESTS_REF=${{ inputs.tests_ref }} \
157-
|| TESTS_REF=refs/pull/$PULL_REQUEST_NUMBER/merge
158-
159-
echo "TESTS_REF=${TESTS_REF}" >>"$GITHUB_ENV"
160-
echo "Using TESTS_REF \`${TESTS_REF}\`" >>"$GITHUB_STEP_SUMMARY"
161-
162-
- name: Checkout tests repo
163-
uses: actions/checkout@v5
164-
with:
165-
repository: trustification/trustify-tests
166-
path: trustify-tests
167-
ref: "${{ env.TESTS_REF }}"
168-
- uses: actions/setup-node@v4
169-
with:
170-
node-version: 20
171-
cache: "npm"
172-
cache-dependency-path: "trustify-tests/package-lock.json"
173-
- name: Install dependencies
174-
run: npm ci
175-
working-directory: trustify-tests
176-
177126
- name: Download artifact
178127
if: "${{ inputs.artifact != '' }}"
179-
uses: actions/download-artifact@v5
128+
uses: actions/download-artifact@v4
180129
with:
181130
name: ${{ inputs.artifact }}
182131
path: /tmp
@@ -186,18 +135,22 @@ jobs:
186135
docker load --input /tmp/${{ inputs.artifact }}.tar
187136
188137
- name: Checkout ui repo
189-
uses: actions/checkout@v5
138+
uses: actions/checkout@v4
139+
- uses: actions/setup-node@v4
190140
with:
191-
path: trustify-ui
141+
node-version: 22
142+
cache: "npm"
143+
- name: Install dependencies
144+
run: npm ci
145+
192146
- name: Start trustify
193-
uses: ./trustify-ui/.github/actions/start-trustify
147+
uses: ./.github/actions/start-trustify
194148
with:
195149
ui_image: ${{ inputs.ui_image }}
196150
server_image: ${{ inputs.server_image }}
197151
server_db_image: ${{ inputs.server_db_image }}
198152

199153
- name: Run Playwright tests
200-
working-directory: trustify-tests
201154
run: |
202155
script=""
203156
if [ "${{ inputs.run_api_tests }}" = "true" ] && [ "${{ inputs.run_ui_tests }}" = "true" ]; then
@@ -210,4 +163,4 @@ jobs:
210163
211164
echo "script to run: ${script}"
212165
213-
PW_TEST_CONNECT_WS_ENDPOINT=ws://localhost:5000/ TRUSTIFY_URL=http://localhost:8081 TRUSTIFY_AUTH_ENABLED=false npm run $script
166+
PW_TEST_CONNECT_WS_ENDPOINT=ws://localhost:5000/ TRUSTIFY_UI_URL=http://localhost:8081 AUTH_REQUIRED=false npm run -w e2e $script

0 commit comments

Comments
 (0)