Skip to content

Commit bf020dd

Browse files
authored
app/: one typed config read from VISUALCI_ variables, with generated docs and warnings for unknown ones (sc-9026) (#140)
Every setting app/ reads is now declared once in app/src/config.rs, a struct derived with the new crates/envschema (typed settings from prefixed environment variables). Its doc comments, types, defaults and required / required-in-production / secret flags drive loading, boot checks, secret masking in logs, warnings for unknown VISUALCI_ variables (naming the closest known one) and the generated docs: the new self-hosting/environment-variables page and app/.env.example, checked by a test. App-owned settings that had other names now start with VISUALCI_ (S3_*, RENDERER_*, METRICS_TOKEN, GITHUB_APP_*, GITHUB_WEBHOOK_SECRET, STRIPE_*, POSTMARK_SERVER_TOKEN, MAIL_*, DEV_LOGIN, TRUSTED_PROXIES, DB_ACQUIRE_TIMEOUT, DB_APPLICATION_NAME). Laravel Rust's and the OAuth server's variables keep their names.
1 parent 5104435 commit bf020dd

66 files changed

Lines changed: 2815 additions & 548 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Cargo.lock‎

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎app/.env.example‎

Lines changed: 319 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,319 @@
1+
# VisualCI's server: every environment variable it reads. Generated from app/src/config.rs (run app/'s tests with
2+
# VISUALCI_GOLDEN_UPDATE=1); the reference is https://visualci.com/docs/self-hosting/environment-variables/
3+
4+
######################################################################################################################
5+
# Blob storage
6+
######################################################################################################################
7+
8+
# Required. The store's S3 endpoint. Example: https://<account>.r2.cloudflarestorage.com.
9+
VISUALCI_S3_ENDPOINT=https://<account>.r2.cloudflarestorage.com
10+
11+
# The endpoint browsers and the CLI upload to and download from, when it differs from the one the server uses (a store
12+
# the server reaches on a cluster-internal address). Images in the web app's Content-Security-Policy come from here
13+
# too.
14+
# VISUALCI_S3_PUBLIC_ENDPOINT=
15+
16+
# Required. The bucket.
17+
VISUALCI_S3_BUCKET=
18+
19+
# The bucket's region. R2 takes auto.
20+
# VISUALCI_S3_REGION=auto
21+
22+
# Required. Secret. The access key's ID.
23+
VISUALCI_S3_ACCESS_KEY_ID=
24+
25+
# Required. Secret. The access key's secret.
26+
VISUALCI_S3_SECRET_ACCESS_KEY=
27+
28+
######################################################################################################################
29+
# Renderers
30+
######################################################################################################################
31+
32+
# Required. Secret. The token every renderer sends: the same value as the renderers' own VISUALCI_RENDERER_TOKEN.
33+
VISUALCI_RENDERER_TOKEN=
34+
35+
# Required. The renderer version documents are drawn with: part of every render's cache key, and what a renderer's
36+
# claim must match exactly. The image sets it from docker/renderer.version; don't set it yourself.
37+
VISUALCI_RENDERER_VERSION=
38+
39+
# Secret. The token for /internal/renderer/metrics (Prometheus). Never give it to the renderers. Empty turns the
40+
# endpoint off: no token matches it.
41+
# VISUALCI_METRICS_TOKEN=
42+
43+
######################################################################################################################
44+
# Hosts
45+
######################################################################################################################
46+
47+
# The marketing site's address. Signed-out visitors to the app's front page go there. Example: https://visualci.com.
48+
# VISUALCI_SITE_URL=https://visualci.com
49+
50+
# The web app's address, also used for the links in emails (http://localhost when unset). Example:
51+
# https://app.visualci.com.
52+
# VISUALCI_APP_URL=https://app.visualci.com
53+
54+
# The API's address, where the CLI and CI send builds. The CLI's own VISUALCI_API_URL names the same address. Example:
55+
# https://api.visualci.com.
56+
# VISUALCI_API_URL=https://api.visualci.com
57+
58+
# The MCP server's address, where coding agents connect, and the OAuth issuer (OAUTH_ISSUER must match it). Example:
59+
# https://mcp.visualci.com.
60+
# VISUALCI_MCP_URL=https://mcp.visualci.com
61+
62+
######################################################################################################################
63+
# Network and database
64+
######################################################################################################################
65+
66+
# The proxies in front of the app whose X-Forwarded-For is believed, as addresses or CIDR ranges. Behind them, a
67+
# request's address is the nearest one that isn't a trusted proxy. Never include addresses untrusted code can send
68+
# from, such as the renderers'.
69+
# VISUALCI_TRUSTED_PROXIES=10.0.0.0/8
70+
71+
# More host names the MCP endpoint answers for, besides the configured hosts, the app's address and localhost (DNS
72+
# rebinding protection). For a development server reached by another name.
73+
# VISUALCI_MCP_HOSTS=
74+
75+
# How long, in seconds, a request waits for a pooled database connection before it fails with a 503 and Retry-After,
76+
# rather than hanging while the queue grows.
77+
# VISUALCI_DB_ACQUIRE_TIMEOUT=5
78+
79+
# The application_name of this process's database connections, in Postgres's metrics and pg_stat_activity, such as
80+
# visualci-web or visualci-worker. Letters, digits, dashes and underscores, at most 63 characters; anything else is
81+
# ignored.
82+
# VISUALCI_DB_APPLICATION_NAME=
83+
84+
######################################################################################################################
85+
# Sign-ups
86+
######################################################################################################################
87+
88+
# Required in production. true keeps sign-ups closed: someone new goes on the waitlist instead of getting an account.
89+
# Production must set it either way, so a dropped setting never opens sign-ups by surprise; elsewhere they're open
90+
# unless it's set.
91+
VISUALCI_WAITLIST=
92+
93+
######################################################################################################################
94+
# Development sign-in
95+
######################################################################################################################
96+
97+
# Lets anyone sign in as anyone by email, for local work and CI's screenshots. Only where APP_ENV is local or testing:
98+
# anywhere else the app refuses to start with it on.
99+
# VISUALCI_DEV_LOGIN=false
100+
101+
######################################################################################################################
102+
# GitHub App
103+
######################################################################################################################
104+
105+
# Required in production. The App's ID.
106+
VISUALCI_GITHUB_APP_ID=
107+
108+
# Required in production. Secret. The App's private key: its PEM file, base64-encoded to fit on one line.
109+
VISUALCI_GITHUB_APP_PRIVATE_KEY_BASE64=
110+
111+
# Required in production. Secret. The App's webhook secret. Without it, the webhook (/webhooks/github) answers 404.
112+
VISUALCI_GITHUB_WEBHOOK_SECRET=
113+
114+
######################################################################################################################
115+
# GitLab
116+
######################################################################################################################
117+
118+
# The GitLab VisualCI's OAuth application and bot are on.
119+
# VISUALCI_GITLAB_URL=https://gitlab.com
120+
121+
# Secret. The bot's personal access token, with the api scope: access checks, commit statuses and merge request notes.
122+
# VISUALCI_GITLAB_BOT_TOKEN=
123+
124+
# The bot's username, for telling people whom to invite.
125+
# VISUALCI_GITLAB_BOT_USERNAME=visualci
126+
127+
# Lets requests to an organization's server reach private addresses. Development only, for a local GitLab.
128+
# VISUALCI_FORGE_PRIVATE_ADDRESSES=false
129+
130+
######################################################################################################################
131+
# Email
132+
######################################################################################################################
133+
134+
# Required in production. Secret. The Postmark server's API token.
135+
VISUALCI_POSTMARK_SERVER_TOKEN=
136+
137+
# Who emails come from.
138+
# VISUALCI_MAIL_FROM="VisualCI <support@visualci.com>"
139+
140+
# Where replies go.
141+
# VISUALCI_MAIL_REPLY_TO=support@visualci.com
142+
143+
######################################################################################################################
144+
# Team
145+
######################################################################################################################
146+
147+
# Where new sign-ups and feedback are sent.
148+
# VISUALCI_TEAM_EMAIL=support@visualci.com
149+
150+
######################################################################################################################
151+
# Payments
152+
######################################################################################################################
153+
154+
# Required in production. Secret. Stripe's secret or restricted key: a live one (sk_live_, rk_live_) in production.
155+
VISUALCI_STRIPE_SECRET_KEY=
156+
157+
# Required in production. Secret. The webhook's signing secret. Stripe's endpoint is /webhooks/stripe on the API host.
158+
VISUALCI_STRIPE_WEBHOOK_SECRET=
159+
160+
######################################################################################################################
161+
# Cloudflare
162+
######################################################################################################################
163+
164+
# The zone the gallery's URLs are served from.
165+
# VISUALCI_CLOUDFLARE_ZONE_ID=
166+
167+
# Secret. An API token that may purge that zone's cache.
168+
# VISUALCI_CLOUDFLARE_PURGE_TOKEN=
169+
170+
######################################################################################################################
171+
# Gallery
172+
######################################################################################################################
173+
174+
# The most gallery credits one project is charged in a day: images past it are served free.
175+
# VISUALCI_GALLERY_DAILY_CREDITS=50000
176+
177+
######################################################################################################################
178+
# Heartbeats
179+
######################################################################################################################
180+
181+
# Email delivery (the worker, every five minutes).
182+
# VISUALCI_EMAILS_HEARTBEAT_URL=
183+
184+
# Secret. Email delivery's token.
185+
# VISUALCI_EMAILS_HEARTBEAT_TOKEN=
186+
187+
# Sign-up notices to the team.
188+
# VISUALCI_SIGNUPS_HEARTBEAT_URL=
189+
190+
# Secret. Sign-up notices' token.
191+
# VISUALCI_SIGNUPS_HEARTBEAT_TOKEN=
192+
193+
# The live-update check (every minute): a notification reaches each process's listener.
194+
# VISUALCI_LIVE_HEARTBEAT_URL=
195+
196+
# Secret. The live-update check's token.
197+
# VISUALCI_LIVE_HEARTBEAT_TOKEN=
198+
199+
# Pruning expired device sign-ins.
200+
# VISUALCI_DEVICE_PRUNE_HEARTBEAT_URL=
201+
202+
# Secret. Device sign-in pruning's token.
203+
# VISUALCI_DEVICE_PRUNE_HEARTBEAT_TOKEN=
204+
205+
# Syncing access from GitHub (the hourly recheck).
206+
# VISUALCI_FORGE_SYNC_HEARTBEAT_URL=
207+
208+
# Secret. Forge access sync's token.
209+
# VISUALCI_FORGE_SYNC_HEARTBEAT_TOKEN=
210+
211+
# Image retention (daily).
212+
# VISUALCI_RETENTION_HEARTBEAT_URL=
213+
214+
# Secret. Image retention's token.
215+
# VISUALCI_RETENTION_HEARTBEAT_TOKEN=
216+
217+
# The demo organization's daily reset.
218+
# VISUALCI_DEMO_HEARTBEAT_URL=
219+
220+
# Secret. The demo reset's token.
221+
# VISUALCI_DEMO_HEARTBEAT_TOKEN=
222+
223+
# The sweep of abandoned builds (every five minutes).
224+
# VISUALCI_BUILDS_EXPIRE_HEARTBEAT_URL=
225+
226+
# Secret. The builds sweep's token.
227+
# VISUALCI_BUILDS_EXPIRE_HEARTBEAT_TOKEN=
228+
229+
# The daily check of snapshot groups.
230+
# VISUALCI_GROUPS_CHECK_HEARTBEAT_URL=
231+
232+
# Secret. The groups check's token.
233+
# VISUALCI_GROUPS_CHECK_HEARTBEAT_TOKEN=
234+
235+
######################################################################################################################
236+
# Laravel Rust
237+
######################################################################################################################
238+
239+
# production, local or testing. The image sets production.
240+
# APP_ENV=production
241+
242+
# Required in production. Secret. Laravel's encryption key for sessions and cookies: 32 random characters. A new key
243+
# signs everyone out.
244+
APP_KEY=
245+
246+
# The server's address, for URLs the framework builds. On one host, the only address you set. Example:
247+
# https://visualci.example.com.
248+
# APP_URL=https://visualci.example.com
249+
250+
# Where the app's files are (public/, storage/). The image sets /app.
251+
# APP_BASE_PATH=
252+
253+
# The address the web server listens on. The image sets 0.0.0.0.
254+
# SERVER_HOST=
255+
256+
# The web server's port. The image sets 5150.
257+
# SERVER_PORT=
258+
259+
# Where logs go. The image sets stderr.
260+
# LOG_CHANNEL=
261+
262+
# Secret. The Postgres URL, with its credentials. Example: postgres://visualci:secret@db:5432/visualci.
263+
# DATABASE_URL=postgres://visualci:secret@db:5432/visualci
264+
265+
# pgsql.
266+
# DB_CONNECTION=pgsql
267+
268+
# The most database connections each process holds. Keep the sum across processes within Postgres's limit.
269+
# DB_MAX_CONNECTIONS=10
270+
271+
# database: the cache in Postgres, shared by every process.
272+
# CACHE_STORE=
273+
274+
# database: sign-in sessions in Postgres, shared by every process.
275+
# SESSION_DRIVER=
276+
277+
# database: the job queue in Postgres, worked by queue:work.
278+
# QUEUE_CONNECTION=
279+
280+
# Required in production. The GitHub App's OAuth client ID, for signing in with GitHub.
281+
GITHUB_CLIENT_ID=
282+
283+
# Required in production. Secret. The GitHub App's OAuth client secret.
284+
GITHUB_CLIENT_SECRET=
285+
286+
# The GitLab OAuth application's ID, for signing in with GitLab.
287+
# GITLAB_CLIENT_ID=
288+
289+
# Secret. The GitLab OAuth application's secret.
290+
# GITLAB_CLIENT_SECRET=
291+
292+
######################################################################################################################
293+
# OAuth for MCP clients
294+
######################################################################################################################
295+
296+
# The OAuth issuer: VISUALCI_MCP_URL. With the four hosts set, production refuses to start when it differs. Example:
297+
# https://mcp.visualci.com.
298+
# OAUTH_ISSUER=https://mcp.visualci.com
299+
300+
# The consent page: /oauth/authorize on VISUALCI_APP_URL, checked like OAUTH_ISSUER. Example:
301+
# https://app.visualci.com/oauth/authorize.
302+
# OAUTH_AUTHORIZATION_ENDPOINT=https://app.visualci.com/oauth/authorize
303+
304+
######################################################################################################################
305+
# Development and tests
306+
######################################################################################################################
307+
308+
# Stands in for the clock in credit allowances (RFC 3339), for screenshots of seeded data.
309+
# VISUALCI_NOW=
310+
311+
# The tests' Postgres (each test borrows a copy of it). Default: CI's,
312+
# postgres://visualci:visualci@127.0.0.1:55433/visualci_app_test.
313+
# VISUALCI_APP_TEST_DATABASE_URL=
314+
315+
# A folder the email tests write each email's HTML to, for review.
316+
# VISUALCI_EMAIL_SNAPSHOTS=
317+
318+
# 1 makes the tests write their golden files (this page among them) instead of comparing.
319+
# VISUALCI_GOLDEN_UPDATE=

‎app/Cargo.toml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,15 @@ rmcp = { version = "3.12", features = ["server", "transport-streamable-http-serv
4545
tower = { version = "0.5", features = ["util"] }
4646
url = "2"
4747
regex = "1"
48+
# Typed settings from VISUALCI_ variables, with their docs (config.rs)
49+
envschema = { path = "../crates/envschema" }
4850
# VisualCI's own crates, shared with the CLI.
4951
visualci-core = { path = "../crates/visualci-core", features = ["bundle"] }
5052
snapshot-diff = { path = "../crates/snapshot-diff" }
5153

5254
[dev-dependencies]
5355
regex = "1"
56+
# Capturing logs in config.rs's tests
57+
tracing-subscriber = { version = "0.3", default-features = false, features = ["fmt", "std"] }
5458
# A GitHub App key made at test time, so no private key is committed
5559
rsa = { version = "0.9", features = ["pem"] }

0 commit comments

Comments
 (0)