Skip to content

Commit

Permalink
chore(e2e): add an option to update snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
ala-n committed Feb 12, 2024
1 parent 4b90863 commit ed2ecf3
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ on:
push:
branches: [ main, main-beta, epic/* ]
workflow_dispatch:
inputs:
updateSnapshots:
type: boolean
default: false
required: false
description: 'Update snapshots during the run on the current brunch'

env:
node-version: 20.x
Expand All @@ -19,6 +25,7 @@ jobs:
e2e-tests:
name: Automation Testing
runs-on: ubuntu-latest
if: ${{ !inputs.updateSnapshots }}

steps:
- uses: actions/checkout@v4
Expand All @@ -37,7 +44,7 @@ jobs:
with:
name: automation-diff-report
path: e2e/.diff
- name: Deploy latest report to branch
- name: Deploy latest issued report to branch
if: failure()
uses: peaceiris/actions-gh-pages@v3
with:
Expand All @@ -49,3 +56,31 @@ jobs:
shell: bash
run: |
cat e2e/.diff/index.md >> $GITHUB_STEP_SUMMARY
e2e-tests-update-snapshots:
name: Update Automation Testing Snapshots
runs-on: ubuntu-latest
if: ${{ github.event_name == 'workflow_dispatch' && inputs.updateSnapshots }}

steps:
- uses: actions/checkout@v4
- name: Use Node v${{ env.node-version }}
uses: actions/setup-node@v4
with:
cache: 'npm'
node-version: ${{ env.node-version }}
- name: Install NPM Dependencies
run: npm ci
- name: Update Test Snapshots
run: npm run test:e2e -- -u
- name: Commit & Push Snapshot Changes
uses: actions/github-script@v5
with:
script: |
const git = require('simple-git')();
const currentBranch = '${{ github.ref }}'.split('/').pop();
await git.addConfig('user.email', '${{ github.actor }}@users.noreply.github.com');
await git.addConfig('user.name', '${{ github.actor }}');
await git.add('*.png');
await git.commit('test(e2e): update snapshots (via GitHub Actions))');
await git.push('origin', currentBranch);

0 comments on commit ed2ecf3

Please sign in to comment.