Skip to content

Merge branch 'playwright-visual-tests' of https://github.com/capitec/… #46

Merge branch 'playwright-visual-tests' of https://github.com/capitec/…

Merge branch 'playwright-visual-tests' of https://github.com/capitec/… #46

Workflow file for this run

name: Generate Playwright Screenshots
env:
PW_COMPONENT_FILTER:
on:
push:
branches-ignore: [ main,develop,alpha ]
paths:
- '**/*.spec.ts'
- '**/*.spec.js'
- '**/OmniInputPlaywright.ts'
- '**/JestPlaywright.ts'
- 'playwright.config.js'
- '.github/workflows/add-screenshots.yml'
# Allows you to run this workflow manually from the Actions tab.
workflow_dispatch:
jobs:
screenshot-add:
if: github.event_name != 'workflow_dispatch' || (github.ref != 'refs/heads/main' && github.ref != 'refs/heads/develop' && github.ref != 'refs/heads/alpha')
name: "Add Missing Screenshots"
timeout-minutes: 60
runs-on: macos-latest
steps:
- name: Configure OS
run: |
echo "Setting CGFontDisableAntialiasing"
defaults write CoreGraphics CGFontDisableAntialiasing YES
echo "Disabling AppleFontSmoothing"
defaults write -g AppleFontSmoothing -int 0
echo "Completed OS configure"
- name: Dump env 💩
run: env | sort
- name: Dump GitHub context 💩
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- name: Checkout 🛎️
uses: actions/checkout@v3
with:
persist-credentials: true
fetch-depth: 0
token: ${{ secrets.PROTECTED_TOKEN }}
- name: Ensure branch up to date 🌿
# Only on branches
if: ${{ startsWith(github.ref, 'refs/heads/') }}
run: |
git pull
- name: Use Node.js 16.x ✔
uses: actions/setup-node@v3
with:
node-version: 16.x
registry-url: 'https://registry.npmjs.org'
always-auth: true
- name: Install Package Dependencies
run: |
npm ci --force
- uses: actions/github-script@v6
id: get-component-filter
with:
script: |
const path = require('path');
const { execSync } = require('child_process');
const ghCtx = ${{ toJson(github) }};
const files = [];
let list = '';
if (ghCtx.event_name === 'workflow_dispatch') {
try {
const response = await github.request(`GET /repos/${ghCtx.repository}/actions/runs`);
const before = response.data.workflow_runs.find(wr => wr.name === ghCtx.workflow && wr.id !== ghCtx.run_id && wr.head_sha && wr.head_sha !== ghCtx.sha && wr.head_branch === ghCtx.ref_name)?.head_sha;
if (before) {
list = execSync(`git diff-tree --no-commit-id --name-only -r ${before} ${ghCtx.sha}`).toString();
}
} catch (error) {
}
} else {
list = execSync(`git diff-tree --no-commit-id --name-only -r ${ghCtx.event.before} ${ghCtx.event.after}`).toString();
}
if (list.includes('src/core')) {
return '';
} else {
list.split(/(\r\n|\n|\r)/gm).forEach(f => {
if (f.startsWith('src') && !f.startsWith('src/utils') && !f.endsWith('index.ts') && f.endsWith('.ts')) {
const filter = path.basename(f).replace('.stories', '').replace('.spec', '').replace('.ts', '');
if (!files.includes(filter)) {
files.push(filter);
}
}
});
const testFilter = files.join(' ');
return testFilter;
}
return '';
result-encoding: string
- name: Update PW_COMPONENT_FILTER
run: |
PW_COMPONENT_FILTER="${{steps.get-component-filter.outputs.result}}"
echo PW_COMPONENT_FILTER=${PW_COMPONENT_FILTER} >> $GITHUB_ENV
- name: Install Playwright Chrome Dependencies
run: npx playwright install --with-deps
- name: Run Tests
run: npm run test:add-screenshots
env:
CI: true
PW_NO_RETRIES: true
- name: Auto Commit Changes 👩‍💻
uses: stefanzweifel/git-auto-commit-action@v4
# Only on branches even when failed
if: ${{ always() && startsWith(github.ref, 'refs/heads/') }}
with:
commit_message: Added Missing Screenshots
branch: ${{ env.GITHUB_REF_NAME }}
file_pattern: '*.png'