Repository navigation
feat(preview): expire preview workspaces and prune expired ones on cleanup #132
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
Open
toiroakr
wants to merge
5
commits into
main
Choose a base branch
from
feat/preview-ttl-prune
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
adb52a5
fix(preview): find the workspace ID in the PR comment under jq 1.8
toiroakr f42007b
feat(preview): expire preview workspaces and prune the expired ones o…
toiroakr 108ca2d
chore: describe the jq named-group fix as it was verified
toiroakr b5fb3aa
fix(preview): keep a preview workspace alive while its PR is active
toiroakr 6511e44
fix(preview): keep a created workspace when its expiry is unconfirmed…
toiroakr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "tailor-platform-actions": patch | ||
| --- | ||
|
|
||
| Fix preview-deploy and preview-cleanup not finding the workspace ID recorded in the PR comment when jq rejects the `(?P<id>…)` named-group syntax, as the jq 1.7.1 and 1.8.2 release binaries do. `try` hid the error, so an existing preview workspace went unrecognized: a later push tried to create it again and closing the PR skipped deleting it. The group is now written `(?<id>…)`, which those jq versions accept. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "tailor-platform-actions": minor | ||
| --- | ||
|
|
||
| Add `ttl` to preview-deploy and `prune-expired` (with `organization-id` and `folder-id`) to preview-cleanup. With `ttl`, a preview workspace records an expiry that every push to the PR restarts, and with `prune-expired: "true"` every PR close also deletes this app's other `{prefix}-pr-{number}` workspaces in the same folder or organization root whose expiry has passed, so a preview whose own cleanup never ran no longer lingers. A PR that sat idle past `ttl` gets a fresh workspace on its next push, and closing it after its workspace was pruned no longer fails. Both inputs are off by default and existing workflows behave as before. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| import assert from "node:assert/strict"; | ||
| import test from "node:test"; | ||
| import { loadAction, runStep } from "./helpers.mjs"; | ||
|
|
||
| const deployEnv = { | ||
| NAME_PREFIX: "my-app", | ||
| REGION: "us-west", | ||
| ORG_ID: "", | ||
| FOLDER_ID: "", | ||
| PR_NUMBER: "42", | ||
| }; | ||
|
|
||
| test("preview-deploy: reuses the workspace recorded in the PR comment instead of creating another", async (context) => { | ||
| const action = await loadAction("preview-deploy"); | ||
| const result = await runStep(context, { | ||
| action, | ||
| stepId: "workspace", | ||
| env: { ...deployEnv, TTL: "7d" }, | ||
| comments: [ | ||
| { | ||
| user: { type: "Bot" }, | ||
| body: "<!-- tailor-preview: my-app-pr-42 id=0a1b2c3d-0000-4000-8000-000000000000 -->", | ||
| }, | ||
| ], | ||
| }); | ||
| assert.equal(result.code, 0, result.stderr); | ||
| assert.deepEqual( | ||
| result.calls.filter((args) => args[2] === "create"), | ||
| [], | ||
| ); | ||
| }); | ||
|
|
||
| test("preview-cleanup: deletes the workspace recorded in the PR comment", async (context) => { | ||
| const action = await loadAction("preview-cleanup"); | ||
| const result = await runStep(context, { | ||
| action, | ||
| stepId: "delete", | ||
| env: { NAME_PREFIX: "my-app", PR_NUMBER: "42" }, | ||
| comments: [ | ||
| { | ||
| user: { type: "Bot" }, | ||
| body: "<!-- tailor-preview: my-app-pr-42 id=0a1b2c3d-0000-4000-8000-000000000000 -->", | ||
| }, | ||
| ], | ||
| }); | ||
| assert.equal(result.code, 0, result.stderr); | ||
| assert.deepEqual(result.calls, [ | ||
| ["tailor", "workspace", "delete", "--workspace-id", "0a1b2c3d-0000-4000-8000-000000000000", "--yes"], | ||
| ]); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.