-
Notifications
You must be signed in to change notification settings - Fork 23
174 lines (152 loc) · 6 KB
/
e2e-tests-xray_frontend.yml
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
# Copyright (c) 2023 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# SPDX-License-Identifier: Apache-2.0
# Require to set secrets:
# - ASSOCIATION_SUPERVISOR_CLIENT_ID
# - ASSOCIATION_SUPERVISOR_PASSWORD
name: "[FE][TEST][E2E]- Cypress"
on:
# triggered manually by Test Manager
workflow_dispatch:
# or automatically by merge to main
push:
branches:
- main
paths:
- 'frontend/**'
jobs:
install:
runs-on: ubuntu-latest
outputs:
http_result: ${{ steps.download.outputs.http_response }}
defaults:
run:
working-directory: frontend
# Install YARN dependencies, cache them correctly
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Run yarn install
uses: Borales/actions-yarn@v5
with:
cmd: install # will run `yarn install` command
# Fetch feature files
- name: Fetch .feature files from Jira Xray
id: download
env:
JIRA_USERNAME: ${{ secrets.ASSOCIATION_TX_JIRA_USERNAME }}
JIRA_PASSWORD: ${{ secrets.ASSOCIATION_TX_JIRA_PASSWORD }}
working-directory: frontend
run: |
token=$(curl -H "Content-Type: application/json" -X POST \
--data "{ \"client_id\": \"$JIRA_USERNAME\",\"client_secret\": \"$JIRA_PASSWORD\" }" \
https://xray.cloud.getxray.app/api/v2/authenticate | tr -d '"')
export HTTP_RESULT=$(curl -s --show-error -w "%{http_code}" --header "Authorization: Bearer $token" \
"https://xray.cloud.getxray.app/api/v2/export/cucumber?filter=10007&fz=true" -o features.zip)
[[ $HTTP_RESULT == 200 || $HTTP_RESULT == 400 ]]
echo "::set-output name=http_response::$HTTP_RESULT"
- name: Unzip feature files
if: ${{ steps.download.outputs.http_response == '200' }}
working-directory: frontend
run: |
unzip -o features.zip -d cypress/e2e
rm -f features.zip
- name: Save cypress/e2e folder
uses: actions/upload-artifact@v4
with:
name: cypress - e2e
if-no-files-found: error
path: frontend/cypress/e2e
overwrite: true
cypress-run-chrome:
timeout-minutes: 15
runs-on: ubuntu-latest
if: ${{ needs.install.outputs.http_result == '200' }}
defaults:
run:
working-directory: frontend
container:
# if you need to change image please make sure use the same version in all places
# (here and in cypress/Dockerfile)
image: cypress/browsers:node16.16.0-chrome107-ff107-edge
options: --user 1001
needs: install
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download the cypress/e2e folder
uses: actions/download-artifact@v4
with:
name: cypress - e2e
path: frontend/cypress/e2e
- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Install Angular CLI
run: npm install -g @angular/cli
- name: Run yarn install
uses: Borales/actions-yarn@v5
with:
cmd: install # will run `yarn install` command
dir: frontend
- name: Start Frontend Application
working-directory: frontend
run: |
npm run start:auth:e2ea &
sleep 60 &&
curl http://localhost:4200 -I
- name: Cypress run all tests
uses: cypress-io/[email protected] # use the explicit version number
with:
browser: chrome
working-directory: frontend
# using wait-on parameter causes "Error: connect ECONNREFUSED 127.0.0.1:4200"
env:
CYPRESS_SUPERVISOR_LOGIN: ${{ secrets.ASSOCIATION_SUPERVISOR_TX_A_CLIENT_ID }}
CYPRESS_SUPERVISOR_PW: ${{ secrets.ASSOCIATION_SUPERVISOR_TX_A_PASSWORD }}
CYPRESS_ADMIN_LOGIN: ${{ secrets.TRACE_X_ADMIN_LOGIN }}
CYPRESS_ADMIN_PW: ${{ secrets.TRACE_X_ADMIN_PW }}
CYPRESS_USER_LOGIN: ${{ secrets.TRACE_X_USER_LOGIN }}
CYPRESS_USER_PW: ${{ secrets.TRACE_X_USER_PW }}
CYPRESS_REDIRECT_URI: https://traceability-portal-int-a.int.catena-x.net/dashboard
- name: Submit results to Xray
# we don't want to submit results to xray when it was run by PR
if: github.event_name != 'pull_request' && (success() || failure())
env:
JIRA_USERNAME: ${{ secrets.ASSOCIATION_TX_JIRA_USERNAME }}
JIRA_PASSWORD: ${{ secrets.ASSOCIATION_TX_JIRA_PASSWORD }}
run: |
token=$(curl -H "Content-Type: application/json" -X POST \
--data "{ \"client_id\": \"$JIRA_USERNAME\",\"client_secret\": \"$JIRA_PASSWORD\" }" \
https://xray.cloud.getxray.app/api/v2/authenticate | tr -d '"')
curl --request POST \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $token" \
--data-binary '@cypress/reports/cucumber-report.json' \
"https://xray.cloud.getxray.app/api/v2/import/execution/cucumber"
- name: Archive cypress artifacts
if: success() || failure()
uses: actions/upload-artifact@v4
with:
name: cypress generated files - chrome
path: |
frontend/cypress/videos/
frontend/cypress/screenshots/