-
Notifications
You must be signed in to change notification settings - Fork 26
102 lines (82 loc) · 3 KB
/
generate-screenshots.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
name: "Generate and Verify Screenshot Tests"
on:
workflow_dispatch:
push:
branches:
- feat/screenshot-tests
permissions:
contents: write
pull-requests: write
env:
GITHUB_TOKEN: ${{ secrets.ANDROID_BOB_GH_TOKEN }}
jobs:
generate-screenshots:
runs-on: buildjet-8vcpu-ubuntu-2204
if: github.ref == 'refs/heads/feat/screenshot-tests'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Set up JDK 17
uses: buildjet/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: gradle
- name: Validate Gradle wrapper
uses: gradle/actions/wrapper-validation@v4
- name: Fetch All Branches
run: git fetch --all
- name: Merge Develop into screenshot-tests
run: |
git checkout screenshot-tests
git merge origin/develop --no-edit
git push origin screenshot-tests
- name: Verify Screenshot Tests
run: ./gradlew validateInternalDebugScreenshotTest
continue-on-error: true # Ensure this task doesn't fail the build
- name: Update Screenshot Reference Images
run: ./gradlew updateInternalDebugScreenshotTest
- name: Copy test results to simplified directory
run: |
mkdir -p screenshotTest
cp -r app/build/reports/screenshotTest/preview/debug/internal/* screenshotTest/
- name: Zip Screenshot Test Reports
run: |
zip -r screenshot-test-report.zip screenshotTest/
- name: Upload Screenshot Test Report
uses: actions/upload-artifact@v4
with:
name: screenshot-test-report
path: screenshot-test-report.zip
- name: Setup GitHub Actions Bot for Git
uses: fregante/setup-git-user@v2
- name: Create New Branch
run: |
BRANCH_NAME="test/screenshots-update-$(date +%Y%m%d%H%M%S)"
git checkout -b $BRANCH_NAME
git add .
git commit -m "test: update screenshot tests"
git push origin $BRANCH_NAME
- name: Create Pull Request
id: create_pr
uses: peter-evans/create-pull-request@v7
with:
token: ${{ env.GITHUB_TOKEN }}
branch: $BRANCH_NAME
base: screenshot-tests
title: "Update Screenshot Tests"
body: "Automated PR to update screenshot tests."
- name: Create comment with test report link
uses: peter-evans/create-or-update-comment@v4
with:
token: ${{ env.GITHUB_TOKEN }}
issue-number: ${{ steps.create_pr.outputs.pull_request_number }}
body: |
Screenshot test results have been generated. [Download the report](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts)
- name: Cleanup Gradle Cache
run: |
rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm -f ~/.gradle/caches/modules-2/gc.properties