Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 12 additions & 0 deletions .github/fork-manifest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,24 @@ apps/mobile/src/features/threads/ThreadHeader.tsx icon: filesVisible ? "folder.f
# Fork: Keep unsigned Personal Team IPA packaging, fork OTA isolation, iOS 17 checks, concurrency, and hosted compilation/dependency caches.
.github/workflows/release-mobile-ios.yml Fork:
.github/workflows/release-mobile-ios.yml T3CODE_IOS_PERSONAL_TEAM: "1"
.github/workflows/release-mobile-ios.yml key: ios-cas-v1-${{ runner.os }}-${{ runner.arch }}-${{ steps.xcode.outputs.build }}-${{ hashFiles('pnpm-lock.yaml', 'pnpm-workspace.yaml', 'patches/**') }}
.github/workflows/release-mobile-ios.yml name: Bound the compilation cache

# Fork: Keep fork opt-in releases, repository identity, hosted runner overrides, Intel macOS builds, and the unsigned iOS release dependency.
# Fork: Cut hosted macOS minutes: a configurable nightly gap, and macOS/iOS builds that wait for the release tests.
.github/workflows/release.yml vars.T3CODE_RELEASES
.github/workflows/release.yml vars.T3CODE_MOBILE_RELEASE
.github/workflows/release.yml Fork:
.github/workflows/release.yml vars.T3CODE_TEST_WEB_TIMEOUT_MINUTES
.github/workflows/release.yml NIGHTLY_GAP_HOURS: ${{ vars.T3CODE_NIGHTLY_GAP_HOURS }}
.github/workflows/release.yml needs: [preflight, relay_public_config, build_bundle, quality, test, test_web, test_server]
.github/workflows/release.yml needs: [preflight, relay_public_config, quality, test, test_web, test_server]

# Fork: The nightly gap reads T3CODE_NIGHTLY_GAP_HOURS so a fork on hosted macOS runners can publish fewer nightlies.
.github/scripts/check-nightly-release.cjs Fork:
.github/scripts/check-nightly-release.cjs gapHours = DEFAULT_RELEASE_GAP_HOURS
.github/scripts/check-nightly-release.test.cjs Fork:
.github/scripts/check-nightly-release.test.cjs a configured gap replaces the six-hour default

# Fork: Honor fork runner variables so CI can use GitHub-hosted runners without the upstream Blacksmith installation.
.github/workflows/web-preview.yml Fork:
Expand Down
22 changes: 17 additions & 5 deletions .github/scripts/check-nightly-release.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const MINIMUM_RELEASE_GAP_MS = 6 * 60 * 60 * 1000;
const DEFAULT_RELEASE_GAP_HOURS = 6;

