From 4b4ad75bf0b99a669575092cbd9377745048e003 Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Wed, 6 Sep 2023 12:38:39 -0400 Subject: [PATCH] chore: add error when no new diffs generated (#28132) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue number: N/A --------- ## What is the current behavior? When the "Update Reference Screenshot" job is run but no new screenshots are generated, the following error is logged: ``` nothing added to commit but untracked files present (use "git add" to track) Error: Process completed with exit code 1. ``` This is happening because there are no files to commit when running `git commit`. Brandy noted that this was confusing since it doesn't actually tell you why there are no files to commit. ## What is the new behavior? - If there are no diffs to commit then the update screenshot script will log a message saying that no screenshot diffs were generated. Example: ``` ⚠️ Error: No new screenshots generated ⚠️ This means that there were zero visual diffs when running screenshot tests. Make sure you have pushed any code changes that would result in visual diffs. ``` https://github.com/ionic-team/ionic-framework/actions/runs/6099399582/job/16552017414 ## Does this introduce a breaking change? - [ ] Yes - [x] No ## Other information --- .../actions/update-reference-screenshots/action.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/actions/update-reference-screenshots/action.yml b/.github/workflows/actions/update-reference-screenshots/action.yml index 493678f22a..47f3737325 100644 --- a/.github/workflows/actions/update-reference-screenshots/action.yml +++ b/.github/workflows/actions/update-reference-screenshots/action.yml @@ -35,7 +35,16 @@ runs: git config user.name ionitron git config user.email hi@ionicframework.com git add src/\*.png --force - git commit -m "chore(): add updated snapshots" - git push + + if git diff --exit-code; then + echo -e "\033[1;31m⚠️ Error: No new screenshots generated ⚠️\033[0m" + echo -e "\033[1;31mThis means that there were zero visual diffs when running screenshot tests.\033[0m" + echo -e "\033[1;31mMake sure you have pushed any code changes that would result in visual diffs.\033[0m" + exit 1 + else + git commit -m "chore(): add updated snapshots" + git push + fi + shell: bash working-directory: ./core