-
Notifications
You must be signed in to change notification settings - Fork 408
215 lines (185 loc) · 7.56 KB
/
test-e2e.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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
name: "E2e test on main branch push"
# These jobs can be tested with nektos/act tool
# https://github.com/nektos/act
#
# Look for "!env.ACT" in the DRY_RUN expression below
on:
push:
branches:
- 2023.9.x-feature-e2e
env:
BUILD_OS: linux
BUILD_ARCH: amd64
GO_VERSION: 1.19
GOFLAGS: -mod=readonly
NODE_VERSION: 16
CORTEZA_VERSION: 2023.9.0
CYPRESS_VERSION: 13.5.0
CYPRESS_HOST: http://localhost:8888
CYPRESS_BASE_URL: http://localhost:8888
CYPRESS_ADMIN_URL: http://localhost:8080
CYPRESS_COMPOSE_URL: http://localhost:8081
CYPRESS_WORKFLOW_URL: http://localhost:8082
CYPRESS_REPORTER_URL: http://localhost:8083
CYPRESS_ONE_URL: http://localhost:8086
CYPRESS_PRIVACY_URL: http://localhost:8087
CYPRESS_USER_EMAIL: [email protected]
CYPRESS_USER_PASSWORD: cypress123
CYPRESS_USER_PASSWORD_NEW: newcypress123
CYPRESS_USER_EMAIL_NEW: [email protected]
CYPRESS_USER_DPO: [email protected]
CYPRESS_USER_DPO_PASSWORD: [email protected]
jobs:
server-client-setup:
name: "server and client test"
strategy:
matrix:
client:
- { port: 8081, name: compose }
- { port: 8080, name: admin }
- { port: 8082, name: workflow }
- { port: 8083, name: reporter }
- { port: 8086, name: one }
# - { port: 8087, name: privacy }
runs-on: ubuntu-20.04
steps:
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
with:
limit-access-to-actor: true
detached: true
- name: Setup environment
env:
RELEASE_CRUST_SFTP_KEY: ${{ secrets.RELEASE_CRUST_SFTP_KEY }}
RELEASE_CRUST_SFTP_URI: ${{ secrets.RELEASE_CRUST_SFTP_URI }}
CLIENT_NAME: ${{ matrix.client.name }}
run: |
echo "SCREENSHOTS_GEN_FOLDER=$(date +"%Y%m%d%H%M%S")-$CLIENT_NAME" >> $GITHUB_ENV && \
echo "TMP_KEY=$(mktemp)" >> $GITHUB_ENV
- name: Create crust key
env:
RELEASE_CRUST_SFTP_KEY: ${{ secrets.RELEASE_CRUST_SFTP_KEY }}
RELEASE_CRUST_KEY_FILE: ${{ env.TMP_KEY }}
run: |
echo ${RELEASE_CRUST_SFTP_KEY} | base64 -d > ${RELEASE_CRUST_KEY_FILE}
- name: Make folder for uploaded screenshots
env:
RELEASE_CRUST_SFTP_URI: ${{ secrets.RELEASE_CRUST_SFTP_URI }}
RELEASE_CRUST_KEY_FILE: ${{ env.TMP_KEY }}
SCREENSHOTS_GEN_FOLDER: ${{ env.SCREENSHOTS_GEN_FOLDER }}
run: |
printf '%s\n' 'cd screenshots' "mkdir ${SCREENSHOTS_GEN_FOLDER}" | sftp -q -o "StrictHostKeyChecking no" -i ${RELEASE_CRUST_KEY_FILE} ${RELEASE_CRUST_SFTP_URI}
- uses: actions/setup-node@v3
with: { node-version: "${{ env.NODE_VERSION }}" }
- uses: actions/setup-go@v3
with: { go-version: "${{ env.GO_VERSION }}" }
- name: "Setup YARN"
run: npm install -g yarn @vue/cli-service
- name: Checkout corteza repo
uses: actions/checkout@v3
with:
path: corteza
token: ${{ secrets.GITHUB_TOKEN }}
ref: 2023.9.x-feature-e2e
- name: "Copy server language files"
working-directory: corteza/server/pkg/locale
run: make src/en
# - name: "Set up PostgreSQL database"
# env:
# POSTGRES_USER: corteza
# POSTGRES_PASSWORD: root
# POSTGRES_DB: corteza_cy_test
# run: |
# docker run -d \
# --name corteza_postgres \
# -p 5432:5432 \
# -e POSTGRES_USER=${POSTGRES_USER} \
# -e POSTGRES_PASSWORD=${POSTGRES_PASSWORD} \
# -e POSTGRES_DB=${POSTGRES_DB} \
# --health-cmd="pg_isready -d ${POSTGRES_DB} -U ${POSTGRES_USER}" \
# --health-interval=10s \
# --health-timeout=5s \
# --health-retries=5 \
# postgres:15
- name: Run server and db
working-directory: corteza
run: |
docker-compose up -d backend
docker-compose up -d postgres
- name: Update config file in webapps
working-directory: corteza
env:
CLIENT_NAME: ${{ matrix.client.name }}
run: |
cp client/web/${CLIENT_NAME}/public/config.example.js client/web/${CLIENT_NAME}/public/config.js
sed -i -e 's/https:\/\/api.cortezaproject.your-domain.tld/\/\/localhost:8888\/api/g' client/web/${CLIENT_NAME}/public/config.js
- name: Build js
working-directory: corteza/lib/js
run: |
yarn install
yarn build
- name: Build vue
working-directory: corteza/lib/vue
run: |
yarn install
yarn build
- name: Run "${{ matrix.client.name }}"
working-directory: corteza
# re-link the packages for each app
env:
CLIENT_NAME: ${{ matrix.client.name }}
CLIENT_PORT: ${{ matrix.client.port }}
run: |
docker-compose run -d \
--name ${CLIENT_NAME} \
--use-aliases \
client \
sh -c "cd /corteza/lib/js && yarn link && cd /corteza/lib/vue && yarn link && cd /corteza/client/web/${CLIENT_NAME} && yarn link @cortezaproject/corteza-vue && yarn link @cortezaproject/corteza-js && yarn install && yarn serve --port ${CLIENT_PORT}"
- name: Clone CY repo
uses: actions/checkout@v3
with:
repository: cortezaproject/corteza-e2e-cypress
token: ${{ secrets.GITHUB_TOKEN }}
ref: 2023.9.x-feature-e2e
path: corteza-e2e-cypress
# github actions do not support docker-compose --wait
- name: Wait for postgres healthcheck
run: timeout 180s sh -c 'until docker ps | grep corteza_postgres_1 | grep -q healthy; do echo "Waiting for container to be healthy..."; sleep 1; done'
- name: Wait for "${{ matrix.client.name }}" healthcheck
env:
CLIENT_NAME: ${{ matrix.client.name }}
run: |
timeout 180s sh -c 'until docker ps | grep ${CLIENT_NAME} | grep -q healthy; do echo "Waiting for container to be healthy..."; sleep 1; done'
- name: Wait for backend healthcheck
run: timeout 180s sh -c 'until docker ps | grep corteza_backend_1 | grep -q healthy; do echo "Waiting for container to be healthy..."; sleep 1; done'
- name: Run CY tests for "${{ matrix.client.name }}"
env:
CLIENT_NAME: ${{ matrix.client.name }}
CLIENT_PORT: ${{ matrix.client.port }}
working-directory: corteza-e2e-cypress
run: |
docker ps
yarn install
docker-compose run \
--entrypoint="bash -c \" \
cypress run --spec cypress/e2e/basic-functionalities/server/Create_user.cy.js --browser chrome \
\"" \
cypress
docker-compose run \
--entrypoint="bash -c \" \
cypress run --spec cypress/e2e/basic-functionalities/${CLIENT_NAME}/index.cy.js --browser chrome \
\"" \
cypress
docker-compose run \
--entrypoint="bash -c \" \
cypress run --spec cypress/e2e/basic-functionalities/topbar/${CLIENT_NAME}/index.cy.js --browser chrome \
\"" \
cypress
- name: Upload screenshots
if: failure()
env:
RELEASE_CRUST_SFTP_URI: ${{ secrets.RELEASE_CRUST_SFTP_URI }}
RELEASE_CRUST_KEY_FILE: ${{ env.TMP_KEY }}
SCREENSHOTS_GEN_FOLDER: ${{ env.SCREENSHOTS_GEN_FOLDER }}
run: |
printf '%s\n' "cd screenshots/${SCREENSHOTS_GEN_FOLDER}" 'put -r cypress/screenshots/*' | sftp -q -o "StrictHostKeyChecking no" -i ${RELEASE_CRUST_KEY_FILE} ${RELEASE_CRUST_SFTP_URI}