Skip to content

Commit

Permalink
ci(efps): allow recording video in efps suite (#7606)
Browse files Browse the repository at this point in the history
### Description

Sometimes it can be really helpful to see what is going on in the eFPS
test suite. This PR adds an option to record videos for runs. It is off
by default, cause I don't think we necessarily need the videos for every
run - but we may consider changing it if we see it being really useful.

### Notes for release

None
  • Loading branch information
rexxars authored Oct 9, 2024
1 parent a17a2bd commit 39e331a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/efps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ on:
required: true
type: boolean
default: false
record_video:
description: "Record video"
required: true
type: boolean
default: false

jobs:
efps:
Expand Down Expand Up @@ -78,6 +83,7 @@ jobs:
PERF_EFPS_SANITY_TOKEN: ${{ secrets.PERF_EFPS_SANITY_TOKEN }}
REFERENCE_TAG: ${{ github.event.inputs.reference_tag || 'latest' }}
ENABLE_PROFILER: ${{ github.event.inputs.enable_profiler || false }}
RECORD_VIDEO: ${{ github.event.inputs.record_video || false }}
run: pnpm efps:test

- name: PR comment with report
Expand Down
4 changes: 4 additions & 0 deletions perf/efps/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ const HEADLESS = true
const ENABLE_PROFILER = process.env.ENABLE_PROFILER === 'true'
// eslint-disable-next-line turbo/no-undeclared-env-vars
const REFERENCE_TAG = process.env.REFERENCE_TAG || 'latest'
// eslint-disable-next-line turbo/no-undeclared-env-vars
const RECORD_VIDEO = process.env.RECORD_VIDEO === 'true'
const TESTS = [article, recipe, synthetic]

const projectId = process.env.VITE_PERF_EFPS_PROJECT_ID!
Expand Down Expand Up @@ -169,6 +171,7 @@ async function runAbTest(test: EfpsTest) {
resultsDir,
client,
headless: HEADLESS,
recordVideo: RECORD_VIDEO,
enableProfiler: ENABLE_PROFILER,
projectId,
sanityPkgPath: referenceSanityPkgPath,
Expand All @@ -189,6 +192,7 @@ async function runAbTest(test: EfpsTest) {
resultsDir,
client,
headless: HEADLESS,
recordVideo: RECORD_VIDEO,
enableProfiler: ENABLE_PROFILER,
projectId,
sanityPkgPath: experimentSanityPkgPath,
Expand Down
27 changes: 15 additions & 12 deletions perf/efps/runTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,29 @@ import {type EfpsResult, type EfpsTest, type EfpsTestRunnerContext} from './type
const workspaceDir = path.dirname(fileURLToPath(import.meta.url))

interface RunTestOptions {
test: EfpsTest
resultsDir: string
projectId: string
headless: boolean
client: SanityClient
sanityPkgPath: string
key: string
enableProfiler: boolean
headless: boolean
key: string
log: (text: string) => void
projectId: string
recordVideo: boolean
resultsDir: string
sanityPkgPath: string
test: EfpsTest
}

export async function runTest({
test,
resultsDir,
projectId,
headless,
client,
sanityPkgPath,
key,
enableProfiler,
headless,
key,
log,
projectId,
recordVideo,
resultsDir,
sanityPkgPath,
test,
}: RunTestOptions): Promise<EfpsResult[]> {
const outDir = path.join(workspaceDir, 'builds', test.name, key)
const testResultsDir = path.join(resultsDir, test.name, key)
Expand Down Expand Up @@ -75,6 +77,7 @@ export async function runTest({
log('Launching browser…')
browser = await chromium.launch({headless})
context = await browser.newContext({
recordVideo: recordVideo ? {dir: testResultsDir} : undefined,
storageState: {
cookies: [],
origins: [
Expand Down

0 comments on commit 39e331a

Please sign in to comment.