-
Notifications
You must be signed in to change notification settings - Fork 0
Visual Regression Testの導入 #183
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
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1ae5f34
feat: set engines
mii288 8f4cc39
feat: update node version
mii288 b9de8be
feat(vrt): add tests for capturing screenshots
mii288 3598ed2
feat(vrt): add GH workflow for VRT
mii288 8d60d70
feat(vrt): deploy reg report to Netlify
mii288 a28c670
refactor(ci): use ./.github/actions/setup
mii288 2217e89
fix(ci): fix warning
mii288 d7d08f9
feat: pull requestのときのみDeploy Previewを実施しPR上でURLを確認できるようにする
mii288 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| name: Deploy to Netlify | ||
|
|
||
| description: Deploy to Netlify | ||
|
|
||
| inputs: | ||
| publish-dir: | ||
| description: e.g. "dist", "_site" | ||
| required: true | ||
| netlify-auth-token: | ||
| description: Required The token to use for authentication. | ||
| required: true | ||
| netlify-site-id: | ||
| description: API site ID of the site you wanna work on | ||
| required: true | ||
|
|
||
| outputs: | ||
| netlify-url: | ||
| value: ${{ steps.result.outputs.deploy-url }} | ||
| description: the URL of the draft site that Netlify provides | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| clean: false | ||
| - name: Deploy to Netlify | ||
| id: netlify | ||
| # FYI: https://github.com/netlify/actions/pull/65 | ||
| uses: South-Paw/action-netlify-cli@v2 | ||
| with: | ||
| args: 'deploy --json --dir \"${{ inputs.publish-dir }}\" --message \"VRT report [${{ github.sha }}]\"' | ||
| env: | ||
| NETLIFY_AUTH_TOKEN: ${{ inputs.netlify-auth-token }} | ||
| NETLIFY_SITE_ID: ${{ inputs.netlify-site-id }} | ||
| - name: Set outputs | ||
| id: result | ||
| shell: bash | ||
| run: echo "deploy-url=${{ fromJson(steps.netlify.outputs.NETLIFY_OUTPUT).deploy_url }}" >> "$GITHUB_OUTPUT" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| name: Setup | ||
|
|
||
| description: Setup environment | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version-file: package.json | ||
| - name: Cache node modules | ||
| id: node_modules_cache_id | ||
| uses: actions/cache@v4 | ||
| env: | ||
| cache-name: cache-node-modules | ||
| with: | ||
| path: '**/node_modules' | ||
| key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | ||
| - if: ${{ steps.node_modules_cache_id.outputs.cache-hit != 'true' }} | ||
|
YuMuuu marked this conversation as resolved.
|
||
| shell: bash | ||
| run: npm ci | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
YuMuuu marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| name: Visual Regression Testing | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize] | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| container: | ||
| image: mcr.microsoft.com/playwright:v1.45.1-jammy | ||
| timeout-minutes: 60 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Install Japanese fonts | ||
| run: | | ||
| apt-get update | ||
| apt-get purge -y fonts-wqy-zenhei fonts-ipafont-gothic | ||
| apt-get install -y fonts-noto-cjk-extra | ||
| fc-cache -fv | ||
|
YuMuuu marked this conversation as resolved.
|
||
| - uses: ./.github/actions/setup | ||
| - name: Run visual tests | ||
| continue-on-error: true | ||
| id: vrt | ||
| run: npm run test:vrt | ||
| - uses: ./.github/actions/netlify | ||
| id: netlify | ||
| timeout-minutes: 1 | ||
| with: | ||
| publish-dir: ./.reg | ||
| netlify-auth-token: ${{ secrets.NETLIFY_AUTH_TOKEN }} | ||
| netlify-site-id: ${{ secrets.NETLIFY_SITE_ID }} | ||
| - if: ${{ steps.vrt.outcome == 'success' }} | ||
| name: Comment PR if success | ||
| uses: thollander/actions-comment-pull-request@v2 | ||
| with: | ||
| message: | | ||
| **✨✨ That's perfect, there is no visual difference! ✨✨** | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. reg-suit の通知プラグインのテキストを流用 |
||
| You can check [this report](${{ steps.netlify.outputs.netlify-url }}) out here. | ||
| comment_tag: test-report-vrt | ||
| - if: ${{ steps.vrt.outcome == 'failure' }} | ||
| name: Comment PR if failure | ||
| uses: thollander/actions-comment-pull-request@v2 | ||
| with: | ||
| message: | | ||
| **reg-suit detected visual differences.** | ||
| Check [this report](${{ steps.netlify.outputs.netlify-url }}), and review them. | ||
| comment_tag: test-report-vrt | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 18.16.0 | ||
| 20.16.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| engine-strict=true |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
このリポジトリで使われている nwtgck/actions-netlify だと、ドット始まりのフォルダがうまくアップロードできなかったので、 別のGithub Actionsを使いました。
最初はNetlifyの公式アクションを使おうと思ったんですが、ちょっとメンテされてないのかWarningが出ていた( netlify/actions#65 )ので、それが修正された South-Paw/action-netlify-cli を使ってます。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
似たような機能のactionを複数利用していると、分かりにくなるのでこの機会に、CIでのtest deployを行なっているactionもSouth-Paw/action-netlify-cli に修正していただけると助かります🙏
oystersjp.github.io/.github/workflows/CI.yml
Line 21 in 2217e89
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
だったので、pull request作成時のみDeploy Previewを作成するように振る舞いを変更しました。(もとの振る舞いのほうがよさそうなら戻します)
↓の用な感じでPRを作成・更新するとDeploy Previewについてのコメントがされて確認できます。
#183 (comment)