Skip to content

Commit

Permalink
[FEATURE] Snapshots Rework (#691)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdamner authored Oct 8, 2023
2 parents 8c2dcc6 + 0519101 commit d129282
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 15 deletions.
18 changes: 3 additions & 15 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,10 @@ jobs:
require_tests: false
job_name: ${{ matrix.playwright }} Results
- name: Update Snapshots
uses: ./.github/actions/update-snapshots
if: ${{ always() && contains(steps.tests.outcome, 'failure') }}
run: npx playwright test --project=${{ matrix.playwright }} --update-snapshots
- name: Create pr
if : ${{ always() && contains(steps.tests.outcome, 'failure') }}
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git config --global push.autoSetupRemote true
git checkout -b $BRANCH_NAME
git add .
git commit -m "Update Snapshots for ${{ matrix.playwright }}"
git push origin
gh pr create --title "Update Snapshots" --body "Automated update of snapshots for ${{ matrix.playwright }}" --base ${{ github.event.pull_request.head.ref }} --head $BRANCH_NAME --label "snapshots"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH_NAME: update-snapshots/${{ matrix.playwright}}/${{ github.sha }}
with:
base-branch: ${{ github.event.pull_request.base.ref }}
report:
name: Report Test Results
runs-on: ubuntu-latest
Expand Down
44 changes: 44 additions & 0 deletions .github/workflows/update-snapshots.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Update Snapshots

on:
workflow_call:
workflows: ["Test"]
inputs:
base-branch:
description: 'The name of the branch to create the PR against'
required: true
type: string

permissions:
contents: write
pull-requests: write
checks: write
issues: write

jobs:
update-snapshots:
name: Update Snapshots
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.base-branch }}
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'
- name: Install dependencies
run: npm ci && npx playwright install --with-deps
- name: Update Snapshots
run: npx playwright test --update-snapshots
- name: Create Or Update PR
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git checkout -b update-snapshots-${{ github.event.inputs.base-branch }}
git add .
git commit -m "Update snapshots"
git push origin update-snapshots --force
gh pr create --title "Update snapshots" --body "This PR updates the snapshots for the ${{ github.event.inputs.base-branch }} branch" --base ${{ github.event.inputs.base-branch }} --head update-snapshots --repo ${{ github.repository }}

0 comments on commit d129282

Please sign in to comment.