Skip to content

Commit 73d661a

Browse files
authored
chore(github-actions): use flexible options to update screenshots (#29044)
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. --> GitHub actions allow screenshots to be updated either by updating all the components or providing a component name. If a component name is given, then the screenshots will only be updated on `src/components/{component-name}`. This isn't ideal when wanting to update a specific path. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - The script no longer strips out `ion-`. The developer needs to submit a valid component name or valid path. - The script no longer appends the value to `src/components/` - The script will run all instances of a component if only the name is given - The script will run tests within a given path ## Does this introduce a breaking change? - [ ] Yes - [x] No <!-- If this introduces a breaking change: 1. Describe the impact and migration path for existing applications below. 2. Update the BREAKING.md file with the breaking change. 3. Add "BREAKING CHANGE: [...]" to the commit description when merging. See https://github.com/ionic-team/ionic-framework/blob/main/.github/CONTRIBUTING.md#footer for more information. --> ## Other information <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. --> How to test: 1. Create a new branch based off this one 2. Make a style change 3. Push it to the new branch 4. Update the reference images using the new branch 5. This will show you all the options Recommended to test: - a component name (`chip`) - a path (`src/components/chip/test/a11y`) - a component that doesn't exist (`random-component`) - no provided component, leave the first input blank
1 parent fc5d692 commit 73d661a

File tree

2 files changed

+16
-22
lines changed

2 files changed

+16
-22
lines changed

.github/workflows/actions/test-core-screenshot/action.yml

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,29 +25,9 @@ runs:
2525
run: npm install
2626
shell: bash
2727
working-directory: ./core
28-
- id: clean-component-name
29-
name: Clean Component Name
30-
# Remove `ion-` prefix from the `component` variable if it exists.
31-
run: |
32-
echo "component=$(echo ${{ inputs.component }} | sed 's/ion-//g')" >> $GITHUB_OUTPUT
33-
shell: bash
34-
- id: set-test-file
35-
name: Set Test File
36-
# Screenshots can be updated for all components or specified component(s).
37-
# If the `component` variable is set, then the test has the option to
38-
# - run all the file paths that are in a component folder.
39-
# -- For example: if the `component` value is "item", then the test will run all the file paths that are in the "src/components/item" folder.
40-
# -- For example: if the `component` value is "item chip", then the test will run all the file paths that are in the "src/components/item" and "src/components/chip" folders.
41-
run: |
42-
if [ -n "${{ steps.clean-component-name.outputs.component }}" ]; then
43-
echo "testFile=\$(echo '${{ steps.clean-component-name.outputs.component }}' | awk '{for(i=1;i<=NF;i++) \$i=\"src/components/\"\$i}1')" >> $GITHUB_OUTPUT
44-
else
45-
echo "testFile=$(echo '')" >> $GITHUB_OUTPUT
46-
fi
47-
shell: bash
4828
- name: Test
4929
if: inputs.update != 'true'
50-
run: npm run test.e2e.docker.ci ${{ steps.set-test-file.outputs.testFile }} -- --shard=${{ inputs.shard }}/${{ inputs.totalShards }}
30+
run: npm run test.e2e.docker.ci ${{ inputs.component }} -- --shard=${{ inputs.shard }}/${{ inputs.totalShards }}
5131
shell: bash
5232
working-directory: ./core
5333
- name: Test and Update
@@ -69,7 +49,7 @@ runs:
6949
# which is why we not using the upload-archive
7050
# composite step here.
7151
run: |
72-
npm run test.e2e.docker.ci ${{ steps.set-test-file.outputs.testFile }} -- --shard=${{ inputs.shard }}/${{ inputs.totalShards }} --update-snapshots
52+
npm run test.e2e.docker.ci ${{ inputs.component }} -- --shard=${{ inputs.shard }}/${{ inputs.totalShards }} --update-snapshots
7353
git add src/\*.png --force
7454
mkdir updated-screenshots
7555
cd ../ && rsync -R --progress $(git diff --name-only --cached) core/updated-screenshots

.github/workflows/update-screenshots.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,20 @@ name: 'Update Reference Screenshots'
33
on:
44
workflow_dispatch:
55
inputs:
6+
# Screenshots can be updated for all components or specified component(s).
7+
# If the `component` variable is set, then the test has the option to
8+
# - run all the instances of the specified component(s) in the `src/components` folder
9+
# -- For example: if the `component` value is "item", then the following command will be: `npm run test.e2e item`
10+
# - run the specified file path
11+
# -- For example: if the `component` value is "src/components/item/test/basic", then the following command will be: `npm run test.e2e src/components/item/test/basic`
12+
# - run multiple specified components based on the space-separated value
13+
# -- For example: if the `component` value is "item basic", then the following command will be: `npm run test.e2e item basic`
14+
# -- For example: if the `component` value is "src/components/item/test/basic src/components/item/test/a11y", then the following command will be: `npm run test.e2e src/components/item/test/basic src/components/item/test/a11y`
15+
#
16+
# If the `component` variable is not set, then the test will run all the instances of the components in the `src/components` folder.
17+
# - For example: `npm run test.e2e`
18+
#
19+
# More common options can be found at the Playwright Command line page: https://playwright.dev/docs/test-cli
620
component:
721
description: 'What component(s) should be updated? (leave blank to update all or use a space-separated list for multiple components)'
822
required: false

0 commit comments

Comments
 (0)