Skip to content

Commit fd5a1ac

Browse files
authored
chore(ci): account for new screenshots in error logging (#28166)
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. --> We checked `git diff` to see if new screenshots were generated. If no new screenshots were generated then we print a user-friendly message informing the dev what happened. However, `git diff` does not account for untracked changes (i.e. new screenshots). As a result, this prevented new screenshots from being committed. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - To fix this we use the `-N` flag which is short for `--intent-to-add`. This adds an entry with no content which causes the new screenshots to show up when running `git diff`. We later add the contents of the image. Example test run of this working: https://github.com/ionic-team/ionic-framework/actions/runs/6174263712/job/16759260534 ## 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 f827095 commit fd5a1ac

File tree

1 file changed

+8
-1
lines changed
  • .github/workflows/actions/update-reference-screenshots

1 file changed

+8
-1
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,21 @@ runs:
3434
run: |
3535
git config user.name ionitron
3636
git config user.email [email protected]
37-
git add src/\*.png --force
37+
38+
# This adds an empty entry for new
39+
# screenshot files so we can track them with
40+
# git diff
41+
git add src/\*.png --force -N
3842
3943
if git diff --exit-code; then
4044
echo -e "\033[1;31m⚠️ Error: No new screenshots generated ⚠️\033[0m"
4145
echo -e "\033[1;31mThis means that there were zero visual diffs when running screenshot tests.\033[0m"
4246
echo -e "\033[1;31mMake sure you have pushed any code changes that would result in visual diffs.\033[0m"
4347
exit 1
4448
else
49+
# This actually adds the contents
50+
# of the screenshots (including new ones)
51+
git add src/\*.png --force
4552
git commit -m "chore(): add updated snapshots"
4653
git push
4754
fi

0 commit comments

Comments
 (0)