Skip to content

chore(toggle): fix track background, when using ion-color #133

chore(toggle): fix track background, when using ion-color

chore(toggle): fix track background, when using ion-color #133

name: E2E Screenshot Tests Pull Request
on:
pull_request:
types: [opened, synchronize, closed]
permissions:
contents: write
pull-requests: write
pages: write
id-token: write
jobs:
test:
if: github.event.action != 'closed'
timeout-minutes: 10
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/playwright:v1.56.0-noble
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm install
- run: npm run build
- run: npm install
working-directory: './demo'
- name: Run Playwright tests
run: PLAYWRIGHT_JSON_OUTPUT_NAME=e2e/screenshot.spec.ts.json npm run test:e2e -- --reporter=json,html
working-directory: ./demo
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: demo/playwright-report/
retention-days: 3
- name: Upload screenshots on failure
uses: actions/upload-artifact@v4
if: failure()
with:
name: test-results
path: demo/test-results/
retention-days: 3
- name: Comment PR with test results
uses: daun/playwright-report-comment@v3
if: always()
with:
report-file: demo/e2e/screenshot.spec.ts.json
job-summary: true
custom-info: 'Please check the [workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details. And if you want to update the screenshots, please comment with `/update-screenshots`.'
- name: Upload HTML report artifact
uses: actions/upload-artifact@v4
if: always()
with:
name: html-report-${{ github.event.pull_request.number }}
path: demo/playwright-report/
retention-days: 30
deploy-report:
needs: test
if: always() && github.event.action != 'closed'
runs-on: ubuntu-latest
steps:
- name: Download HTML report
uses: actions/download-artifact@v4
with:
name: html-report-${{ github.event.pull_request.number }}
path: playwright-report
- name: Checkout gh-pages
uses: actions/checkout@v4
with:
ref: gh-pages
path: gh-pages
continue-on-error: true
- name: Prepare GitHub Pages directory
run: |
# gh-pagesディレクトリが存在しない場合は作成
if [ ! -d "gh-pages" ]; then
mkdir -p gh-pages
fi
# PR用のディレクトリを作成(既存の場合は削除して再作成)
rm -rf gh-pages/pr-${{ github.event.pull_request.number }}
mkdir -p gh-pages/pr-${{ github.event.pull_request.number }}
cp -r playwright-report/* gh-pages/pr-${{ github.event.pull_request.number }}/
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./gh-pages
keep_files: true
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
commit_message: 'Update test report for PR #${{ github.event.pull_request.number }}'
- name: Comment PR with report link
uses: actions/github-script@v7
if: always()
with:
script: |
const prNumber = context.payload.pull_request.number;
const reportUrl = `https://${context.repo.owner}.github.io/${context.repo.repo}/pr-${prNumber}/`;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body: `📊 **Playwright Test Report**\n\nView the detailed test report: ${reportUrl}`
});
cleanup-report:
if: github.event.action == 'closed'
runs-on: ubuntu-latest
steps:
- name: Checkout gh-pages
uses: actions/checkout@v4
with:
ref: gh-pages
path: gh-pages
continue-on-error: true
- name: Remove PR report directory
run: |
if [ -d "gh-pages/pr-${{ github.event.pull_request.number }}" ]; then
rm -rf gh-pages/pr-${{ github.event.pull_request.number }}
echo "Removed report directory for PR #${{ github.event.pull_request.number }}"
else
echo "No report directory found for PR #${{ github.event.pull_request.number }}"
fi
- name: Deploy to GitHub Pages
if: hashFiles('gh-pages/**') != ''
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./gh-pages
keep_files: true
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
commit_message: 'Remove test report for closed PR #${{ github.event.pull_request.number }}'