Skip to content

Preview branches #2086

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 125 commits into from
May 28, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
125 commits
Select commit Hold shift + click to select a range
7ae56e6
Initial preview migrations
matt-aitken May 11, 2025
b65e88b
Modified the staging endpoint to create preview environments
matt-aitken May 11, 2025
99e8130
Added isBranchableEnvironment to RuntimeEnvironment
matt-aitken May 11, 2025
9a57df2
Staging = yellow Preview = orange
matt-aitken May 11, 2025
406ce5d
Changed the env sort order
matt-aitken May 11, 2025
e1b1735
Set isBranchableEnvironment correctly. Create preview for new projects
matt-aitken May 11, 2025
7a04b97
Very basic branch menu
matt-aitken May 11, 2025
7de28ce
Creating branches from the dashboard
matt-aitken May 11, 2025
18941bf
Fix for string icons on project delete page
matt-aitken May 11, 2025
3b1dd91
Don’t show branch API keys
matt-aitken May 11, 2025
288cb7c
WIP on the manage branches page
matt-aitken May 13, 2025
05cff35
RuntimeEnvironment added projectId index
matt-aitken May 13, 2025
e741997
Only create the parentEnvironmentId column if it doesn’t exist already
matt-aitken May 13, 2025
79ce9a0
Improved the limit wording
matt-aitken May 13, 2025
2f79398
Add search to the branch list
matt-aitken May 13, 2025
8074fa3
contains in both places
matt-aitken May 13, 2025
9209607
Many style improvements
matt-aitken May 13, 2025
00ac0f7
Branch dropdown and v4 badge
matt-aitken May 13, 2025
65fc70a
Arching/unarchive branches working in the dashboard
matt-aitken May 13, 2025
b637ec1
Tidied imports
matt-aitken May 14, 2025
6efa232
Change preview slug from `prev` to `preview`
matt-aitken May 14, 2025
4e97a8c
Use correct color for side menu preview branch icon
matt-aitken May 14, 2025
0579f0e
Upsert the branch and use the shortcode as a unique constraint
matt-aitken May 14, 2025
17b5a40
Upserting working with nice messages in the dashboard
matt-aitken May 14, 2025
8b80cf2
Better errors when upserting branches
matt-aitken May 14, 2025
705b375
Button shortcut, don’t allow event to propagate
matt-aitken May 14, 2025
8719fb0
Better duplicate error message
matt-aitken May 14, 2025
9635408
Filter out archived branches from the env selector
matt-aitken May 14, 2025
e7e821a
Archiving/creating tweaked some more
matt-aitken May 14, 2025
865691e
Add an archived banner to the app, fixes for archived branches and up…
matt-aitken May 14, 2025
ff352ae
Fixed pagination
matt-aitken May 14, 2025
ac47c57
Disable editing schedules, pausing queues, testing tasks
matt-aitken May 14, 2025
66ee041
Don’t allow replaying if the env is archived
matt-aitken May 15, 2025
1dd75f8
When deploying detect the correct environment
matt-aitken May 15, 2025
1ed453c
Get the projectClient when there’s a branch
matt-aitken May 15, 2025
fdf3a86
createGitMeta function, most code from the vercel CLI repo
matt-aitken May 15, 2025
af5970d
Deploy, getting the correct environment client
matt-aitken May 15, 2025
162f922
Added git column to WorkerDeployment
matt-aitken May 15, 2025
199110b
Add GitMeta to core schemas
matt-aitken May 15, 2025
b5be9b4
Create branch when deploying
matt-aitken May 15, 2025
06720bb
WIP on branch support in the API
matt-aitken May 16, 2025
ba57574
Merge remote-tracking branch 'origin/main' into preview-branches
matt-aitken May 16, 2025
69c3cd9
Merge remote-tracking branch 'origin/main' into preview-branches
matt-aitken May 16, 2025
152963a
Delete old createTaskRunAttempt fn
matt-aitken May 16, 2025
7d92eba
apiAuth remove export from internal functions
matt-aitken May 16, 2025
8758961
Rename env var to “TRIGGER_PREVIEW_BRANCH”
matt-aitken May 16, 2025
f5c47d1
Add TRIGGER_PREVIEW_BRANCH to resolved env vars for runs
matt-aitken May 16, 2025
efbaf6c
First preview deploy and run working
matt-aitken May 19, 2025
6430da6
Set the preview branch in the main SDK
matt-aitken May 19, 2025
fc0e4a7
Added git links to the preview branches table
matt-aitken May 19, 2025
e80177e
Better errors when replaying/testing archived branches
matt-aitken May 19, 2025
862af37
Don’t dequeue archived environments
matt-aitken May 19, 2025
5de8317
Env var resolution with parent environment
matt-aitken May 20, 2025
43dd223
Hello world default machine small-2x to save my memory
matt-aitken May 20, 2025
082bdad
Fix for more env var functions
matt-aitken May 20, 2025
03e69c4
Merge remote-tracking branch 'origin/main' into preview-branches
matt-aitken May 20, 2025
e203f3c
Only return non-archived envs
matt-aitken May 20, 2025
932a4eb
Switch to controlled state for the checkboxes
matt-aitken May 20, 2025
615080f
Uncheck everything when PREVIEW is checked
matt-aitken May 20, 2025
184835b
WIP on branch UI
matt-aitken May 20, 2025
ff62192
Show the preview branch label on the env vars list
matt-aitken May 20, 2025
a1a3c44
Fix for overriding env vars
matt-aitken May 20, 2025
8ec543b
Adding preview branch env vars working
matt-aitken May 20, 2025
5d0d0ae
Progress on new env vars
matt-aitken May 20, 2025
25372d6
Only allow selecting a single branch
matt-aitken May 20, 2025
74d9923
Layout fix when there are errors
matt-aitken May 20, 2025
32e9950
Set the defaultValue so there are some fields
matt-aitken May 20, 2025
e21d65d
Conform fix for team invite page
matt-aitken May 20, 2025
ed30009
Archived environments don’t run scheduled tasks
matt-aitken May 21, 2025
7be7c30
Added Git data to deployments
matt-aitken May 21, 2025
9da2768
Added git data to the deployment inspector
matt-aitken May 21, 2025
e338061
Don’t allow upserting schedules when archived
matt-aitken May 21, 2025
e39eeeb
Deduplicate and blacklist some env vars
matt-aitken May 21, 2025
c24af91
Fix for wrong conform function being used
matt-aitken May 21, 2025
17b50c7
Show a better error if all vars were blacklisted
matt-aitken May 21, 2025
35ed095
Added environment variable search (by key and value)
matt-aitken May 21, 2025
236f3ff
Improved preview branch icon
matt-aitken May 21, 2025
81932bc
Replay now supports branches
matt-aitken May 21, 2025
2e3944d
Schedule page render branches properly
matt-aitken May 21, 2025
a2f324e
Show the env icon in bottom-left of the test page
matt-aitken May 21, 2025
c69cb2a
When editing older schedules (that have multi-env) show preview branc…
matt-aitken May 21, 2025
352c84d
Fix for incorrect disallowed branch name character
matt-aitken May 21, 2025
b3873f1
Extract and improve the directory verification code
matt-aitken May 21, 2025
8dbf504
WIP for CLI preview archive command
matt-aitken May 21, 2025
77bd001
Improved the preview branch action buttons
matt-aitken May 22, 2025
b8bdd60
Redirect to the project if we don’t find a matching env
matt-aitken May 22, 2025
4bb22d6
Archiving branch via the CLI working
matt-aitken May 22, 2025
351ee53
Fix for archiving branches
matt-aitken May 22, 2025
46498bb
Public access token test task
matt-aitken May 22, 2025
c7dcf57
JWTs working are with preview branches
matt-aitken May 22, 2025
527c632
Add branch and git data to the Run ctx
matt-aitken May 22, 2025
1b645e2
Updated GitMeta functions to work in CI
matt-aitken May 23, 2025
704deed
Added pullRequestState
matt-aitken May 23, 2025
052b63c
Archive when deploying if the PR is closed/merged
matt-aitken May 23, 2025
53de51b
Fix for the changesets guide
matt-aitken May 23, 2025
8b9efbc
Fix for CLI dev bug introduced
matt-aitken May 23, 2025
d8a71b5
CLI promote now supports preview branches
matt-aitken May 23, 2025
3ccb6d6
Add PR title. Reordered them and added tooltips
matt-aitken May 23, 2025
3afa516
syncEnvVars working with branches
matt-aitken May 24, 2025
d661d71
Added preview branch support to syncVercelEnvVars()
matt-aitken May 25, 2025
ca761ba
Detect the branch from Vercel env var (set during build)
matt-aitken May 26, 2025
9811531
Allow passing a branch in
matt-aitken May 26, 2025
448b038
Use process.env.VERCEL_TOKEN as well… this used in Vercel CI
matt-aitken May 26, 2025
177b92c
Temp delete
matt-aitken May 26, 2025
c9a3d87
Improved regenerate api key modal
matt-aitken May 27, 2025
642b87a
Added Accordion component (with styles)
matt-aitken May 27, 2025
c4d0d4d
Redesigned the API keys page
matt-aitken May 27, 2025
07bd968
Revert "Temp delete"
matt-aitken May 27, 2025
c0c8f7d
Changeset
matt-aitken May 27, 2025
7937003
Fixed docs link
matt-aitken May 27, 2025
2c31121
Merge remote-tracking branch 'origin/main' into preview-branches
matt-aitken May 27, 2025
e6c0a03
The new branch panel closes when a branch is created
matt-aitken May 27, 2025
42f69d5
Update apps/webapp/app/services/upsertBranch.server.ts
matt-aitken May 27, 2025
085c53a
Removed findUniques from WorkerGroupTokenService
matt-aitken May 27, 2025
0bdd9db
Made the parentEnvironmentId migrations safe
matt-aitken May 27, 2025
9eac17e
Latest lockfile
matt-aitken May 27, 2025
c14e029
Update packages/cli-v3/src/commands/workers/build.ts
matt-aitken May 27, 2025
24917fe
Move isValidGitBranchName to a separate file
matt-aitken May 27, 2025
0d5905e
Move the sanitize fn too
matt-aitken May 27, 2025
345da55
removeBlacklistedVariables moved to a separate file
matt-aitken May 27, 2025
f823f76
Moved deduplicateVariableArray to a separate file…
matt-aitken May 28, 2025
9713615
Fix broken sanitizeBranchName import
matt-aitken May 28, 2025
7885045
Another import fix…
matt-aitken May 28, 2025
641b74c
Improved blacklisted error message
matt-aitken May 28, 2025
2f39936
SImplified migration to use `ADD COLUMN IF NOT EXISTS "parentEnvironm…
matt-aitken May 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Moved deduplicateVariableArray to a separate file…
  • Loading branch information
matt-aitken committed May 28, 2025
commit f823f76d8263a3fe8f9e35b6e8e23e4787d76e51
14 changes: 14 additions & 0 deletions apps/webapp/app/v3/deduplicateVariableArray.server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { type EnvironmentVariable } from "./environmentVariables/repository";

/** Later variables override earlier ones */
export function deduplicateVariableArray(variables: EnvironmentVariable[]) {
const result: EnvironmentVariable[] = [];
// Process array in reverse order so later variables override earlier ones
for (const variable of [...variables].reverse()) {
if (!result.some((v) => v.key === variable.key)) {
result.push(variable);
}
}
// Reverse back to maintain original order but with later variables taking precedence
return result.reverse();
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
type Result,
} from "./repository";
import { removeBlacklistedVariables } from "../environmentVariableRules.server";
import { deduplicateVariableArray } from "../deduplicateVariableArray.server";

function secretKeyProjectPrefix(projectId: string) {
return `environmentvariable:${projectId}:`;
Expand Down Expand Up @@ -842,19 +843,6 @@ export async function resolveVariablesForEnvironment(
]);
}

/** Later variables override earlier ones */
export function deduplicateVariableArray(variables: EnvironmentVariable[]) {
const result: EnvironmentVariable[] = [];
// Process array in reverse order so later variables override earlier ones
for (const variable of [...variables].reverse()) {
if (!result.some((v) => v.key === variable.key)) {
result.push(variable);
}
}
// Reverse back to maintain original order but with later variables taking precedence
return result.reverse();
}

async function resolveOverridableTriggerVariables(
runtimeEnvironment: RuntimeEnvironmentForEnvRepo
) {
Expand Down
2 changes: 1 addition & 1 deletion apps/webapp/test/environmentVariableDeduplication.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, it, expect } from "vitest";
import { deduplicateVariableArray } from "../app/v3/environmentVariables/environmentVariablesRepository.server";
import type { EnvironmentVariable } from "../app/v3/environmentVariables/repository";
import { deduplicateVariableArray } from "~/v3/deduplicateVariableArray.server";

describe("Deduplicate variables", () => {
it("should keep later variables when there are duplicates", () => {
Expand Down
Loading