Skip to content

Commit b52a04d

Browse files
authored
chore: setup playwright (#236)
1 parent 8faaa4b commit b52a04d

File tree

14 files changed

+1048
-31
lines changed

14 files changed

+1048
-31
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: PR Visual Tests Report
2+
3+
on:
4+
workflow_run:
5+
workflows: ['PR Visual Tests']
6+
types:
7+
- completed
8+
9+
jobs:
10+
comment:
11+
name: Create GitHub Comment
12+
if: github.event.workflow_run.event == 'pull_request'
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Generate token
16+
id: generate-token
17+
uses: actions/create-github-app-token@v2
18+
with:
19+
app-id: ${{ secrets.GRAVITY_UI_APP_ID }}
20+
private-key: ${{ secrets.GRAVITY_UI_APP_PRIVATE_KEY }}
21+
- name: Download Artifacts
22+
uses: actions/download-artifact@v4
23+
with:
24+
github-token: ${{ steps.generate-token.outputs.token }}
25+
run-id: ${{ github.event.workflow_run.id }}
26+
- name: Extract PR Number
27+
id: pr
28+
run: echo "::set-output name=id::$(<pr/pr-id.txt)"
29+
shell: bash
30+
- name: Install AWS CLI
31+
uses: unfor19/install-aws-cli-action@v1
32+
with:
33+
version: 2.22.35
34+
arch: amd64
35+
- name: Upload to S3
36+
env:
37+
AWS_ACCESS_KEY_ID: ${{ secrets.STORYBOOK_S3_KEY_ID }}
38+
AWS_SECRET_ACCESS_KEY: ${{ secrets.STORYBOOK_S3_SECRET_KEY }}
39+
AWS_DEFAULT_REGION: ru-central1
40+
AWS_EC2_METADATA_DISABLED: true
41+
run: aws s3 cp playwright-report s3://playwright-reports/date-components/pulls/${{ steps.pr.outputs.id}}/ --endpoint-url=https://storage.yandexcloud.net --recursive
42+
shell: bash
43+
- name: Create Comment
44+
uses: marocchino/sticky-pull-request-comment@v2
45+
with:
46+
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
47+
number: ${{ steps.pr.outputs.id }}
48+
header: visual tests report
49+
message: '[Visual Tests Report](https://storage.yandexcloud.net/playwright-reports/date-components/pulls/${{ steps.pr.outputs.id }}/index.html) is ready.'
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: PR Visual Tests
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
visual-tests-prepare:
8+
name: Detect Playwright Version
9+
runs-on: ubuntu-latest
10+
outputs:
11+
playwright-version: ${{ steps.detect-playwright-version.outputs.version }}
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Setup Node.js from .nvmrc
15+
uses: actions/setup-node@v4
16+
with:
17+
node-version-file: '.nvmrc'
18+
cache: 'npm'
19+
- name: Install Packages
20+
run: npm ci
21+
- name: Detect Playwright version
22+
id: detect-playwright-version
23+
run: |
24+
VERSION=$(./scripts/playwright-version.sh)
25+
echo "version=$VERSION" >> $GITHUB_OUTPUT
26+
echo "Detected Playwright version: $VERSION"
27+
28+
visual-tests:
29+
name: Visual Tests
30+
runs-on: ubuntu-latest
31+
needs: visual-tests-prepare
32+
container:
33+
image: mcr.microsoft.com/playwright:v${{ needs.visual-tests-prepare.outputs.playwright-version }}-jammy
34+
steps:
35+
- uses: actions/checkout@v4
36+
- name: Install Packages
37+
run: npm ci
38+
- name: Run Visual Tests
39+
run: npm run playwright
40+
env:
41+
CI: 'true'
42+
- name: Upload Playwright Report
43+
if: always()
44+
uses: actions/upload-artifact@v4
45+
with:
46+
name: playwright-report
47+
path: ./playwright-report
48+
retention-days: 1
49+
- name: Save PR ID
50+
if: always()
51+
run: |
52+
pr="${{ github.event.pull_request.number }}"
53+
echo $pr > ./pr-id.txt
54+
shell: bash
55+
- name: Create PR Artifact
56+
if: always()
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: pr
60+
path: ./pr-id.txt

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,13 @@ node_modules
99
dist
1010
storybook-static
1111
.cache
12+
13+
# Playwright
14+
playwright-report
15+
playwright-report-docker
16+
playwright/.cache-docker
17+
playwright/.cache/
18+
test-results
19+
20+
# System files
21+
.DS_Store

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const config = {
2020
moduleNameMapper: {
2121
'\\.(css|less|scss|sass)$': 'jest-transform-css',
2222
},
23-
testMatch: ['**/*.test.[jt]s?(x)'],
23+
testMatch: ['**/*.test.[jt]s?(x)', '!**/*.visual.test.[jt]s?(x)'],
2424
};
2525

2626
module.exports = config;

0 commit comments

Comments
 (0)