-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yaml
97 lines (83 loc) · 2.87 KB
/
action.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
name: Run VRT
description: Runs a simple visual regression test using Backstop
inputs:
testurl:
description: The test URL that has potential changes
type: string
required: true
referenceurl:
description: The URL the test url should be tested against (typically a production URL)
type: string
required: true
runs:
using: composite
steps:
- name: Verify we were given a URL for Reference
id: verify-reference
uses: platformsh/gha-check-url@main
with:
test_url: ${{ inputs.referenceurl }}
- name: Verify we were given a URL for test
id: verify-test
uses: platformsh/gha-check-url@main
with:
test_url: ${{ inputs.testurl }}
- name: install backstop
shell: bash
working-directory: ${{ github.action_path }}
run: npm install
- name: 'update jq'
uses: dcarbone/[email protected]
with:
version: '1.7'
force: true
- name: update backstop config
shell: bash
working-directory: ${{ github.action_path }}
run: |
echo $(cat backstop-orig.json | jq --arg testurl "${{ inputs.testurl }}" --arg refurl "${{ inputs.referenceurl }}" '.scenarios.[].url |= sub("https://example-dev.com/";$testurl) | .scenarios.[].referenceUrl |= sub("https://example.com/";$refurl)') > backstop.json
- name: run reference
shell: bash
working-directory: ${{ github.action_path }}
run: ./node_modules/.bin/backstop reference
- name: run test
id: test-results
continue-on-error: true
working-directory: ${{ github.action_path }}
shell: bash
run: |
# we dont want to halt on an error since backstop test might fail and we want to store the reports
set +e
suppress=$(./node_modules/.bin/backstop test)
testresults=$?
echo "::notice::Visual Regression Testing complete. Preparing results..."
if (( 0 != $testresults )); then
echo "::error::Backstop visual regression testing failed. Please see the generated report"
results="false"
else
echo "::notice::Backstop visual regression testing passed."
results="true"
fi
echo "vrt_results=${results}" >> $GITHUB_ENV
- name: Setup tmate session
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
with:
detached: true
- name: 'export reports'
id: export-reports
if: ${{ env.vrt_results == 'false' }}
uses: actions/upload-artifact@v3
with:
name: vrt-report
path: |
${{ github.action_path }}/backstop_data
!${{ github.action_path }}/backstop_data/engine_scripts/*
- name: Return Results
id: return-results
if: ${{ always() }}
shell: bash
run: |
if [[ "false" = "${{ env.vrt_results }}" ]]; then
exit 1;
fi