-
Notifications
You must be signed in to change notification settings - Fork 3
109 lines (94 loc) · 3.95 KB
/
ci-verify-build.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
# Copyright (C) 2023 Dynamic Solutions
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: 'CI: verify build'
on:
pull_request:
push:
branches:
- main
env:
MAVEN_CACHE_VERSION: v7.0.0 # bump cache version number to invalidate cache i.e. v3 > v4
MAVEN_CACHE_PATH: ~/.m2/repository
permissions:
id-token: write
contents: read
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
with:
workload_identity_provider: ${{ secrets.GCP_WEBSIGHT_RELEASES_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GCP_WEBSIGHT_RELEASES_RELEASE_DEPLOY_SA }}
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
- uses: actions/cache/restore@v3
with:
path: ${{ env.MAVEN_CACHE_PATH }}
key: ${{ env.MAVEN_CACHE_VERSION }}-${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ env.MAVEN_CACHE_VERSION }}-${{ runner.os }}-maven
- name: Build and run e2e tests
run: ./mvnw --batch-mode clean verify -P e2e-functional
- uses: actions/cache/save@v3
if: always()
with:
path: ${{ env.MAVEN_CACHE_PATH }}
key: ${{ env.MAVEN_CACHE_VERSION }}-${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
- name: Switch to base branch
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.base.ref }}
- uses: actions/cache/restore@v3
with:
path: ${{ env.MAVEN_CACHE_PATH }}
key: ${{ env.MAVEN_CACHE_VERSION }}-${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ env.MAVEN_CACHE_VERSION }}-${{ runner.os }}-maven
- name: Visual tests - create reference snapshots
run: mvn --batch-mode clean verify -P e2e-visual-seed
- name: Temporarily store snapshot references
run: cp -R ./tests/end-to-end/backstop_data/bitmaps_reference $HOME/bitmaps_reference
- name: Switch to PR branch
uses: actions/checkout@v4
- name: Add snapshot references from base branch to the project
run: cp -R $HOME/bitmaps_reference ./tests/end-to-end/backstop_data
- name: Remove temporary storage of snapshot references
run: rm -r $HOME/bitmaps_reference
- uses: actions/cache/restore@v3
with:
path: ${{ env.MAVEN_CACHE_PATH }}
key: ${{ env.MAVEN_CACHE_VERSION }}-${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ env.MAVEN_CACHE_VERSION }}-${{ runner.os }}-maven
- name: Visual tests - compare with reference screenshots
id: visualTestsCompare
run: mvn --batch-mode clean verify -P e2e-visual-check
continue-on-error: true
- name: Create visual tests report
if: steps.visualTestsCompare.outcome == 'failure'
shell: bash
run: |
./tests/end-to-end/backstop_data/ci/read-report-failures.sh
sudo apt-get install -y pngquant && ./tests/end-to-end/backstop_data/ci/provide-report.sh
- name: Upload artifact with visual test report
if: steps.visualTestsCompare.outcome == 'failure'
uses: actions/upload-artifact@v3
with:
name: visual-tests-report
path: artifacts/visual/
if-no-files-found: error
retention-days: 1