Skip to content

feat(tests): enhance CI workflow and Playwright configuration#279

Merged
yamcodes merged 2 commits intomainfrom
fix-a11y-tests
Nov 4, 2025
Merged

feat(tests): enhance CI workflow and Playwright configuration#279
yamcodes merged 2 commits intomainfrom
fix-a11y-tests

Conversation

@yamcodes
Copy link
Owner

@yamcodes yamcodes commented Nov 4, 2025

  • Added a build step for the www app in the CI workflow to ensure the application is built before running tests.
  • Updated Playwright configuration to support different server modes for CI and local development, improving stability and performance.
  • Enhanced README documentation to clarify the web server configuration for testing environments.

This update optimizes the testing process by ensuring a production build is used in CI, while allowing for a development server in local environments, thus improving developer experience and CI reliability.

Summary by CodeRabbit

  • Tests

    • Switched CI test runs to a unified command, added an explicit build step for PR e2e runs, and refined CI vs. local test behavior with improved timeouts and failure-based artifacts (videos/screenshots).
  • Documentation

    • Expanded testing docs with build requirements, CI vs. local server guidance, troubleshooting for web server timeouts, and reporter/artifact configuration.

- Added a build step for the www app in the CI workflow to ensure the application is built before running tests.
- Updated Playwright configuration to support different server modes for CI and local development, improving stability and performance.
- Enhanced README documentation to clarify the web server configuration for testing environments.

This update optimizes the testing process by ensuring a production build is used in CI, while allowing for a development server in local environments, thus improving developer experience and CI reliability.
@changeset-bot
Copy link

changeset-bot bot commented Nov 4, 2025

⚠️ No Changeset found

Latest commit: f12f47d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Nov 4, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
arkenv Ready Ready Preview Comment Nov 4, 2025 7:48pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 4, 2025

Walkthrough

Adds a pnpm build step to CI e2e tests and refines Playwright configuration and README to distinguish CI vs local webServer behavior, timeouts, reporters, and artifact capture policies.

Changes

Cohort / File(s) Summary
CI Workflow
.github/workflows/tests.yml
Replace turbo run test with pnpm run test across jobs; add pnpm --filter=www run build --filter=... production build step before Playwright e2e tests when running PRs.
Playwright config
tooling/playwright-www/playwright.config.ts
Introduce CI vs local branching for webServer (production start in CI, dev server locally), set test/expect timeouts, per-environment reporters, enable on-first-retry tracing, and retain video/screenshots only on failures.
Documentation
tooling/playwright-www/README.md
Add "Build Requirements", "Web Server Configuration", "Troubleshooting", and "Reporter and Artifacts" sections describing CI vs local modes, timeouts, server reuse, and artifact behavior.

Sequence Diagram(s)

sequenceDiagram
    participant GH as GitHub Actions
    participant Build as Build Step
    participant Server as WebServer
    participant Playwright as Playwright e2e
    participant Artifacts as Videos/Screenshots

    rect rgb(220,240,255)
    Note over GH: CI / PR run
    GH->>Build: install deps\n`pnpm --filter=www run build`
    Build->>Server: start production server\n(long timeout, no reuse)
    Server->>Playwright: serve app
    Playwright->>Artifacts: capture only on failures
    Playwright->>GH: report results
    end

    rect rgb(240,255,240)
    Note over GH: Local developer run
    GH->>Server: start dev server\n(reuse, hot-reload, short timeout)
    Server->>Playwright: serve app
    Playwright->>Artifacts: capture only on failures
    Playwright->>GH: report results
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

  • Review CI workflow build/filter syntax and placement relative to e2e step.
  • Verify Playwright CI vs local branching: webServer commands, timeouts, and reporter config.
  • Confirm README guidance matches actual commands and env vars.

Possibly related PRs

Suggested labels

tests, www

Poem

🐰 I hopped the build, I pranced the test,

CI in suit, local in vest.
Timeouts trimmed and videos spared,
Reused servers napped, productions aired.
A tiny rabbit cheers—your pipelines fared! 🎉

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main changes: enhancing CI workflow (GitHub Actions configuration and build steps) and Playwright configuration (server modes, timeouts, reporters).
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-a11y-tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added docs Improvements or additions to documentation github actions Pull requests that update GitHub Actions code labels Nov 4, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
tooling/playwright-www/playwright.config.ts (1)

17-22: Validate the worker override before returning it.

Returning Number.parseInt(envWorkers, 10) directly means a malformed override (e.g., "auto", empty string, "0") propagates as NaN/0, and Playwright refuses to start. Please guard against non-finite or non-positive values so we fall back to the default instead of crashing.

