Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding the update-snapshot workflow #327

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
3 changes: 2 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ permissions:
pages: write
id-token: write
deployments: write

jobs:
build:
runs-on: macos-latest
Expand Down Expand Up @@ -61,7 +62,7 @@ jobs:
path: playwright-report/
retention-days: 30
- if: ${{ failure() && steps.screenshot_tests.conclusion == 'failure' }}
run: npm run test.int -- --grep @screenshots --update-snapshots
run: npm run test.int -- --grep @screenshots --update-snapshots --last-failed
- if: ${{ failure() && steps.screenshot_tests.conclusion == 'failure' }}
name: Upload screens
uses: actions/upload-artifact@v4
Expand Down
68 changes: 51 additions & 17 deletions .github/workflows/update-snapshots.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:
inputs:
pr_number:
description: 'Pull Request Number'
description: 'Pull Request Number (Warning: This action will push a commit to the referenced PR)'
required: true
type: string

Expand All @@ -17,25 +17,59 @@ jobs:
name: Update PR Snapshots
runs-on: macos-latest
steps:
- name: Checkout PR
- uses: actions/checkout@v3
- name: Checkout PR ${{ github.event.inputs.pr_number }}
if: github.event_name == 'workflow_dispatch'
run: gh pr checkout ${{ github.event.inputs.pr_number }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Run command
if: github.event_name == 'workflow_dispatch'
- name: Use Node.js from .nvmrc
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'

- name: Cache node modules
id: cache-npm
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}

- name: Install dependencies
run: npm ci

- name: Build all
run: npm run build && npm run build.debug

- name: Fetch fonts
run: npm run fetch-fonts

- name: Install Playwright Browsers
run: npx playwright install --with-deps

- name: Run Screenshot tests
id: screenshot_tests
run: npm run test.int -- screenshots.js --grep @screenshots

- if: ${{ failure() && steps.screenshot_tests.conclusion == 'success' }}
run: |
echo "nothing to update - tests all passed"

- name: Re-Running Playwright to update snapshots
id: screenshot_tests_update
if: ${{ failure() && steps.screenshot_tests.conclusion == 'failure' }}
run: npm run test.int -- screenshots.js --grep @screenshots --update-snapshots --last-failed

- name: Commit the updated files to the PR branch
if: ${{ failure() && steps.screenshot_tests_update.conclusion == 'success' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Running A command here command..."

# Step 5: Commit and push changes back to the PR branch

# - name: Commit and push changes
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# run: |
# git config user.name "github-actions[bot]"
# git config user.email "github-actions[bot]@users.noreply.github.com"
# git add .
# git commit -m "Automated updates from GitHub Actions"
# git push origin ${{ env.PR_BRANCH }}
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add integration-tests/*
git commit -m "Updated snapshots via workflow"
git push origin HEAD
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ build/
build/app_backup
bslive.yml
.vscode
/json-reports
Loading