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

ci: integrated visual tests via playwright #670

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
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
6 changes: 5 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,9 @@
"varsIgnorePattern": "^_",
"caughtErrors": "none"
}]
}
},
"ignorePatterns": [
"**/__tests__/**/*",
"**/__stories__/**/*"
]
}
43 changes: 43 additions & 0 deletions .github/workflows/pr-visual-tests-report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: PR Visual Tests Report

on:
workflow_run:
workflows: ['PR Visual Tests']
types:
- completed

jobs:
comment:
name: Create GitHub Comment
if: github.event.workflow_run.event == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
github-token: ${{ secrets.GRAVITY_UI_BOT_GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
- name: Extract PR Number
id: pr
run: echo "::set-output name=id::$(<pr/pr-id.txt)"
shell: bash
- name: Install AWS CLI
uses: unfor19/install-aws-cli-action@v1
with:
version: 2.22.35
arch: amd64
- name: Upload to S3
env:
AWS_ACCESS_KEY_ID: ${{ secrets.STORYBOOK_S3_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.STORYBOOK_S3_SECRET_KEY }}
AWS_DEFAULT_REGION: ru-central1
AWS_EC2_METADATA_DISABLED: true
run: aws s3 cp playwright-report s3://playwright-reports/markdown-editor/pulls/${{ steps.pr.outputs.id}}/ --endpoint-url=https://storage.yandexcloud.net --recursive
shell: bash
- name: Create Comment
uses: marocchino/sticky-pull-request-comment@v2
with:
GITHUB_TOKEN: ${{ secrets.GRAVITY_UI_BOT_GITHUB_TOKEN }}
number: ${{ steps.pr.outputs.id }}
header: visual tests report
message: '[Visual Tests Report](https://storage.yandexcloud.net/playwright-reports/markdown-editor/pulls/${{ steps.pr.outputs.id }}/index.html) is ready.'
42 changes: 42 additions & 0 deletions .github/workflows/pr-visual-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: PR Visual Tests

on:
pull_request:

jobs:
visual_tests:
name: Visual Tests
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/playwright:v1.49.0-jammy
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Install Packages
run: npm ci
- name: Run Visual Tests
run: npm run playwright
env:
CI: 'true'
- name: Upload Playwright Report
if: always()
uses: actions/upload-artifact@v4
with:
name: playwright-report
path: ./playwright-report
retention-days: 1
- name: Save PR ID
if: always()
run: |
pr="${{ github.event.pull_request.number }}"
echo $pr > ./pr-id.txt
shell: bash
- name: Create PR Artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: pr
path: ./pr-id.txt
7 changes: 6 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@ async function compileTS({module, destPath}) {
];

return new Promise((resolve) => {
gulp.src(['src/**/*.{js,jsx,ts,tsx}', '!src/**/*.test.{js,jsx,ts,tsx}'])
gulp.src([
'src/**/*.{js,jsx,ts,tsx}',
'!src/**/*.test.{js,jsx,ts,tsx}',
'!src/**/__tests__/**/*',
'!src/**/__stories__/**/*',
])
.pipe(sourcemaps.init())
.pipe(
tsProject({
Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const {compilerOptions} = require('./tsconfig.json');
module.exports = {
preset: 'ts-jest/presets/js-with-ts',
testEnvironment: 'jsdom',
testPathIgnorePatterns: ['spec.js', 'spec.ts'],
testPathIgnorePatterns: ['spec.js', 'spec.ts', '__tests__', '__stories__'],
setupFilesAfterEnv: ['<rootDir>tests/setup.ts'],
moduleNameMapper: {
...pathsToModuleNameMapper(compilerOptions.paths, {prefix: '<rootDir>/'}),
Expand Down
Loading
Loading