-
Notifications
You must be signed in to change notification settings - Fork 1
97 lines (83 loc) · 2.64 KB
/
visual-testing.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
name: Visual testing
on:
pull_request:
branches: [main]
workflow_dispatch:
repository_dispatch:
types: [run_visual_testing]
jobs:
prepare-visual-testing:
if: "!contains(github.event.head_commit.message, '[skip ci]')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20.11.0
registry-url: https://npm.pkg.github.com/
scope: '@carlsberg'
- name: Set npm registry and authentication
run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" > .npmrc
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: |
if [ -e yarn.lock ]; then
yarn install
elif [ -e package-lock.json ]; then
npm ci
else
npm i
fi
- name: 'Tar files'
run: tar -cvf malty.tar .
- name: Save packages folder
uses: actions/upload-artifact@v3
with:
name: malty-artifact
if-no-files-found: error
path: malty.tar
retention-days: 1
visual-testing:
runs-on: ubuntu-latest
needs: prepare-visual-testing
env:
BASE_URL: https://pr-${{ github.event.number }}.d3acoh2jwy8aw9.amplifyapp.com
strategy:
fail-fast: false
matrix:
containers: [1, 2]
container:
image: cypress/included:cypress-13.6.4-node-20.11.0-chrome-121.0.6167.85-1-ff-120.0-edge-121.0.2277.83-1
env:
BASE_URL: ${{ env.BASE_URL }}
steps:
- uses: actions/checkout@v3
- name: Download the build folder
uses: actions/download-artifact@v3
with:
name: malty-artifact
- name: 'Untar files'
run: tar -xvf malty.tar
- run: |
if [ -e yarn.lock ]; then
yarn install
elif [ -e package-lock.json ]; then
npm ci
else
npm i
fi
- name: Run visual testing in desktop
if: matrix.containers == 1
# TODO: As soon as the ticket https://carlsberggbs.atlassian.net/browse/DEVOPS-3179 is finished we can remove the npx wait-on utility.
run: npx wait-on ${{ env.BASE_URL }} --interval 300000 --timeout 15m && yarn cypress:ci:desktop
- name: Run visual testing in mobile
if: matrix.containers == 2
run: echo 'Not implemented yet, moving on...'.
shell: bash
- name: Upload Cypress Screenshots
uses: actions/upload-artifact@v3
if: failure()
with:
name: cypress-snapshots-${{ matrix.containers }}
path: cypress/snapshots
retention-days: 1