Skip to content

Commit ec30f95

Browse files
Merge branch 'main' into fix/web-wsl-sidebar-icon
2 parents bf5cc13 + 223ff44 commit ec30f95

533 files changed

Lines changed: 22507 additions & 7585 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
const MINIMUM_RELEASE_GAP_MS = 6 * 60 * 60 * 1000;
2+
3+
// Runs after the workflow acquires the nightly concurrency lock.
4+
async function shouldReleaseNightly({ github, context, core, now = Date.now() }) {
5+
const releases = await github.paginate(github.rest.repos.listReleases, {
6+
...context.repo,
7+
per_page: 100,
8+
});
9+
const lastNightly = releases
10+
.filter(
11+
(release) =>
12+
!release.draft &&
13+
release.published_at &&
14+
(/^v.*-nightly\./.test(release.tag_name) || release.tag_name.startsWith("nightly-v")),
15+
)
16+
.sort((a, b) => Date.parse(b.published_at) - Date.parse(a.published_at))[0];
17+
18+
if (!lastNightly) {
19+
core.info("No published nightly found. Proceeding with release.");
20+
return true;
21+
}
22+
23+
if (now - Date.parse(lastNightly.published_at) < MINIMUM_RELEASE_GAP_MS) {
24+
core.info(`Nightly ${lastNightly.tag_name} was published less than six hours ago. Skipping.`);
25+
return false;
26+
}
27+
28+
const { data: comparison } = await github.rest.repos.compareCommitsWithBasehead({
29+
...context.repo,
30+
basehead: `${lastNightly.tag_name}...${context.sha}`,
31+
per_page: 1,
32+
});
33+
if (comparison.status !== "ahead") {
34+
core.info(
35+
`Candidate commit is ${comparison.status} relative to ${lastNightly.tag_name}. Skipping.`,
36+
);
37+
return false;
38+
}
39+
40+
core.info(`New commits since ${lastNightly.tag_name}, and the six-hour gap has passed.`);
41+
return true;
42+
}
43+
44+
module.exports = { shouldReleaseNightly };
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
const assert = require("node:assert/strict");
2+
const test = require("node:test");
3+
const { shouldReleaseNightly } = require("./check-nightly-release.cjs");
4+
5+
const now = Date.parse("2026-09-05T12:00:00Z");
6+
const hour = 60 * 60 * 1000;
7+
const nightly = (hoursAgo, overrides = {}) => ({
8+
tag_name: "v1.0.1-nightly.20260905.123",
9+
draft: false,
10+
published_at: new Date(now - hoursAgo * hour).toISOString(),
11+
...overrides,
12+
});
13+
14+
function fixture({ releases = [nightly(7)], comparisonStatus = "ahead" } = {}) {
15+
const calls = [];
16+
return {
17+
calls,
18+
options: {
19+
now,
20+
context: { repo: { owner: "example", repo: "app" }, sha: "new" },
21+
core: { info() {} },
22+
github: {
23+
rest: {
24+
repos: {
25+
listReleases() {},
26+
async compareCommitsWithBasehead(params) {
27+
calls.push(params);
28+
return { data: { status: comparisonStatus } };
29+
},
30+
},
31+
},
32+
async paginate() {
33+
return releases;
34+
},
35+
},
36+
},
37+
};
38+
}
39+
40+
test("releases the first nightly when no nightly is published", async () => {
41+
const { options } = fixture({
42+
releases: [nightly(0, { tag_name: "v1.0.0" }), nightly(0, { draft: true })],
43+
});
44+
assert.equal(await shouldReleaseNightly(options), true);
45+
});
46+
47+
test("waits six hours after publication, including manual nightlies", async () => {
48+
for (const age of [0, 3, 6 - 1 / 3600]) {
49+
const { options, calls } = fixture({ releases: [nightly(age)] });
50+
assert.equal(await shouldReleaseNightly(options), false);
51+
assert.equal(calls.length, 0);
52+
}
53+
});
54+
55+
test("releases new commits at six hours and after an idle period", async () => {
56+
for (const age of [6, 7, 24]) {
57+
const { options } = fixture({ releases: [nightly(age)] });
58+
assert.equal(await shouldReleaseNightly(options), true);
59+
}
60+
});
61+
62+
test("skips unchanged commits after the gap", async () => {
63+
const { options } = fixture({ comparisonStatus: "identical" });
64+
assert.equal(await shouldReleaseNightly(options), false);
65+
});
66+
67+
test("uses publication time, not release order or the tagged commit date", async () => {
68+
const { options } = fixture({
69+
releases: [nightly(10), nightly(1), nightly(20, { tag_name: "nightly-v0.9.0" })],
70+
});
71+
assert.equal(await shouldReleaseNightly(options), false);
72+
});
73+
74+
test("ignores stable releases and drafts when checking the gap", async () => {
75+
const { options } = fixture({
76+
releases: [nightly(0, { tag_name: "v1.0.0" }), nightly(0, { draft: true }), nightly(7)],
77+
});
78+
assert.equal(await shouldReleaseNightly(options), true);
79+
});
80+
81+
test("compares against the published tag, including legacy nightly tags", async () => {
82+
const tag = "nightly-v0.9.0";
83+
const { options, calls } = fixture({ releases: [nightly(7, { tag_name: tag })] });
84+
assert.equal(await shouldReleaseNightly(options), true);
85+
assert.equal(calls[0].basehead, `${tag}...new`);
86+
});
87+
88+
test("fails instead of releasing when GitHub cannot supply release state", async () => {
89+
const { options } = fixture();
90+
options.github.paginate = async () => {
91+
throw new Error("GitHub unavailable");
92+
};
93+
await assert.rejects(shouldReleaseNightly(options), /GitHub unavailable/);
94+
});
95+
96+
for (const status of ["behind", "diverged"]) {
97+
test(`skips a candidate commit that is ${status} relative to the last nightly`, async () => {
98+
const { options } = fixture({ comparisonStatus: status });
99+
assert.equal(await shouldReleaseNightly(options), false);
100+
});
101+
}

