Skip to content

Fix/KYAN-291 image previews #73

Fix/KYAN-291 image previews

Fix/KYAN-291 image previews #73

Workflow file for this run

# 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