Skip to content

build: add performance-tests #31

build: add performance-tests

build: add performance-tests #31

Workflow file for this run

name: Performance Test
on:
pull_request:
types: [labeled, synchronize, opened]
branches:
- main
push:
branches:
- main
jobs:
build-react-day-picker:
if: contains(github.event.label.name, 'performance')
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up pnpm
uses: pnpm/action-setup@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
cache: pnpm
- name: Create pnpm store directory
run: mkdir -p ~/.pnpm-store
- name: Cache node_modules
uses: actions/cache@v4
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build project
run: pnpm build
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: rdp-dist
path: dist
run-performance-test:
needs: [build-react-day-picker]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Chrome
uses: browser-actions/setup-chrome@v1
id: setup-chrome
- name: Set up pnpm
uses: pnpm/action-setup@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
cache: pnpm
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: rdp-dist
path: dist
- name: Create pnpm store directory
run: mkdir -p ~/.pnpm-store
- name: Cache node_modules
uses: actions/cache@v4
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Start server
run: pnpm --filter performance-tests start-server &
env:
CHROME_PATH: ${{ steps.setup-chrome.outputs.chrome-path }}
- name: Wait for server to start
run: pnpx wait-on http://localhost:4173 --timeout 10000
- name: Create reports directory
run: mkdir -p ./reports
- name: Run performance test
run: node performance-tests/capture.mjs
env:
CHROME_PATH: ${{ steps.setup-chrome.outputs.chrome-path }}
CI: true
- name: Post comment with download link
if: success()
uses: actions/github-script@v7
with:
script: |
const artifactUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/suites/${context.runId}/artifacts/${context.runNumber}`;
const comment = `Performance test reports are available [here](${artifactUrl}).`;
github.rest.issues.createComment({
...context.repo,
issue_number: context.issue.number,
body: comment
});