diff --git a/.github/workflows/update-visual-test-snapshots.yml b/.github/workflows/update-visual-test-snapshots.yml new file mode 100644 index 000000000..6e0cc42ed --- /dev/null +++ b/.github/workflows/update-visual-test-snapshots.yml @@ -0,0 +1,48 @@ +# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and update visual test snapshots for playwright tests. +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions + +permissions: + contents: write + packages: write + id-token: write + +name: Update Visual Test Snapshots +on: + workflow_dispatch: # Allow manual triggers + inputs: + target_branch: + description: "The branch to push the updated snapshots to" + required: true + type: string + +jobs: + update_snapshots: + runs-on: ubuntu-latest + container: + image: mcr.microsoft.com/playwright:v1.32.1-focal + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Node.js + uses: ./.github/actions/node-step + with: + npm-auth-token: ${{ secrets.NPM_TOKEN }} + + - name: Install browsers + run: npx playwright install --with-deps chromium firefox webkit + shell: bash + + - name: Run update snapshots + run: HOME=/root npm run e2e-update-snapshots + + - name: Push Changes to target branch + run: | + git config --global --add safe.directory /__w/golden-sample-app/golden-sample-app + git checkout ${{ github.event.inputs.target_branch }} + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add -A + git commit -m "Update Playwright visual test snapshots" + git push origin ${{ github.event.inputs.target_branch }} diff --git a/package.json b/package.json index c3894731f..fc3ccdc96 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "e2e-test-sndbx-all": "nx run golden-sample-app-e2e:e2e-localhost-ebp-sndbx", "e2e-test-sndbx-ci": "nx run golden-sample-app-e2e:e2e-localhost-ebp-sndbx --args='test --config=playwright.localhost.config.ts --project=localhost-ebp-sndbx --grep=@identity'", "e2e-test-responsive": "npx playwright test --project 'mobile-chrome' --grep '@visual.+@responsive|@responsive.+@visual' --workers=2", + "e2e-update-snapshots": "npx playwright test --project 'mobile-chrome' --grep '@visual' --update-snapshots --workers=1", "lint": "nx run-many --all --target=lint", "format": "prettier --write \"{apps,libs}/**/*.{ts,md,html}\" \"!{apps,libs}/**/coverage\" ", "format:check": "prettier --list-different \"{apps,libs}/**/*.{ts,md}\" \"!{apps,libs}/**/coverage\"",