Skip to content

chore(env): add repo-wide .env.example and adopt provider-aware site resolution for docs#115

Merged
yacosta738 merged 5 commits into
mainfrom
chore/add-env-example
Mar 1, 2026
Merged

chore(env): add repo-wide .env.example and adopt provider-aware site resolution for docs#115
yacosta738 merged 5 commits into
mainfrom
chore/add-env-example

Conversation

@yacosta738
Copy link
Copy Markdown
Contributor

@yacosta738 yacosta738 commented Mar 1, 2026

This pull request introduces a canonical .env.example file for environment variable documentation and refactors the documentation site's configuration to use a shared environment resolution helper. The main goal is to standardize environment variable usage across the repository and make local development and deployment more robust and provider-agnostic.

Environment variable standardization and configuration improvements:

  • Added a comprehensive .env.example file at the root (corvus/.env.example) documenting all environment variables used across the repository, including development, production, CI, and third-party provider keys. This file serves as a template and reference for local development and CI/CD setups.

Documentation site configuration refactor:

  • Updated clients/web/apps/docs/astro.config.mjs to use the shared @corvus/shared/env helpers (resolveSiteUrl, getPortFromUrl, PORTS) for dynamic site URL and port resolution, supporting multiple hosting providers and local development.
  • Replaced hardcoded site URL and base path with environment-driven values, ensuring the docs site works seamlessly in different environments and hosting providers.
  • Refactored server and preview port configuration to use the resolved port from environment variables, improving consistency for local development and preview deployments.

Summary by CodeRabbit

  • Documentation

    • Added a comprehensive environment variable example template for local development, with sections, defaults, and security guidance.
  • Chores

    • Docs site configuration now resolves site URL, base path, and dev/preview port from environment for deploy-time flexibility.
  • Tests

    • Added unit tests validating environment URL and port resolution behavior.
  • Documentation

    • Simplified changelog template and updated changelog/PR commit formatting for clearer release notes.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 1, 2026

📝 Walkthrough

Walkthrough

Adds a canonical .env.example template for local development, makes the Astro docs app resolve site URL and server/preview port dynamically from environment, updates changelog configuration formatting, and adds unit tests for environment URL/port resolution.

Changes

Cohort / File(s) Summary
Environment Template
corvus/.env.example
New documented environment variables template organized into sections with defaults, comments, and guidance for local development and public vs private keys.
Astro Docs Config
clients/web/apps/docs/astro.config.mjs
Replaces hardcoded site/base with dynamic docsUrl and computeBaseFromUrl, binds server and preview to resolvedPort and host: true.
Env URL/Port Tests
clients/web/packages/shared/test/env.test.mjs
New Vitest unit tests covering resolveSiteUrl and getPortFromUrl behavior across provider-specific and fallback env variables.
Changelog Config
.github/config/changelog.json
Template and commit/PR formatting simplified; removed $schema, adjusted label extractor targets and changed sort order to descending.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • feat: marketing #16 — Related changes to environment-resolution utilities and Astro app configs (overlaps on resolveSiteUrl, getPortFromUrl, and docs app configuration).
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the two main changes: adding a .env.example file and adopting provider-aware site resolution for the docs site.
Description check ✅ Passed The description adequately covers the PR's purpose, changes made, and motivation. All key sections from the template are present with sufficient detail.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/add-env-example

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
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 1, 2026

✅ Contributor Report

User: @yacosta738
Status: Passed (12/13 metrics passed)

Metric Description Value Threshold Status
PR Merge Rate PRs merged vs closed 88% >= 30%
Repo Quality Repos with ≥100 stars 0 >= 0
Positive Reactions Positive reactions received 9 >= 1
Negative Reactions Negative reactions received 0 <= 5
Account Age GitHub account age 3047 days >= 30 days
Activity Consistency Regular activity over time 108% >= 0%
Issue Engagement Issues with community engagement 0 >= 0
Code Reviews Code reviews given to others 380 >= 0
Merger Diversity Unique maintainers who merged PRs 2 >= 0
Repo History Merge Rate Merge rate in this repo 90% >= 0%
Repo History Min PRs Previous PRs in this repo 87 >= 0
Profile Completeness Profile richness (bio, followers) 90 >= 0
Suspicious Patterns Spam-like activity detection 1 N/A