function repositoryDefaultBranch(context) {
const branch = context.payload.repository?.default_branch;
Expand Down Expand Up @@ -74,8 +74,20 @@ async function findLatestNightly({ github, context, isSettled = () => false }) {
return latest;
}

async function shouldReleaseNightly({ github, context, core, now = Date.now() }) {
const isInGap = (release) => now - Date.parse(release.publishedAt) < MINIMUM_RELEASE_GAP_MS;
// Fork: `gapHours` comes from the T3CODE_NIGHTLY_GAP_HOURS variable so a fork on hosted macOS
// runners can publish fewer nightlies than upstream's six-hour cadence. Unset keeps upstream's gap.
async function shouldReleaseNightly({
github,
context,
core,
now = Date.now(),
gapHours = DEFAULT_RELEASE_GAP_HOURS,
}) {
if (!Number.isFinite(gapHours) || gapHours <= 0) {
throw new Error(`Nightly release gap must be a positive number of hours, got ${gapHours}.`);
}
const gapMs = gapHours * 60 * 60 * 1000;
const isInGap = (release) => now - Date.parse(release.publishedAt) < gapMs;
// Any nightly inside the gap means the newest one is too, so stop reading.
const lastNightly = await findLatestNightly({ github, context, isSettled: isInGap });

Expand All @@ -86,7 +98,7 @@ async function shouldReleaseNightly({ github, context, core, now = Date.now() })

const tag = lastNightly.tagName;
if (isInGap(lastNightly)) {
core.info(`Nightly ${tag} was published less than six hours ago. Skipping.`);
core.info(`Nightly ${tag} was published less than ${gapHours} hours ago. Skipping.`);
return false;
}

Expand All @@ -100,7 +112,7 @@ async function shouldReleaseNightly({ github, context, core, now = Date.now() })
return false;
}

core.info(`New commits since ${tag}, and the six-hour gap has passed.`);
core.info(`New commits since ${tag}, and the ${gapHours}-hour gap has passed.`);
return true;
}

Expand Down
9 changes: 9 additions & 0 deletions .github/scripts/check-nightly-release.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,15 @@ test("the six-hour gap ends exactly six hours after publication", async () => {
assert.equal(justInside.calls.length, 0);
});

// Fork: T3CODE_NIGHTLY_GAP_HOURS widens the gap to publish fewer nightlies.
test("a configured gap replaces the six-hour default", async () => {
const { options } = fixture({ releases: [nightly(7)] });
assert.equal(await shouldReleaseNightly({ ...options, gapHours: 24 }), false);
const passed = fixture({ releases: [nightly(24)] });
assert.equal(await shouldReleaseNightly({ ...passed.options, gapHours: 24 }), true);
await assert.rejects(shouldReleaseNightly({ ...options, gapHours: Number.NaN }), /positive/);
});

test("stops reading releases once a nightly inside the gap is seen", async () => {
const { options, cursors } = fixture({ pages: [[nightly(10), nightly(2)], [nightly(30)]] });
assert.equal(await shouldReleaseNightly(options), false);
Expand Down
23 changes: 21 additions & 2 deletions .github/workflows/release-mobile-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,32 @@ jobs:
restore-keys: |
ios-downloads-v1-${{ runner.os }}-${{ runner.arch }}-

# Keyed by dependency inputs, not commit: a per-commit 1.6 GB entry filled the 10 GB repository
# cache and evicted itself, and a cold build takes ~80 min against ~13 warm. The store is
# content-addressed, so an older lockfile's entry is safe to restore and still covers
# every unchanged dependency.
- name: Cache native compilation
id: ios_cas
uses: actions/cache@v6
with:
path: ${{ github.workspace }}/.ios-compilation-cache
key: ios-cas-v1-${{ runner.os }}-${{ runner.arch }}-${{ steps.xcode.outputs.build }}-${{ hashFiles('pnpm-lock.yaml', 'pnpm-workspace.yaml', 'patches/**') }}-${{ github.sha }}
key: ios-cas-v1-${{ runner.os }}-${{ runner.arch }}-${{ steps.xcode.outputs.build }}-${{ hashFiles('pnpm-lock.yaml', 'pnpm-workspace.yaml', 'patches/**') }}
restore-keys: |
ios-cas-v1-${{ runner.os }}-${{ runner.arch }}-${{ steps.xcode.outputs.build }}-${{ hashFiles('pnpm-lock.yaml', 'pnpm-workspace.yaml', 'patches/**') }}-
ios-cas-v1-${{ runner.os }}-${{ runner.arch }}-${{ steps.xcode.outputs.build }}-

# Restoring across lockfiles keeps stale objects; start over before the saved entry crowds
# out the repository's other caches. An exact hit is never saved again, so it stays.
- name: Bound the compilation cache
if: steps.ios_cas.outputs.cache-hit != 'true'
run: |
cas="$GITHUB_WORKSPACE/.ios-compilation-cache"
[ -d "$cas" ] || exit 0
size_mb=$(du -sm "$cas" | cut -f1)
echo "compilation cache: ${size_mb} MB"
if [ "$size_mb" -gt 3072 ]; then
echo "::notice::compilation cache is ${size_mb} MB; starting a fresh one"
rm -rf "$cas"
fi

- name: Generate the iOS project
run: |
Expand Down
22 changes: 15 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ jobs:
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
env:
DISPATCH_CHANNEL: ${{ inputs.channel }}
# Fork: hours between automatic nightlies; unset keeps upstream's six.
NIGHTLY_GAP_HOURS: ${{ vars.T3CODE_NIGHTLY_GAP_HOURS }}
with:
# Every call here is a read; retry GitHub's transient 5xx and dropped connections.
retries: 3
Expand All @@ -95,7 +97,8 @@ jobs:
await assertReleaseSource({ github, context, releaseChannel });

if (context.eventName === 'schedule') {
core.setOutput('has_changes', await shouldReleaseNightly({ github, context, core }));
const gapHours = process.env.NIGHTLY_GAP_HOURS ? Number(process.env.NIGHTLY_GAP_HOURS) : undefined;
core.setOutput('has_changes', await shouldReleaseNightly({ github, context, core, gapHours }));
core.setOutput('ref', context.sha);
} else if (context.eventName === 'workflow_dispatch' && dispatchChannel === 'stable') {
const { tag, sha, version } = await resolveLatestNightlyCommit({ github, context, core });
Expand Down Expand Up @@ -654,8 +657,10 @@ jobs:
# not at all.
desktop_mac_arm64:
name: Desktop macOS arm64
needs: [preflight, relay_public_config, build_bundle]
if: ${{ !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' && needs.build_bundle.result == 'success' }}
# Fork: hosted macOS minutes are the release's main cost, so on every trigger (nightly, dispatch,
# tag) macOS builds wait for the release tests; a failing run then spends no macOS time.
needs: [preflight, relay_public_config, build_bundle, quality, test, test_web, test_server]
if: ${{ !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' && needs.build_bundle.result == 'success' && needs.quality.result == 'success' && needs.test.result == 'success' && needs.test_web.result == 'success' && needs.test_server.result == 'success' }}
uses: ./.github/workflows/release-desktop.yml
secrets: inherit
with:
Expand All @@ -680,8 +685,10 @@ jobs:

desktop_mac_x64:
name: Desktop macOS x64
needs: [preflight, relay_public_config, build_bundle]
if: ${{ !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' && needs.build_bundle.result == 'success' }}
# Fork: hosted macOS minutes are the release's main cost, so on every trigger (nightly, dispatch,
# tag) macOS builds wait for the release tests; a failing run then spends no macOS time.
needs: [preflight, relay_public_config, build_bundle, quality, test, test_web, test_server]
if: ${{ !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' && needs.build_bundle.result == 'success' && needs.quality.result == 'success' && needs.test.result == 'success' && needs.test_web.result == 'success' && needs.test_server.result == 'success' }}
uses: ./.github/workflows/release-desktop.yml
secrets: inherit
with:
Expand Down Expand Up @@ -809,8 +816,9 @@ jobs:
# Fork: an unsigned iOS IPA for sideloading, only when the fork sets T3CODE_MOBILE_RELEASE.
mobile_ios_unsigned:
name: Mobile iOS (unsigned)
needs: [preflight, relay_public_config]
if: ${{ !cancelled() && vars.T3CODE_MOBILE_RELEASE == 'true' && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' }}
# Waits for the release tests for the same reason as the macOS desktop builds.
needs: [preflight, relay_public_config, quality, test, test_web, test_server]
if: ${{ !cancelled() && vars.T3CODE_MOBILE_RELEASE == 'true' && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' && needs.quality.result == 'success' && needs.test.result == 'success' && needs.test_web.result == 'success' && needs.test_server.result == 'success' }}
uses: ./.github/workflows/release-mobile-ios.yml
with:
version: ${{ needs.preflight.outputs.version }}
Expand Down
19 changes: 16 additions & 3 deletions docs/operations/fork-releases.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ and `T3CODE_IOS_RUNNER` for the unsigned IPA to use the Intel pool when ARM capa
Each falls back to `T3CODE_MACOS_RUNNER` when unset; the arm64 desktop build keeps that variable.
The IPA cross-compiles for arm64 on either host. Its build skips index stores and dSYM bundles,
and reports elapsed build time in the job log. Hosted runners start with fresh DerivedData,
but restore Xcode's content-addressed compilation cache for the same Xcode build, host architecture,
and dependency inputs. A native change can still reuse unchanged dependency compilations. Cold
builds populate the cache; only a measured warm job can establish the end-to-end build time.
but restore Xcode's content-addressed compilation cache for the same Xcode build and host
architecture. Entries are saved once per dependency change, not per commit, and a dependency change
restores the previous entry, so only the changed dependencies recompile. A per-commit key filled
the repository's 10 GB cache and evicted itself, turning ~13-minute builds into ~80-minute cold
ones. A restored cache over 3 GB is dropped so it cannot crowd out the other caches.
The `mobile-ios-build-log` artifact includes compilation-cache diagnostics and Xcode task timings.

## Releases
Expand Down Expand Up @@ -80,6 +82,17 @@ only when the fork opts in:
| `T3CODE_RELEASE_APP` | The stable-release version bump pushed to `main` by a GitHub App (`RELEASE_APP_ID`, `RELEASE_APP_PRIVATE_KEY`). Without it, bump versions by hand after a stable release. |
| `T3CODE_MOBILE_RELEASE` | An unsigned iOS IPA on every release (see [iOS sideload build](#ios-sideload-build)). A failed build blocks the release. |

Hosted macOS minutes are the release's main cost: the two macOS desktop builds and the IPA take
roughly 40 to 60 minutes per release. Two settings keep that down:

- `T3CODE_NIGHTLY_GAP_HOURS` sets the minimum hours between automatic nightlies. Upstream uses 6,
which can mean four nightlies a day; this fork sets `24`.
- The macOS and iOS builds start only after the release tests pass, so a failing run spends no
macOS time. This applies to nightlies, dispatched releases, and tag pushes, and adds the test
time (about 7 minutes) to every release.

`PAUSE_NIGHTLY` set to `true` stops automatic nightlies entirely; dispatched releases still run.

Builds are unsigned unless the signing secrets in [release](./release.md) are set. Unsigned
Windows and Linux builds install and update; macOS needs signing and notarization before it can
update itself.
Expand Down
Loading