forked from ankidroid/Anki-Android
-
-
Notifications
You must be signed in to change notification settings - Fork 0
120 lines (105 loc) · 4.42 KB
/
screenshot_compare.yml
File metadata and controls
120 lines (105 loc) · 4.42 KB
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
# Adapted from https://github.com/takahirom/roborazzi/blob/4be7f304fa23f2f00fad67ab612aec2035ac9db2/.github/workflows/CompareScreenshot.yml
# Modified from the original: adapted to AnkiDroid CI conventions.
#
# Copyright 2023 takahirom
# Copyright 2019 Square, Inc.
# Copyright The Android Open Source Project
#
# 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: "🛠️ Screenshots: Compare" # do not rename - referenced by screenshot_comment.yml
on:
push:
branches:
- main
pull_request:
permissions: {}
jobs:
compare-screenshot-test:
name: compare
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
contents: read # for clone
actions: write # for upload-artifact
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Configure JDK
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
with:
distribution: "temurin"
java-version: "21"
- name: Setup Gradle
uses: gradle/actions/setup-gradle@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e # v6.1.0
with:
# Use open source provider: https://github.com/gradle/actions/blob/main/docs/setup-gradle.md#basic-caching
cache-provider: basic
gradle-version: wrapper
- name: Download base branch screenshots
uses: dawidd6/action-download-artifact@09f2f74827fd3a8607589e5ad7f9398816f540fe # v3.1.4
continue-on-error: true
with:
name: screenshot
workflow: screenshot_store.yml
branch: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || github.event.repository.default_branch }}
- name: Compare screenshots
id: compare-screenshot-test
run: |
./gradlew compareRoborazziPlayDebug -Pscreenshot --stacktrace
- name: Stage screenshot diffs
if: ${{ always() }}
env:
# Folder name inside the artifact (e.g. "screenshot-diff-pr-12345" on PRs, "screenshot-diff-main" on push)
SUBDIR: ${{ github.event_name == 'pull_request' && format('screenshot-diff-pr-{0}', github.event.number) || format('screenshot-diff-{0}', github.ref_name) }}
run: |
# Trim 'AnkiDroid/build/outputs/roborazzi' from the artifact
# Only keep diagnostic content for failing cases: each <class>/diffs/ becomes <class>/
mkdir -p "screenshot-diff/$SUBDIR"
shopt -s nullglob
for diffs_dir in AnkiDroid/build/outputs/roborazzi/*/diffs; do
class_name="$(basename "$(dirname "$diffs_dir")")"
mv "$diffs_dir" "screenshot-diff/$SUBDIR/$class_name"
done
- name: Upload screenshot diffs
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: ${{ always() }}
with:
name: screenshot-diff # referenced by screenshot_comment.yml
path: screenshot-diff
retention-days: 30
- name: Upload screenshot diff reports
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: ${{ always() }}
with:
name: screenshot-diff-reports
path: |
**/build/reports
retention-days: 30
- name: Upload screenshot diff test results
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: ${{ always() }}
with:
name: screenshot-diff-test-results
path: |
**/build/test-results
retention-days: 30
- name: Save PR number
if: ${{ github.event_name == 'pull_request' }}
run: |
mkdir -p ./pr
echo ${{ github.event.number }} > ./pr/NR
- name: Persist PR number
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: pr # downloaded by screenshot_comment.yml
path: pr/