Skip to content

[pull] master from highcharts:master #1372

[pull] master from highcharts:master

[pull] master from highcharts:master #1372

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/iron]
steps:
- uses: actions/checkout@v3
with:
ref: master
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
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@v4
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