From 430f2046c53c480aac6bc98f209e533a71761143 Mon Sep 17 00:00:00 2001 From: Maria Hutt Date: Tue, 13 Feb 2024 16:59:58 -0800 Subject: [PATCH 1/4] chore(github-actions): use flexible options to update screenshots --- .../actions/test-core-screenshot/action.yml | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/actions/test-core-screenshot/action.yml b/.github/workflows/actions/test-core-screenshot/action.yml index d9cf4bf6f50..5a3cdaa36fd 100644 --- a/.github/workflows/actions/test-core-screenshot/action.yml +++ b/.github/workflows/actions/test-core-screenshot/action.yml @@ -25,22 +25,22 @@ 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 all the instances of the specified component(s) in the `src/components` folder + # -- For example: if the `component` value is "item", then the following command will be: `npm run test.e2e item` + # - run the specified file path + # -- For example: if the `component` value is "src/components/item/basic", then the following command will be: `npm run test.e2e src/components/item/basic` + # - run multiple specified components based on the space-separated value + # -- For example: if the `component` value is "item basic", then the following command will be: `npm run test.e2e item basic` + # -- For example: if the `component` value is "src/components/item/basic src/components/item/advanced", then the following command will be: `npm run test.e2e src/components/item/basic src/components/item/advanced` + # + # More common options can be found at the Playwright Command line page: https://playwright.dev/docs/test-cli 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 + if [ -n "${{ inputs.component }}" ]; then + echo "testFile=\$(echo '${{ inputs.component }}' | awk '{for(i=1;i<=NF;i++) \$i=\"src/components/\"\$i}1')" >> $GITHUB_OUTPUT else echo "testFile=$(echo '')" >> $GITHUB_OUTPUT fi From b5369d39436bb009d9336713e9bcead152dba74c Mon Sep 17 00:00:00 2001 From: Maria Hutt Date: Tue, 13 Feb 2024 17:08:35 -0800 Subject: [PATCH 2/4] refactor(github-actions): use correct paths --- .github/workflows/actions/test-core-screenshot/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/actions/test-core-screenshot/action.yml b/.github/workflows/actions/test-core-screenshot/action.yml index 5a3cdaa36fd..9b3e1ddcec7 100644 --- a/.github/workflows/actions/test-core-screenshot/action.yml +++ b/.github/workflows/actions/test-core-screenshot/action.yml @@ -32,10 +32,10 @@ runs: # - run all the instances of the specified component(s) in the `src/components` folder # -- For example: if the `component` value is "item", then the following command will be: `npm run test.e2e item` # - run the specified file path - # -- For example: if the `component` value is "src/components/item/basic", then the following command will be: `npm run test.e2e src/components/item/basic` + # -- 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` # - run multiple specified components based on the space-separated value # -- For example: if the `component` value is "item basic", then the following command will be: `npm run test.e2e item basic` - # -- For example: if the `component` value is "src/components/item/basic src/components/item/advanced", then the following command will be: `npm run test.e2e src/components/item/basic src/components/item/advanced` + # -- 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` # # More common options can be found at the Playwright Command line page: https://playwright.dev/docs/test-cli run: | From 0f2b8fbc0e07f825f2115b167516a25ce93799a1 Mon Sep 17 00:00:00 2001 From: Maria Hutt Date: Fri, 8 Mar 2024 08:36:31 -0800 Subject: [PATCH 3/4] refactor(github-actions): allow paths --- .../actions/test-core-screenshot/action.yml | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/.github/workflows/actions/test-core-screenshot/action.yml b/.github/workflows/actions/test-core-screenshot/action.yml index 9b3e1ddcec7..f2eeb3f4323 100644 --- a/.github/workflows/actions/test-core-screenshot/action.yml +++ b/.github/workflows/actions/test-core-screenshot/action.yml @@ -25,8 +25,8 @@ runs: run: npm install && npx playwright install && npx playwright install-deps shell: bash working-directory: ./core - - id: set-test-file - name: Set Test File + - name: Test + if: inputs.update != 'true' # 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 instances of the specified component(s) in the `src/components` folder @@ -37,17 +37,11 @@ runs: # -- For example: if the `component` value is "item basic", then the following command will be: `npm run test.e2e item basic` # -- 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` # + # If the `component` variable is not set, then the test will run all the instances of the components in the `src/components` folder. + # - For example: `npm run test.e2e` + # # More common options can be found at the Playwright Command line page: https://playwright.dev/docs/test-cli - run: | - if [ -n "${{ inputs.component }}" ]; then - echo "testFile=\$(echo '${{ inputs.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 ${{ steps.set-test-file.outputs.testFile }} -- --shard=${{ inputs.shard }}/${{ inputs.totalShards }} + run: npm run test.e2e ${{ inputs.component }} -- --shard=${{ inputs.shard }}/${{ inputs.totalShards }} shell: bash working-directory: ./core - name: Test and Update From c9ba1a85666a36d1f074596641f075d1b62e39a1 Mon Sep 17 00:00:00 2001 From: Maria Hutt Date: Fri, 8 Mar 2024 09:11:18 -0800 Subject: [PATCH 4/4] refactor(github-actions): remove old variable --- .../actions/test-core-screenshot/action.yml | 16 +--------------- .github/workflows/update-screenshots.yml | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/actions/test-core-screenshot/action.yml b/.github/workflows/actions/test-core-screenshot/action.yml index 226b527eb64..a0d3554b81c 100644 --- a/.github/workflows/actions/test-core-screenshot/action.yml +++ b/.github/workflows/actions/test-core-screenshot/action.yml @@ -27,20 +27,6 @@ runs: working-directory: ./core - name: Test if: inputs.update != 'true' - # 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 instances of the specified component(s) in the `src/components` folder - # -- For example: if the `component` value is "item", then the following command will be: `npm run test.e2e item` - # - run the specified file path - # -- 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` - # - run multiple specified components based on the space-separated value - # -- For example: if the `component` value is "item basic", then the following command will be: `npm run test.e2e item basic` - # -- 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` - # - # If the `component` variable is not set, then the test will run all the instances of the components in the `src/components` folder. - # - For example: `npm run test.e2e` - # - # More common options can be found at the Playwright Command line page: https://playwright.dev/docs/test-cli run: npm run test.e2e ${{ inputs.component }} -- --shard=${{ inputs.shard }}/${{ inputs.totalShards }} shell: bash working-directory: ./core @@ -63,7 +49,7 @@ runs: # which is why we not using the upload-archive # composite step here. run: | - npm run test.e2e ${{ steps.set-test-file.outputs.testFile }} -- --shard=${{ inputs.shard }}/${{ inputs.totalShards }} --update-snapshots + npm run test.e2e ${{ inputs.component }} -- --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 diff --git a/.github/workflows/update-screenshots.yml b/.github/workflows/update-screenshots.yml index bce7f324f2b..5bb35c5905a 100644 --- a/.github/workflows/update-screenshots.yml +++ b/.github/workflows/update-screenshots.yml @@ -3,6 +3,20 @@ name: 'Update Reference Screenshots' on: workflow_dispatch: inputs: + # 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 instances of the specified component(s) in the `src/components` folder + # -- For example: if the `component` value is "item", then the following command will be: `npm run test.e2e item` + # - run the specified file path + # -- 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` + # - run multiple specified components based on the space-separated value + # -- For example: if the `component` value is "item basic", then the following command will be: `npm run test.e2e item basic` + # -- 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` + # + # If the `component` variable is not set, then the test will run all the instances of the components in the `src/components` folder. + # - For example: `npm run test.e2e` + # + # More common options can be found at the Playwright Command line page: https://playwright.dev/docs/test-cli component: description: 'What component(s) should be updated? (leave blank to update all or use a space-separated list for multiple components)' required: false