-
Notifications
You must be signed in to change notification settings - Fork 4
262 lines (220 loc) · 8.19 KB
/
run_tests.yaml
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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
name: Run tests
# Run tests
on:
push:
branches:
- main
pull_request_target:
branches:
- main
jobs:
test-and-build:
name: Cypress components/e2e tests
concurrency:
group:
${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-${{ matrix.name }}-${{ matrix.os }}
cancel-in-progress: true
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
fail-fast: false
timeout-minutes: 720
env:
timeout: 720
dev_server_url: 'http://localhost:9000'
# browser_connect_timeout: 180000
steps:
- name: Install Mozilla Firefox/Microsoft Edge
run: |
if [ "$RUNNER_OS" == 'macOS' ]; then
brew update
brew install --cask firefox microsoft-edge
fi
shell: bash
- name: Checkout app repository code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
# - name: Make cypress dir required for cypress-parallel parallel-weights.json file
# run: |
# mkdir ./cypress
# shell: bash
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ vars.NODE_VERSION }}
- run: node -v
- name: Run Cypress e2e test on Mozilla Firefox/OS ${{ matrix.os }}
uses: cypress-io/github-action@v6
# env:
# DEBUG: "cypress:*"
# CYPRESS_INTERNAL_BROWSER_CONNECT_TIMEOUT: ${{ env.browser_connect_timeout }}
with:
start: yarn dev
browser: firefox
wait-on-timeout: ${{ env.timeout }}
wait-on: ${{ env.dev_server_url }}
command: yarn test:e2e:ci:firefox
- name: Run Cypress e2e test on Google Chrome/OS ${{ matrix.os }}
uses: cypress-io/github-action@v6
# env:
# DEBUG: "cypress:*"
# CYPRESS_INTERNAL_BROWSER_CONNECT_TIMEOUT: ${{ env.browser_connect_timeout }}
with:
install: false
browser: chrome
wait-on-timeout: ${{ env.timeout }}
wait-on: ${{ env.dev_server_url }}
command: yarn test:e2e:ci:chrome
- name: Run Cypress e2e test on MS Edge/OS ${{ matrix.os }}
uses: cypress-io/github-action@v6
# env:
# DEBUG: "cypress:*"
# CYPRESS_INTERNAL_BROWSER_CONNECT_TIMEOUT: ${{ env.browser_connect_timeout }}
with:
install: false
browser: edge
wait-on-timeout: ${{ env.timeout }}
wait-on: ${{ env.dev_server_url }}
command: yarn test:e2e:ci:edge
- name: Run Cypress component test on Mozilla Firefox/OS ${{ matrix.os }}
uses: cypress-io/github-action@v6
# env:
# DEBUG: "cypress:*"
# CYPRESS_INTERNAL_BROWSER_CONNECT_TIMEOUT: ${{ env.browser_connect_timeout }}
with:
install: false
browser: firefox
wait-on-timeout: ${{ env.timeout }}
wait-on: ${{ env.dev_server_url }}
command: yarn test:component:ci:firefox
- name: Run Cypress component test on Google Chrome/OS ${{ matrix.os }}
uses: cypress-io/github-action@v6
# env:
# DEBUG: "cypress:*"
# CYPRESS_INTERNAL_BROWSER_CONNECT_TIMEOUT: ${{ env.browser_connect_timeout }}
with:
install: false
browser: chrome
wait-on-timeout: ${{ env.timeout }}
wait-on: ${{ env.dev_server_url }}
command: yarn test:component:ci:chrome
- name: Run Cypress component test on MS Edge/OS ${{ matrix.os }}
uses: cypress-io/github-action@v6
# env:
# DEBUG: "cypress:*"
# CYPRESS_INTERNAL_BROWSER_CONNECT_TIMEOUT: ${{ env.browser_connect_timeout }}
with:
install: false
browser: edge
wait-on-timeout: ${{ env.timeout }}
wait-on: ${{ env.dev_server_url }}
command: yarn test:component:ci:edge
- name: Build app
run: npx quasar build
- name: Archive runned cypress tests snapshots result
uses: actions/upload-artifact@v4
if: ${{ failure() }}
with:
name: cypress-tests-snapshots-${{ matrix.os }}
path: test/cypress/snapshots
if-no-files-found: ignore
retention-days: 3
- name: Archive runned cypress tests videos result
uses: actions/upload-artifact@v4
if: ${{ failure() }}
with:
name: cypress-tests-videos-${{ matrix.os }}
path: test/cypress/videos
if-no-files-found: ignore
retention-days: 3
# dump-github-context:
# name: Dump GitHub context
# runs-on: ubuntu-latest
# steps:
# - name: Dump GitHub context
# env:
# GITHUB_CONTEXT: ${{ toJson(github) }}
# run: echo "$GITHUB_CONTEXT"
sonarcloud:
name: SonarCloud scan analysis
runs-on: ubuntu-latest
steps:
- name: Checkout app repository code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ vars.NODE_VERSION }}
- run: node -v
- name: Run yarn install
uses: borales/actions-yarn@v5
with:
cmd: install
- name: SonarCloud Scan
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
push-docker-img:
if: github.event_name == 'push' && github.event.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs: [test-and-build, sonarcloud]
outputs:
dockerhub_image_version: ${{ steps.set_output.outputs.dockerhub_image_version }}
steps:
- name: Checkout app repository code
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Get Docker image version
run: |
.github/workflows/get_docker_image_tag_number.sh \
${{ secrets.DOCKERHUB_REPO_OWNER }} ${{ secrets.DOCKERHUB_REPO_NAME }}
- name: Create deployed_app_version.toml file with deployed app Docker image version
run: |
echo "version = ${{ env.DOCKERHUB_IMAGE_VERSION }}" > deployed_app_version.toml
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: ./
file: ./docker/Dockerfile
push: true
tags: ${{ secrets.DOCKERHUB_REPO_OWNER }}/${{ secrets.DOCKERHUB_REPO_NAME }}:${{ env.DOCKERHUB_IMAGE_VERSION }}
- id: set_output
run: |
echo "dockerhub_image_version=${{ env.DOCKERHUB_IMAGE_VERSION }}" >> "$GITHUB_OUTPUT"
deploy-app-to-k8:
if: github.event_name == 'push' && github.event.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs: [push-docker-img]
steps:
- name: Checkout k8 repository
uses: actions/checkout@v4
with:
repository: auto-mat/k8s
token: ${{ secrets.GH_PAT }}
path: k8s
- env:
DOCKERHUB_IMAGE_VERSION: ${{ needs.push-docker-img.outputs.dockerhub_image_version }}
run: |
cd ./k8s
git config --global user.name "github-actions"
git config --global user.email "[email protected]"
echo "DOCKERHUB_IMAGE_VERSION: ${DOCKERHUB_IMAGE_VERSION}"
file ./manifests/ytt/ride-to-work-by-bike-frontend-test.yaml
sed -i -e "2s/.*/#@ image = \"${{ secrets.DOCKERHUB_REPO_OWNER }}\/${{ secrets.DOCKERHUB_REPO_NAME }}:${DOCKERHUB_IMAGE_VERSION}\"/" ./manifests/ytt/ride-to-work-by-bike-frontend-test.yaml
git commit -am "manifests/ytt: bump ride-to-work-by-bike-frontend-test app build image to version ${DOCKERHUB_IMAGE_VERSION}"
git push