Contributor Report evaluates based on public GitHub activity. Analysis period: 2025-03-01 to 2026-03-01

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Mar 1, 2026

Deploying corvus with  Cloudflare Pages  Cloudflare Pages

Latest commit: 9bada94
Status: ✅  Deploy successful!
Preview URL: https://fa39578b.corvus-42x.pages.dev
Branch Preview URL: https://chore-add-env-example.corvus-42x.pages.dev

View logs

Copy link
Copy Markdown
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: 2

🧹 Nitpick comments (4)
clients/web/apps/docs/astro.config.mjs (2)

12-25: Add regression coverage for URL precedence and port resolution.

This block changes deployment-critical behavior (DOCS_URL / provider keys / SITE_URL fallback and derived port). A small config-level test matrix would prevent regressions.

As per coding guidelines, "Testing: Verify that tests cover critical paths and follow established naming conventions (e.g., backticks for Kotlin tests)."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@clients/web/apps/docs/astro.config.mjs` around lines 12 - 25, Add regression
tests that exercise resolveSiteUrl and getPortFromUrl to cover DOCS_URL,
providerKeys (CF_PAGES_URL, VERCEL_URL, URL), and generic SITE_URL fallback plus
port derivation; create a small matrix of cases setting env values for DOCS_URL,
each provider key, and SITE_URL (including absent values) and assert that
docsUrl equals the expected resolved URL and resolvedPort matches getPortFromUrl
expectations; put tests alongside existing config tests, name them to reflect
the matrix (e.g.,
`resolveSiteUrl_prefers_DOCS_URL_over_providers_and_falls_back_to_SITE_URL` and
`getPortFromUrl_derives_port_from_docsUrl`), and include both production and dev
mode variants to verify isProdLike behavior.

29-29: Derive base from docsUrl pathname instead of hardcoding root.

If DOCS_URL (or provider URL) ever includes a path segment, Line 29 will force root asset paths and break routing/assets on subpath deploys. Consider computing base from new URL(docsUrl).pathname.

Proposed refactor
+const docsBasePath = (() => {
+  const pathname = new URL(docsUrl).pathname;
+  return pathname.endsWith("/") ? pathname : `${pathname}/`;
+})();

 export default defineConfig({
   site: docsUrl,
-  base: "/", // ← Root level for custom domain
+  base: docsBasePath,
   server: {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@clients/web/apps/docs/astro.config.mjs` at line 29, The hardcoded base: "/"
should be computed from the docs URL so subpath deployments work; replace the
literal with a derived value using the DOCS_URL/docsUrl (the env var used in
this file) by parsing new URL(docsUrl).pathname, normalizing it (ensure it
starts with "/" and remove trailing slash except for root) and falling back to
"/" when docsUrl is missing or parsing fails; update the base assignment in
astro.config.mjs to use that normalized pathname instead of the hardcoded "/" so
asset and route paths follow the provider URL path segments.
.env.example (2)

22-128: Optional: normalize key ordering to satisfy dotenv-linter warnings.

Current ordering triggers many UnorderedKey warnings. If linting is enforced in CI, reordering keys per section will reduce noise.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.env.example around lines 22 - 128, Reorder the environment keys within each
commented section so they are consistently sorted (e.g., alphabetically) to
eliminate dotenv-linter UnorderedKey warnings; for example in the "Web apps /
Static sites" group ensure MARKETING_PORT, MARKETING_URL, DOCS_PORT, DOCS_URL
are in the same logical order, in "Agent runtime / backend (Corvus)" group sort
CORVUS_API_KEY, CORVUS_GATEWAY_HOST, CORVUS_GATEWAY_PORT,
CORVUS_TEST_SURREALDB_* and CORVUS_SURREALDB_* keys consistently, and similarly
sort third-party keys like ANTHROPIC_API_KEY, OPENAI_API_KEY, GOOGLE_API_KEY and
CI keys like GITHUB_TOKEN, GH_TOKEN — preserve section comments and blank lines
while only reordering the key/value lines so dotenv-linter no longer reports
UnorderedKey.

