Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions .github/workflows/actions/test-core-screenshot/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ inputs:
description: 'Playwright total number of test shards (ex: 4)'
update:
description: 'Whether or not to update the reference snapshots'
component:
description: 'The component to update the reference snapshots'

runs:
using: 'composite'
Expand All @@ -23,9 +25,29 @@ runs:
run: npm install && npx playwright install && npx playwright install-deps
shell: bash
working-directory: ./core
- id: clean-component-name
name: Clean Component Name
# Remove `ion-` prefix from the `component` variable if it exists.
run: |
echo "component=$(echo ${{ inputs.component }} | sed 's/ion-//g')" >> $GITHUB_OUTPUT
shell: bash
- id: set-test-file
name: Set Test File
# Screenshots can be updated for all components or specified component(s).
# If the `component` variable is set, then the test has the option to
# - run all the file paths that are in a component folder.
# -- 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.
# -- 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.
run: |
if [ -n "${{ steps.clean-component-name.outputs.component }}" ]; then
echo "testFile=\$(echo '${{ steps.clean-component-name.outputs.component }}' | awk '{for(i=1;i<=NF;i++) \$i=\"src/components/\"\$i}1')" >> $GITHUB_OUTPUT
else
echo "testFile=$(echo '')" >> $GITHUB_OUTPUT
fi
shell: bash
- name: Test
if: inputs.update != 'true'
run: npm run test.e2e -- --shard=${{ inputs.shard }}/${{ inputs.totalShards }}
run: npm run test.e2e ${{ steps.set-test-file.outputs.testFile }} -- --shard=${{ inputs.shard }}/${{ inputs.totalShards }}
shell: bash
working-directory: ./core
- name: Test and Update
Expand All @@ -47,7 +69,7 @@ runs:
# which is why we not using the upload-archive
# composite step here.
run: |
npm run test.e2e -- --shard=${{ inputs.shard }}/${{ inputs.totalShards }} --update-snapshots
npm run test.e2e ${{ steps.set-test-file.outputs.testFile }} -- --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
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/update-screenshots.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ name: 'Update Reference Screenshots'

on:
workflow_dispatch:
inputs:
component:
description: 'What component(s) should be updated? (leave blank to update all or use a space-separated list for multiple components)'
required: false
default: ''

jobs:
build-core:
Expand Down Expand Up @@ -34,6 +39,7 @@ jobs:
shard: ${{ matrix.shard }}
totalShards: ${{ matrix.totalShards }}
update: true
component: ${{ inputs.component }}

update-reference-screenshots:
runs-on: ubuntu-latest
Expand Down