1+ name : ' Test E2E'
2+ description : ' Test E2E'
3+ inputs :
4+ shard :
5+ description : ' Playwright Test Shard (ex: 2)'
6+ totalShards :
7+ description : ' Playwright total number of test shards (ex: 4)'
8+ update :
9+ description : ' Whether or not to update the reference snapshots'
10+ runs :
11+ using : ' composite'
12+ steps :
13+ - uses : actions/setup-node@v3
14+
15+ - name : Cache Node Modules
16+ uses : actions/cache@v3
17+ env :
18+ cache-name : node-modules
19+ with :
20+ path : ./node_modules
21+ key : ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('./package-lock.json') }}-v1
22+ - uses : ./.github/workflows/actions/download-archive
23+ with :
24+ name : ionicons-build
25+ path : .
26+ filename : IoniconsBuild.zip
27+ - uses : ./.github/workflows/actions/download-archive
28+ with :
29+ name : ionicons-src
30+ path : .
31+ filename : IoniconsSrc.zip
32+ - name : Install Playwright Dependencies
33+ run : npx playwright install && npx playwright install-deps
34+ shell : bash
35+ - name : Test
36+ if : inputs.update != 'true'
37+ run : npx playwright test --shard=${{ inputs.shard }}/${{ inputs.totalShards }}
38+ shell : bash
39+ - name : Test and Update
40+ id : test-and-update
41+ if : inputs.update == 'true'
42+ # Keep track of the files that were
43+ # changed so they can be correctly restored
44+ # in the combine step.
45+ # To do this, we move only the changed files
46+ # to a separate directory, while preserving the
47+ # directory structure of the source.
48+ # When, we create and archive of these results
49+ # so that the combine step can simply
50+ # unzip and move the changed files into place.
51+ # We have extra logic added so that job runners
52+ # that do not have any new screenshots do not create
53+ # an unnecessary .zip.
54+ run : |
55+ npx playwright test --shard=${{ inputs.shard }}/${{ inputs.totalShards }} --update-snapshots
56+ git add src/\*.png --force
57+ mkdir updated-screenshots
58+ echo 'made dir'
59+ rsync -R --progress $(git diff --name-only --cached) updated-screenshots
60+ echo 'copied images'
61+ if [ -d updated-screenshots ]; then
62+ echo "::set-output name=hasUpdatedScreenshots::$(echo 'true')"
63+ cd updated-screenshots
64+ ls
65+ zip -q -r ../UpdatedScreenshots-${{ inputs.shard }}-${{ inputs.totalShards }}.zip ./
66+ fi
67+ shell : bash
68+ - name : Archive Updated Screenshots
69+ if : inputs.update == 'true' && steps.test-and-update.outputs.hasUpdatedScreenshots == 'true'
70+ uses : actions/upload-artifact@v3
71+ with :
72+ name : updated-screenshots-${{ inputs.shard }}-${{ inputs.totalShards }}
73+ path : UpdatedScreenshots-${{ inputs.shard }}-${{ inputs.totalShards }}.zip
74+ - name : Archive Test Results
75+ # The always() ensures that this step
76+ # runs even if the previous step fails.
77+ # We want the test results to be archived
78+ # even if the test fails in the previous
79+ # step, otherwise there would be no way
80+ # to debug these tests.
81+ if : always()
82+ uses : ./.github/workflows/actions/upload-archive
83+ with :
84+ name : test-results-${{ inputs.shard }}-${{ inputs.totalShards }}
85+ output : TestResults-${{ inputs.shard }}-${{ inputs.totalShards }}.zip
86+ paths : playwright-report
0 commit comments