148-149: Remove AI assistant prompt text from the committed template.

Lines 148-149 are conversational and not part of canonical env documentation; removing them will keep this file clean and tooling-focused.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.env.example around lines 148 - 149, Remove the two conversational prompt
lines ("If you want me to run an exhaustive scan..." and the follow-up
instruction) from the .env.example so the template contains only canonical
environment docs/comments; locate the exact text block present in the file and
delete those lines (no replacement needed).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.env.example:
- Line 85: Update the ANTHROPIC_API_KEY placeholder in .env.example to correct
the typo: replace "sk_antropic_xxx" with a properly spelled placeholder such as
"sk_anthropic_xxx" or a neutral value like "<YOUR_ANTHROPIC_API_KEY>" so the
ANTHROPIC_API_KEY entry uses "anthropic" spelled correctly.
- Around line 51-53: The .env.example contains secret-like example values (e.g.,
CORVUS_API_KEY=sk_corvus_xxx) that can trigger secret scanners; update the
example values to neutral placeholders (for example use
CORVUS_API_KEY=your_corvus_api_key_here) and similarly replace other token-like
examples in the file (lines referenced in the review, e.g., the block around
82-111) with non-secret, clearly-labeled placeholders so no real-looking secrets
(sk_*, ghp_*, AIza*, token-shaped UUIDs) remain in the template.

---

Nitpick comments:
In @.env.example:
- Around line 22-128: Reorder the environment keys within each commented section
so they are consistently sorted (e.g., alphabetically) to eliminate
dotenv-linter UnorderedKey warnings; for example in the "Web apps / Static
sites" group ensure MARKETING_PORT, MARKETING_URL, DOCS_PORT, DOCS_URL are in
the same logical order, in "Agent runtime / backend (Corvus)" group sort
CORVUS_API_KEY, CORVUS_GATEWAY_HOST, CORVUS_GATEWAY_PORT,
CORVUS_TEST_SURREALDB_* and CORVUS_SURREALDB_* keys consistently, and similarly
sort third-party keys like ANTHROPIC_API_KEY, OPENAI_API_KEY, GOOGLE_API_KEY and
CI keys like GITHUB_TOKEN, GH_TOKEN — preserve section comments and blank lines
while only reordering the key/value lines so dotenv-linter no longer reports
UnorderedKey.
- Around line 148-149: Remove the two conversational prompt lines ("If you want
me to run an exhaustive scan..." and the follow-up instruction) from the
.env.example so the template contains only canonical environment docs/comments;
locate the exact text block present in the file and delete those lines (no
replacement needed).

In `@clients/web/apps/docs/astro.config.mjs`:
- Around line 12-25: Add regression tests that exercise resolveSiteUrl and
getPortFromUrl to cover DOCS_URL, providerKeys (CF_PAGES_URL, VERCEL_URL, URL),
and generic SITE_URL fallback plus port derivation; create a small matrix of
cases setting env values for DOCS_URL, each provider key, and SITE_URL
(including absent values) and assert that docsUrl equals the expected resolved
URL and resolvedPort matches getPortFromUrl expectations; put tests alongside
existing config tests, name them to reflect the matrix (e.g.,
`resolveSiteUrl_prefers_DOCS_URL_over_providers_and_falls_back_to_SITE_URL` and
`getPortFromUrl_derives_port_from_docsUrl`), and include both production and dev
mode variants to verify isProdLike behavior.
- Line 29: The hardcoded base: "/" should be computed from the docs URL so
subpath deployments work; replace the literal with a derived value using the
DOCS_URL/docsUrl (the env var used in this file) by parsing new
URL(docsUrl).pathname, normalizing it (ensure it starts with "/" and remove
trailing slash except for root) and falling back to "/" when docsUrl is missing
or parsing fails; update the base assignment in astro.config.mjs to use that
normalized pathname instead of the hardcoded "/" so asset and route paths follow
the provider URL path segments.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 5aea1e4 and f5d4964.

📒 Files selected for processing (2)
  • .env.example
  • clients/web/apps/docs/astro.config.mjs

Comment thread .env.example Outdated
Comment thread .env.example Outdated
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Mar 1, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

Copy link
Copy Markdown
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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.env.example:
- Around line 31-33: The example uses shell-style interpolation for DOCS_URL and
MARKETING_URL (DOCS_URL, MARKETING_URL referencing DOCS_PORT, MARKETING_PORT)
which many env loaders won't expand; either replace those entries with concrete
default literals (e.g., use explicit port numbers) or add a short comment above
these lines explaining that ${DOCS_PORT} and ${MARKETING_PORT} require shell
expansion (or recommend using dotenv-expand) and showing the literal fallback
format so users know to set full URLs when using non-shell env loaders.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between f5d4964 and 9bada94.

📒 Files selected for processing (4)
  • .env.example
  • .github/config/changelog.json
  • clients/web/apps/docs/astro.config.mjs
  • clients/web/packages/shared/test/env.test.mjs

Comment thread .env.example
Comment on lines +31 to +33
DOCS_URL=http://localhost:${DOCS_PORT}
# Marketing site - provider-aware. Local default uses MARKETING_PORT above.
MARKETING_URL=http://localhost:${MARKETING_PORT}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Shell variable interpolation may not work with all env loaders.

The ${DOCS_PORT} and ${MARKETING_PORT} syntax relies on shell interpolation, which won't work with many env loaders (e.g., Node.js dotenv doesn't expand variables by default). Consider using literal values or documenting this limitation.

