Skip to content

Commit

Permalink
chore(ci): fix update screenshot action to account for existing scree…
Browse files Browse the repository at this point in the history
…nshot (#25190)
  • Loading branch information
liamdebeasi authored Apr 25, 2022
1 parent 7296b52 commit ff1429b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
35 changes: 33 additions & 2 deletions .github/workflows/actions/test-core-screenshot/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,41 @@ runs:
shell: bash
working-directory: ./core
- name: Test and Update
id: test-and-update
if: inputs.update == 'true'
run: npx playwright test --shard=${{ inputs.shard }}/${{ inputs.totalShards }} --update-snapshots
# Keep track of the files that were
# changed so they can be correctly restored
# in the combine step.
# To do this, we move only the changed files
# to a separate directory, while preserving the
# directory structure of the source.
# When, we create and archive of these results
# so that the combine step can simply
# unzip and move the changed files into place.
# We have extra logic added so that job runners
# that do not have any new screenshots do not create
# an unnecessary .zip.
# Note that we need to unzip directory to be "core"
# which is why we not using the upload-archive
# composite step here.
run: |
npx playwright test --shard=${{ inputs.shard }}/${{ inputs.totalShards }} --update-snapshots
git add src/\*.png --force
mkdir updated-screenshots
cd ../ && rsync -R --progress $(git diff --name-only --cached) core/updated-screenshots
if [ -d core/updated-screenshots/core ]; then
echo "::set-output name=hasUpdatedScreenshots::$(echo 'true')"
cd core/updated-screenshots
zip -q -r ../../UpdatedScreenshots-${{ inputs.shard }}-${{ inputs.totalShards }}.zip core
fi
shell: bash
working-directory: ./core
- name: Archive Updated Screenshots
if: inputs.update == 'true' && steps.test-and-update.outputs.hasUpdatedScreenshots == 'true'
uses: actions/upload-artifact@v2
with:
name: updated-screenshots-${{ inputs.shard }}-${{ inputs.totalShards }}
path: UpdatedScreenshots-${{ inputs.shard }}-${{ inputs.totalShards }}.zip
- name: Archive Test Results
# The always() ensures that this step
# runs even if the previous step fails.
Expand All @@ -57,4 +88,4 @@ runs:
with:
name: test-results-${{ inputs.shard }}-${{ inputs.totalShards }}
output: core/TestResults-${{ inputs.shard }}-${{ inputs.totalShards }}.zip
paths: core/playwright-report core/src
paths: core/playwright-report
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ runs:
# directory, including nested directories.
# It then unzips every .zip to the root directory
run: |
find . -type f -name '*.zip' -exec unzip -q -o -d ../ -- '{}' -x '*.zip' \;
find . -type f -name 'UpdatedScreenshots-*.zip' -exec unzip -q -o -d ../ {} \;
shell: bash
working-directory: ./artifacts
- name: Push Screenshots
Expand Down

0 comments on commit ff1429b

Please sign in to comment.