-
Notifications
You must be signed in to change notification settings - Fork 3.6k
150 lines (128 loc) · 4.17 KB
/
dashboards-visual-test.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
name: Dashboards visual comparison tests
on:
pull_request:
branches:
- 'master'
paths:
- '.github/workflows/dashboards-visual-test.yml'
- 'css/dashboards*'
- 'css/datagrid*'
- 'samples/dashboards/**'
- 'test/cypress/dashboards/**'
- 'ts/Dashboards/**'
- 'ts/Data/**'
permissions:
contents: read # to fetch code (actions/checkout)
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
cypress_visual_test:
timeout-minutes: 10
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [lts/*]
steps:
- uses: actions/checkout@v3
with:
ref: master
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install dependencies
uses: cypress-io/github-action@v6
with:
runTests: false
- name: Build Highcharts
run: npx gulp scripts
- name: Build Dashboards
run: npx gulp dashboards/scripts
- name: Checkout utils
uses: actions/checkout@v4
with:
repository: highcharts/highcharts-utils
path: utils
fetch-depth: 1
- name: Install Highcharts Utils
run: |
cd utils
npm i
- name: Create visual test base images
uses: cypress-io/github-action@v6
with:
start: node utils/server --localOnly
wait-on: 'http://localhost:3031/dashboards.js'
env: type=base
config-file: test/cypress/dashboards/visual.config.mjs
install: false
- name: Stop server
run: kill $(lsof -t -i:3030)
- name: Checkout current branch
uses: actions/checkout@v3
with:
clean: false
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install dependencies
uses: cypress-io/github-action@v6
with:
runTests: false
- name: Build Highcharts
run: npx gulp scripts
- name: Build Dashboards
run: npx gulp dashboards/scripts
- name: Run visual test
uses: cypress-io/github-action@v6
with:
start: node utils/server --localOnly
wait-on: 'http://localhost:3031/dashboards.js'
env: type=actual
config-file: test/cypress/dashboards/visual.config.mjs
install: false
- name: Comment on PR
uses: actions/github-script@v7
with:
github-token: ${{secrets.PR_COMMENT_TOKEN}}
script: |
const { createOrUpdateComment } = require('./.github/scripts/commentOnPR');
const { readFile } = require('node:fs/promises')
const jsonFile = await readFile('./tmp/dashboards-visual-results.json')
.catch(() => null);
const commentTitle = 'Dashboard visual diffs';
// Only exists if there are diffs
if (jsonFile) {
const tests = JSON.parse(jsonFile).map(testObj => {
return `\n* ${testObj.actual}`;
}).join('');
await createOrUpdateComment(
github,
context,
commentTitle,
'Visual differences found in: ' +
tests +
`\n\n See artifacts in [the run summary](https://github.com/highcharts/highcharts/actions/runs/${context.runId}) for screenshots`
);
} else {
await createOrUpdateComment(
github,
context,
commentTitle,
'No differences found'
);
}
- name: Store artifacts
uses: actions/upload-artifact@v3
if: ${{ always() }}
with:
name: post-tests
path: |
tmp/dashboards-visual-results.json
cypress/screenshots
cypress/snapshots
test/cypress/dashboards/cypress/snapshots/base