Apply this diff to add the guard:

 		// Allow override via environment variable
 		const envWorkers = process.env.PLAYWRIGHT_WORKERS;
 		if (envWorkers) {
-			return Number.parseInt(envWorkers, 10);
+			const overridden = Number.parseInt(envWorkers, 10);
+			if (Number.isFinite(overridden) && overridden > 0) {
+				return overridden;
+			}
 		}
tooling/playwright-www/README.md (1)

62-66: Keep the screenshot guidance in sync with the config.

The config now sets screenshot: "only-on-failure", so screenshots aren’t produced for every run. Please reword this bullet (and any similar spots) to note they’re captured only on failure to avoid surprising folks looking for happy-path screenshots.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1870c09 and 23ed63b.

📒 Files selected for processing (3)
  • .github/workflows/tests.yml (1 hunks)
  • tooling/playwright-www/README.md (1 hunks)
  • tooling/playwright-www/playwright.config.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/README.md

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Document environment requirements in README files

Files:

  • tooling/playwright-www/README.md
🧠 Learnings (1)
📚 Learning: 2025-09-12T06:23:45.463Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-12T06:23:45.463Z
Learning: Applies to **/*.test.ts : In tests, save and restore process.env in setup/teardown (beforeEach/afterEach) to avoid leakage between cases

Applied to files:

  • tooling/playwright-www/playwright.config.ts
🧬 Code graph analysis (2)
.github/workflows/tests.yml (5)
tooling/playwright-www/tests/integrations.test.ts (1)
  • test (4-157)
tooling/playwright-www/tests/morphs.test.ts (2)
  • test (4-149)
  • page (106-126)
tooling/playwright-www/tests/docs-navigation.test.ts (1)
  • test (4-181)
tooling/playwright-www/tests/examples.test.ts (1)
  • test (4-94)
tooling/playwright-www/tests/homepage.test.ts (1)
  • test (4-205)
tooling/playwright-www/playwright.config.ts (3)
tooling/playwright-www/tests/integrations.test.ts (3)
  • test (4-157)
  • page (82-97)
  • page (18-41)
tooling/playwright-www/tests/quickstart.test.ts (4)
  • page (78-86)
  • test (4-181)
  • page (158-165)
  • page (18-34)
tooling/playwright-www/tests/homepage.test.ts (1)
  • test (4-205)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: test-e2e (e2e)
  • GitHub Check: test-e2e (a11y)

- Changed the CI workflow to use `pnpm run test` instead of `pnpm turbo run test` for consistency.
- Updated the build command in the CI workflow to `pnpm run build --filter=www...` to ensure all dependencies are built.
- Revised Playwright configuration comments to reflect the new build command requirements.
- Enhanced README documentation to clarify the build requirements for running tests, emphasizing the need to build the `arkenv` package.

These changes improve the clarity and reliability of the testing process in both CI and local environments.
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
tooling/playwright-www/playwright.config.ts (1)

43-43: Consider extracting the port number to a constant.

The port "3000" is hardcoded in three places (baseURL on line 43, and env.PORT on lines 78 and 88). While this works correctly, extracting it to a constant would improve maintainability.

Apply this diff to extract the port constant:

+const PORT = "3000";
+
 export default defineConfig({
 	testDir: "./tests",
 	fullyParallel: true,
 	forbidOnly: isCi,
 	retries: isCi ? 2 : 0,
 	workers: getWorkers(),
 	// Reporter: dot/html for CI (less noise), list/html for local (immediate feedback)
 	reporter: isCi
 		? [["dot"], ["html", { open: "never" }]]
 		: [["list"], ["html", { open: "on-failure" }]],
 	// Test timeout: 60s for CI (networkidle waits, axe-core scans), 30s for local
 	timeout: isCi ? 60_000 : 30_000,
 	// Explicit expect timeout prevents flaky assertions
 	expect: { timeout: 5_000 },
 	use: {
-		baseURL: "http://localhost:3000",
+		baseURL: `http://localhost:${PORT}`,
 		trace: "on-first-retry",
 		// Capture videos and screenshots only on failure to reduce CI artifact size
 		video: "retain-on-failure",
 		screenshot: "only-on-failure",
 	},
 
 	projects: [
 		{
 			name: "chromium",
 			use: { ...devices["Desktop Chrome"] },
 		},
 		{
 			name: "firefox",
 			use: { ...devices["Desktop Firefox"] },
 		},
 		{
 			name: "webkit",
 			use: { ...devices["Desktop Safari"] },
 		},
 	],
 
 	// Web server configuration
 	// CI: Use production server (next start) for stability - requires pre-build in workflow
 	// Local: Use dev server (next dev) for hot reload and better DX
 	webServer: isCi
 		? {
 				// CI: Production server (faster, more stable, matches production)
 				// Requires: pnpm run build --filter=www... in GitHub Actions before tests
 				command: "pnpm --filter=www run start",
-				url: "http://localhost:3000",
+				url: `http://localhost:${PORT}`,
 				reuseExistingServer: false,
 				timeout: 120_000, // 2min should be enough for production server
 				stdout: "pipe",
 				stderr: "pipe",
-				env: { PORT: "3000" },
+				env: { PORT },
 			}
 		: {
 				// Local: Dev server (hot reload, sourcemaps, better DX)
 				command: "pnpm --filter=www run dev",
-				url: "http://localhost:3000",
+				url: `http://localhost:${PORT}`,
 				reuseExistingServer: true,
 				timeout: 120_000, // 2min for dev server cold start
 				stdout: "pipe",
 				stderr: "pipe",
-				env: { PORT: "3000" },
+				env: { PORT },
 			},
 });

Also applies to: 78-78, 88-88

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 23ed63b and f12f47d.

📒 Files selected for processing (3)
  • .github/workflows/tests.yml (4 hunks)
  • tooling/playwright-www/README.md (1 hunks)
  • tooling/playwright-www/playwright.config.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/tests.yml
🧰 Additional context used
📓 Path-based instructions (1)
**/README.md

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Document environment requirements in README files