‎.github/workflows/ci.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ jobs:
103103
sudo sed -i 's|http://|https://|g' /etc/apt/blacksmith-ubuntu-mirrors.txt /etc/apt/sources.list.d/ubuntu.sources
104104
sudo apt-get update && sudo apt-get install -y libsecret-1-dev pkg-config
105105
106+
- name: Test nightly release checks
107+
run: node --test .github/scripts/check-nightly-release.test.cjs
108+
106109
- name: Test
107110
run: vp run --parallel --concurrency-limit 4 --filter '!t3' --filter '!@t3tools/monorepo' test
108111

‎.github/workflows/release.yml‎

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ on:
66
- "v*.*.*"
77
- "!v*-nightly.*"
88
schedule:
9-
# Off minute zero: GitHub delays scheduled runs most at the top of the hour.
10-
- cron: "38 */3 * * *"
9+
# Avoid minute zero, when GitHub scheduled jobs are busiest.
10+
- cron: "8,38 * * * *"
1111
workflow_dispatch:
1212
inputs:
1313
channel:
@@ -28,7 +28,7 @@ on:
2828
# own group so a nightly never blocks them. Running publishers are never
2929
# canceled, and queue: max keeps every pending run instead of the default
3030
# newest-wins single slot, so a queued stable tag can never be silently
31-
# dropped. Queued nightlies with no new commits skip via check_changes.
31+
# dropped. Automatic nightlies recheck the release gap after leaving the queue.
3232
concurrency:
3333
group: release-${{ (github.event_name == 'schedule' || inputs.channel == 'nightly') && 'nightly' || 'stable' }}
3434
cancel-in-progress: false
@@ -40,41 +40,25 @@ permissions:
4040