Option 1: Use literal values
-DOCS_URL=http://localhost:${DOCS_PORT}
+DOCS_URL=http://localhost:4321
 # Marketing site - provider-aware. Local default uses MARKETING_PORT above.
-MARKETING_URL=http://localhost:${MARKETING_PORT}
+MARKETING_URL=http://localhost:9988
Option 2: Add a note about interpolation

Add a comment above these lines:

+# Note: ${VAR} interpolation requires shell expansion or dotenv-expand; use literal ports if your loader doesn't support it.
 DOCS_URL=http://localhost:${DOCS_PORT}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
DOCS_URL=http://localhost:${DOCS_PORT}
# Marketing site - provider-aware. Local default uses MARKETING_PORT above.
MARKETING_URL=http://localhost:${MARKETING_PORT}
DOCS_URL=http://localhost:4321
# Marketing site - provider-aware. Local default uses MARKETING_PORT above.
MARKETING_URL=http://localhost:9988
Suggested change
DOCS_URL=http://localhost:${DOCS_PORT}
# Marketing site - provider-aware. Local default uses MARKETING_PORT above.
MARKETING_URL=http://localhost:${MARKETING_PORT}
# Note: ${VAR} interpolation requires shell expansion or dotenv-expand; use literal ports if your loader doesn't support it.
DOCS_URL=http://localhost:${DOCS_PORT}
# Marketing site - provider-aware. Local default uses MARKETING_PORT above.
MARKETING_URL=http://localhost:${MARKETING_PORT}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.env.example around lines 31 - 33, The example uses shell-style
interpolation for DOCS_URL and MARKETING_URL (DOCS_URL, MARKETING_URL
referencing DOCS_PORT, MARKETING_PORT) which many env loaders won't expand;
either replace those entries with concrete default literals (e.g., use explicit
port numbers) or add a short comment above these lines explaining that
${DOCS_PORT} and ${MARKETING_PORT} require shell expansion (or recommend using
dotenv-expand) and showing the literal fallback format so users know to set full
URLs when using non-shell env loaders.

@yacosta738 yacosta738 merged commit fe371a7 into main Mar 1, 2026
17 of 19 checks passed
@yacosta738 yacosta738 deleted the chore/add-env-example branch March 1, 2026 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant