forked from guacsec/trustify-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
175 lines (166 loc) · 5.83 KB
/
ci-e2e-template.yaml
File metadata and controls
175 lines (166 loc) · 5.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
name: Run e2e Trustify CI tests
on:
workflow_call:
inputs:
artifact:
description: |
The name of the component being tested, ie server etc.
Must correspond to an artifact storing the custom built image, named <artifact>,
and should contain the file <artifact>.tar inside.
required: false
type: string
ui_image:
description: image uri for the ui (ie. ghcr.io/<namespace>/<image-name>:<tag>)
type: string
required: false
default: ""
server_image:
description: image uri for the server (ie. ghcr.io/<namespace>/<image-name>:<tag>)
type: string
required: false
default: ""
server_db_image:
description: image uri for server-postgres (ie. ghcr.io/<namespace>/<image-name>:<tag>)
type: string
required: false
default: ""
run_api_tests:
description: |
A flag that determines whether the API tests should be run or not
type: boolean
required: false
default: true
run_ui_tests:
description: |
A flag that determines whether the UI tests should be run or not
type: boolean
required: false
default: true
workflow_dispatch:
inputs:
artifact:
description: |
The name of the component being tested, ie server etc.
Must correspond to an artifact storing the custom built image, named <artifact>,
and should contain the file <artifact>.tar inside.
required: false
type: string
ui_image:
description: image uri for the ui (ie. ghcr.io/<namespace>/<image-name>:<tag>)
type: string
required: false
default: ""
server_image:
description: image uri for the server (ie. ghcr.io/<namespace>/<image-name>:<tag>)
type: string
required: false
default: ""
server_db_image:
description: image uri for server-postgres (ie. ghcr.io/<namespace>/<image-name>:<tag>)
type: string
required: false
default: ""
run_api_tests:
description: |
A flag that determines whether the API tests should be run or not
type: boolean
required: false
default: true
run_ui_tests:
description: |
A flag that determines whether the UI tests should be run or not
type: boolean
required: false
default: true
jobs:
check-images:
runs-on: ubuntu-latest
steps:
- name: Download artifact
if: "${{ inputs.artifact != '' }}"
uses: actions/download-artifact@v8
with:
name: ${{ inputs.artifact }}
path: /tmp
- name: Load images
if: ${{ inputs.artifact != '' }}
run: |
docker load --input /tmp/${{ inputs.artifact }}.tar
- name: Check ui image exists
if: ${{ inputs.ui_image != '' }}
run: |
if docker image inspect ${{ inputs.ui_image }} >/dev/null 2>&1; then
echo "Image exists locally"
docker image inspect ${{ inputs.ui_image }}
else
echo "Image does not exist locally"
docker manifest inspect ${{ inputs.ui_image }}
fi
- name: Check server image exists
if: ${{ inputs.server_image != '' }}
run: |
if docker image inspect ${{ inputs.server_image }} >/dev/null 2>&1; then
echo "Image exists locally"
docker image inspect ${{ inputs.server_image }}
else
echo "Image does not exist locally"
docker manifest inspect ${{ inputs.server_image }}
fi
- name: Check server_db_image image exists
if: ${{ inputs.server_db_image != '' }}
run: |
if docker image inspect ${{ inputs.server_db_image }} >/dev/null 2>&1; then
echo "Image exists locally"
docker image inspect ${{ inputs.server_db_image }}
else
echo "Image does not exist locally"
docker manifest inspect ${{ inputs.server_db_image }}
fi
e2e-integration-tests:
needs: check-images
runs-on: ubuntu-latest
steps:
- name: Download artifact
if: "${{ inputs.artifact != '' }}"
uses: actions/download-artifact@v8
with:
name: ${{ inputs.artifact }}
path: /tmp
- name: Load images
if: ${{ inputs.artifact != '' }}
run: |
docker load --input /tmp/${{ inputs.artifact }}.tar
- name: Checkout ui repo
uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 22
cache: "npm"
- name: Install dependencies
run: npm ci --verbose --ignore-scripts --no-audit
- name: Start trustify
uses: ./.github/actions/start-trustify
with:
ui_image: ${{ inputs.ui_image }}
server_image: ${{ inputs.server_image }}
server_db_image: ${{ inputs.server_db_image }}
- name: Run Playwright tests
run: |
script=""
if [ "${{ inputs.run_api_tests }}" = "true" ] && [ "${{ inputs.run_ui_tests }}" = "true" ]; then
script="test"
elif [ "${{ inputs.run_api_tests }}" = "true" ]; then
script="test:api"
elif [ "${{ inputs.run_ui_tests }}" = "true" ]; then
script="test:ui"
fi
echo "script to run: ${script}"
PW_TEST_CONNECT_WS_ENDPOINT=ws://localhost:5000/ TRUSTIFY_UI_URL=http://localhost:8081 AUTH_REQUIRED=false npm run -w e2e $script
- name: Upload Playwright artifacts
if: failure() # only upload if tests failed
uses: actions/upload-artifact@v7
with:
name: playwright-artifacts
path: |
e2e/test-results
e2e/playwright-report