Skip to content

Commit 1c1274f

Browse files
committed
build(ci): improve 'screenshot-diff' directory structure
* remove the nested folder tree (build/outputs/roborazzi) * name the directory: screenshot-diff.zip contains `screenshot-diff-pr-123` so conflicts don't occur and cleanup is easier Assisted-by: Claude Opus 4.7 - all Issue 20942
1 parent 7a0cb6e commit 1c1274f

2 files changed

Lines changed: 20 additions & 9 deletions

File tree

.github/workflows/screenshot_comment.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ jobs:
6565
name: Check if there are valid files
6666
shell: bash
6767
run: |
68-
# Find roborazzi diff PNGs in the downloaded artifact.
69-
mapfile -t files_to_add < <(find . -path '*/roborazzi/*' -name "*_compare.png" -type f)
68+
# Find roborazzi diff PNGs in the downloaded artifact (in <TestClass>/diffs/).
69+
mapfile -t files_to_add < <(find . -path '*/diffs/*' -name "*_compare.png" -type f)
7070
if [ ${#files_to_add[@]} -gt 0 ]; then
7171
exist_valid_files="true"
7272
else
@@ -83,17 +83,17 @@ jobs:
8383
BASE_REF: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.pull_requests[0].base.ref || github.event.repository.default_branch }}
8484
shell: bash
8585
run: |
86-
# Find roborazzi diff PNGs to mention in the comment.
87-
mapfile -t files < <(find . -path '*/roborazzi/*' -name "*_compare.png" -type f | sort)
86+
# Find roborazzi diff PNGs to mention in the comment (in <TestClass>/diffs/).
87+
mapfile -t files < <(find . -path '*/diffs/*' -name "*_compare.png" -type f | sort)
8888
total=${#files[@]}
8989
# Cap the full list so we remain within GitHub's comment limit
9090
max_details=100
9191
92-
# Group by test class — the directory immediately under roborazzi/.
92+
# Group by test class — the directory containing diffs/.
9393
declare -A class_counts class_files
9494
for file in "${files[@]}"; do
95-
rest="${file#*/roborazzi/}"
96-
class="${rest%%/*}"
95+
class_dir="${file%/diffs/*}"
96+
class="${class_dir##*/}"
9797
class_counts[$class]=$(( ${class_counts[$class]:-0} + 1 ))
9898
class_files[$class]+="$(basename "$file")"$'\n'
9999
done

.github/workflows/screenshot_compare.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,24 @@ jobs:
6767
run: |
6868
./gradlew compareRoborazziPlayDebug -Pscreenshot --stacktrace
6969
70+
- name: Stage screenshot diffs
71+
if: ${{ always() }}
72+
env:
73+
# Folder name inside the artifact (e.g. "screenshot-diff-pr-12345" on PRs, "screenshot-diff-main" on push)
74+
SUBDIR: ${{ github.event_name == 'pull_request' && format('screenshot-diff-pr-{0}', github.event.number) || format('screenshot-diff-{0}', github.ref_name) }}
75+
run: |
76+
# Trim 'AnkiDroid/build/outputs/roborazzi' from the artifact and namespace by PR/branch
77+
mkdir -p screenshot-diff
78+
if [ -d AnkiDroid/build/outputs/roborazzi ]; then
79+
mv AnkiDroid/build/outputs/roborazzi "screenshot-diff/$SUBDIR"
80+
fi
81+
7082
- name: Upload screenshot diffs
7183
uses: actions/upload-artifact@v4
7284
if: ${{ always() }}
7385
with:
7486
name: screenshot-diff # referenced by screenshot_comment.yml
75-
path: |
76-
**/build/outputs/roborazzi
87+
path: screenshot-diff
7788
retention-days: 30
7889

7990
- name: Upload screenshot diff reports

0 commit comments

Comments
 (0)