4141
jobs:
4242
check_changes:
43-
name: Check for changes since last nightly
43+
name: Check automatic nightly release
4444
if: github.event_name == 'schedule'
4545
runs-on: blacksmith-8vcpu-ubuntu-2404
46+
timeout-minutes: 5
4647
outputs:
47-
has_changes: ${{ steps.check.outputs.has_changes }}
48+
has_changes: ${{ steps.check.outputs.result }}
4849
steps:
4950
- name: Checkout
5051
uses: actions/checkout@v6
5152
with:
52-
fetch-depth: 0
53-
sparse-checkout: |
54-
/*
55-
!/.repos/
56-
sparse-checkout-cone-mode: false
53+
sparse-checkout: .github/scripts
5754

5855
- id: check
59-
name: Compare HEAD to last nightly tag
60-
run: |
61-
last_nightly_tag=$(git tag --list 'v*-nightly.*' 'nightly-v*' --sort=-creatordate | head -n 1)
62-
if [[ -z "$last_nightly_tag" ]]; then
63-
echo "No previous nightly tag found. Proceeding with release."
64-
echo "has_changes=true" >> "$GITHUB_OUTPUT"
65-
exit 0
66-
fi
67-
68-
last_nightly_sha=$(git rev-parse "$last_nightly_tag^{commit}")
69-
head_sha=$(git rev-parse HEAD)
70-
71-
if [[ "$last_nightly_sha" == "$head_sha" ]]; then
72-
echo "No changes on main since last nightly release ($last_nightly_tag). Skipping."
73-
echo "has_changes=false" >> "$GITHUB_OUTPUT"
74-
else
75-
echo "Changes detected on main since $last_nightly_tag ($last_nightly_sha → $head_sha). Proceeding."
76-
echo "has_changes=true" >> "$GITHUB_OUTPUT"
77-
fi
56+
name: Check release gap and new commits
57+
uses: actions/github-script@v8
58+
with:
59+
script: |
60+
const { shouldReleaseNightly } = require('./.github/scripts/check-nightly-release.cjs');
61+
return await shouldReleaseNightly({ github, context, core });
7862
7963
preflight:
8064
name: Preflight
@@ -228,7 +212,7 @@ jobs:
228212
name: Resolve T3 Connect public config
229213
# Consumes only the commit SHA, not preflight's resolved version, so it runs
230214
# alongside preflight instead of after it. The condition mirrors preflight's:
231-
# check_changes is skipped on non-schedule events (skipped is neither failure
215+
# check_changes is skipped on manual and tag releases (skipped is neither failure
232216
# nor success, so success() would be wrong here).
233217
needs: [check_changes]
234218
if: |

‎apps/desktop/src/app/DesktopClerk.test.ts‎

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,6 @@ describe("DesktopClerk", () => {
6363
storageMock.mockReset();
6464
});
6565

66-
it("derives the Clerk Frontend API hostname used by the desktop CSP", () => {
67-
const publishableKey = `pk_test_${btoa("clerk.t3.codes$")}`;
68-
69-
assert.equal(
70-
DesktopClerk.resolveDesktopClerkFrontendApiHostname(publishableKey),
71-
"clerk.t3.codes",
72-
);
73-
assert.equal(DesktopClerk.resolveDesktopClerkFrontendApiHostname(""), undefined);
74-
assert.equal(DesktopClerk.resolveDesktopClerkFrontendApiHostname("invalid"), undefined);
75-
});
76-
7766
it.effect("acquires and releases the SDK bridge with the layer", () => {
7867
const cleanup = vi.fn();
7968
const events: string[] = [];
@@ -208,27 +197,4 @@ describe("DesktopClerk", () => {
208197
Effect.provideService(ElectronWindow.ElectronWindow, electronWindow),
209198
);
210199
});
211-
212-
it.each([
213-
{ isDevelopment: true, scheme: "t3code-dev" },
214-
{ isDevelopment: false, scheme: "t3code" },
215-
])("configures the SDK with the $scheme renderer origin", ({ isDevelopment, scheme }) => {
216-
const bridge = { cleanup: vi.fn(), isPrimaryInstance: true };
217-
storageMock.mockReturnValue(storageAdapter);
218-
createClerkBridgeMock.mockReturnValue(bridge);
219-
220-
assert.equal(DesktopClerk.createDesktopClerkBridge("/tmp/t3-state", isDevelopment), bridge);
221-
assert.deepEqual(storageMock.mock.calls, [[{ path: "/tmp/t3-state" }]]);
222-
assert.deepEqual(createClerkBridgeMock.mock.calls, [
223-
[
224-
{
225-
storage: storageAdapter,
226-
passkeys: true,
227-
renderer: { scheme, host: "app" },
228-
},
229-
],
230-
]);
231-
storageMock.mockClear();
232-
createClerkBridgeMock.mockClear();
233-
});
234200
});

‎apps/desktop/src/app/DesktopClerk.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export class DesktopClerk extends Context.Service<
5353
}
5454
>()("@t3tools/desktop/app/DesktopClerk") {}
5555

56-
export function resolveDesktopClerkFrontendApiHostname(
56+
function resolveDesktopClerkFrontendApiHostname(
5757
publishableKey: string | undefined,
5858
): string | undefined {
5959
const normalizedKey = publishableKey?.trim();
@@ -72,7 +72,7 @@ export const desktopClerkFrontendApiHostname = resolveDesktopClerkFrontendApiHos
7272
: __T3CODE_BUILD_CLERK_PUBLISHABLE_KEY__,
7373
);
7474

75-
export function createDesktopClerkBridge(stateDir: string, isDevelopment: boolean) {
75+
function createDesktopClerkBridge(stateDir: string, isDevelopment: boolean) {
7676
return createClerkBridge({
7777
storage: storage({ path: stateDir }),
7878
passkeys: true,

‎apps/desktop/src/app/DesktopPreReadyPlatform.test.ts‎

Lines changed: 15 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -37,45 +37,22 @@ describe("DesktopPreReadyPlatform", () => {
3737
registerSchemesMock.mockReset();
3838
});
3939

40-
it("reads an explicit Electron command-line switch value", () => {
41-
const value = DesktopPreReadyPlatform.readCommandLineSwitchValue(
42-
{
43-
hasSwitch: (switchName) => switchName === "password-store",
44-
getSwitchValue: (switchName) => {
45-
assert.equal(switchName, "password-store");
46-
return "basic";
47-
},
48-
},
49-
"password-store",
40+
it.effect("preserves an explicit Linux password-store switch", () => {
41+
hasSwitchMock.mockImplementation((switchName) => switchName === "password-store");
42+
getSwitchValueMock.mockReturnValue(" basic ");
43+
44+
return Effect.gen(function* () {
45+
const options = yield* DesktopPreReadyPlatform.DesktopPreReadyElectronOptions;
46+
47+
assert.equal(options.linuxPasswordStoreCommandLine, "basic");
48+
assert.isFalse(appendSwitchMock.mock.calls.some(([name]) => name === "password-store"));
49+
}).pipe(
50+
Effect.provide(
51+
DesktopPreReadyPlatform.layer.pipe(
52+
Layer.provide(Layer.succeed(HostProcessPlatform, "linux")),
53+
),
54+
),
5055
);
51-
52-
assert.equal(value, "basic");
53-
});
54-
55-
it("treats valueless Electron command-line switches as absent", () => {
56-
const value = DesktopPreReadyPlatform.readCommandLineSwitchValue(
57-
{
58-
hasSwitch: () => true,
59-
getSwitchValue: () => "",
60-
},
61-
"password-store",
62-
);
63-
64-
assert.isNull(value);
65-
});
66-
67-
it("returns null for missing Electron command-line switches", () => {
68-
const value = DesktopPreReadyPlatform.readCommandLineSwitchValue(
69-
{
70-
hasSwitch: () => false,
71-
getSwitchValue: () => {
72-
throw new Error("Unexpected switch value read.");
73-
},
74-
},
75-
"password-store",
76-
);
77-
78-
assert.isNull(value);
7956
});
8057

8158
it.effect(

‎apps/desktop/src/app/DesktopPreReadyPlatform.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export interface DesktopPreReadyCommandLineReader {
1717
readonly getSwitchValue: (switchName: string) => string;
1818
}
1919

20-
export function readCommandLineSwitchValue(
20+
function readCommandLineSwitchValue(
2121
commandLine: DesktopPreReadyCommandLineReader,
2222
switchName: string,
2323
): string | null {

‎apps/desktop/src/backend/DesktopBackendConfiguration.test.ts‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -218,14 +218,6 @@ const withPackagedWslHarness = <A, E, R>(
218218
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer));
219219

220220
describe("DesktopBackendConfiguration", () => {
221-
it("accepts only normalized SHA-256 archive identities", () => {
222-
assert.equal(
223-
DesktopBackendConfiguration.parseWslRuntimeArchiveHash(` ${"A".repeat(64)}\n`),
224-
"a".repeat(64),
225-
);
226-
assert.isNull(DesktopBackendConfiguration.parseWslRuntimeArchiveHash("abc123"));
227-
});
228-
229221
it.effect("resolvePrimary produces a stable scoped bootstrap token", () =>
230222
withHarness(
231223
Effect.gen(function* () {

‎apps/desktop/src/backend/DesktopBackendConfiguration.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ const WSL_RUNTIME_ARCHIVE_NAME = "wsl-runtime.tar.gz";
243243
const WSL_RUNTIME_ARCHIVE_HASH_NAME = `${WSL_RUNTIME_ARCHIVE_NAME}.sha256`;
244244
const SHA256_HEX_PATTERN = /^[0-9a-f]{64}$/i;
245245

246-
export const parseWslRuntimeArchiveHash = (value: string): string | null => {
246+
const parseWslRuntimeArchiveHash = (value: string): string | null => {
247247
const trimmed = value.trim();
248248
return SHA256_HEX_PATTERN.test(trimmed) ? trimmed.toLowerCase() : null;
249249
};

0 commit comments

Comments
 (0)