Files:

  • tooling/playwright-www/README.md
🧠 Learnings (4)
📓 Common learnings
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-12T06:23:45.463Z
Learning: When contributing, ensure tests pass (pnpm test), lint passes (pnpm check/fix), and create a changeset (pnpm changeset) before merging
📚 Learning: 2025-09-12T06:23:45.463Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-12T06:23:45.463Z
Learning: Applies to **/*.test.ts : Test both success and failure cases for environment validation and utilities

Applied to files:

  • tooling/playwright-www/README.md
📚 Learning: 2025-09-12T06:23:45.463Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-12T06:23:45.463Z
Learning: Applies to **/*.test.ts : Verify both runtime behavior and TypeScript types in tests

Applied to files:

  • tooling/playwright-www/README.md
📚 Learning: 2025-09-12T06:23:45.463Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-12T06:23:45.463Z
Learning: Applies to **/*.test.ts : In tests, save and restore process.env in setup/teardown (beforeEach/afterEach) to avoid leakage between cases

Applied to files:

  • tooling/playwright-www/playwright.config.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: test-e2e (e2e)
  • GitHub Check: test-e2e (a11y)
🔇 Additional comments (8)
tooling/playwright-www/playwright.config.ts (4)

34-37: LGTM: Appropriate reporter configuration for each environment.

The conditional reporter setup provides concise output for CI (dot) and detailed feedback for local development (list), with appropriate HTML artifact handling.


38-41: LGTM: Well-reasoned timeout configuration.

The timeout values are appropriate for each environment. The explicit expect timeout of 5s is a good defensive measure against flaky assertions.


44-47: LGTM: Efficient artifact capture strategy.

Capturing videos and screenshots only on failure is an effective approach to reduce CI artifact size while maintaining debuggability.


65-89: Configuration verified — no changes needed.

The GitHub Actions workflow correctly includes the build step (pnpm run build --filter=www...) before running Playwright tests, confirming that the production server configuration in playwright.config.ts is properly supported by the CI pipeline.

tooling/playwright-www/README.md (4)

68-79: LGTM: Clear documentation of build requirements.

The Build Requirements section clearly explains why the arkenv package must be built before tests and provides the necessary commands for both CI and local environments. This aligns with the coding guideline to document environment requirements in README files.

Based on coding guidelines.


80-101: LGTM: Comprehensive server configuration documentation.

The Web Server Configuration section clearly documents the different server modes for CI and local environments, with well-reasoned rationale for using production builds in CI. The documentation aligns perfectly with the implementation in playwright.config.ts.


102-126: LGTM: Thorough troubleshooting guide.

The Troubleshooting section provides practical, actionable solutions for the most common issues, with environment-specific guidance for CI vs local development. The solutions are clear and include specific commands.


127-134: LGTM: Accurate documentation of reporter and artifacts.

The Reporter and Artifacts section accurately documents the configuration implemented in playwright.config.ts, clearly explaining the different behaviors for CI and local environments.

@yamcodes yamcodes merged commit a93ed85 into main Nov 4, 2025
15 checks passed
@yamcodes yamcodes deleted the fix-a11y-tests branch November 4, 2025 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation github actions Pull requests that update GitHub Actions code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant