Skip to content

Commit 4b4ad75

Browse files
authored
chore: add error when no new diffs generated (#28132)
Issue number: N/A --------- <!-- Please do not submit updates to dependencies unless it fixes an issue. --> <!-- Please try to limit your pull request to one type (bugfix, feature, etc). Submit multiple pull requests if needed. --> ## What is the current behavior? <!-- Please describe the current behavior that you are modifying. --> 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? <!-- Please describe the behavior or changes that are being added by this PR. --> - 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 <!-- If this introduces a breaking change, please describe the impact and migration path for existing applications below. --> ## Other information <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. -->
1 parent 3c94cd1 commit 4b4ad75

File tree

1 file changed

+11
-2
lines changed
  • .github/workflows/actions/update-reference-screenshots

1 file changed

+11
-2
lines changed

.github/workflows/actions/update-reference-screenshots/action.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,16 @@ runs:
3535
git config user.name ionitron
3636
git config user.email [email protected]
3737
git add src/\*.png --force
38-
git commit -m "chore(): add updated snapshots"
39-
git push
38+
39+
if git diff --exit-code; then
40+
echo -e "\033[1;31m⚠️ Error: No new screenshots generated ⚠️\033[0m"
41+
echo -e "\033[1;31mThis means that there were zero visual diffs when running screenshot tests.\033[0m"
42+
echo -e "\033[1;31mMake sure you have pushed any code changes that would result in visual diffs.\033[0m"
43+
exit 1
44+
else
45+
git commit -m "chore(): add updated snapshots"
46+
git push
47+
fi
48+
4049
shell: bash
4150
working-directory: ./core

0 commit comments

Comments
 (0)