create-disposabl-app 0.17.0 → 0.17.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/disposabl.js +1 -1
- package/dist/index.js +1 -1
- package/dist/templates/default/.github/scripts/android-runner.sh +19 -1
- package/dist/templates/default/.github/workflows/android-cache-prime.yml +64 -0
- package/dist/templates/default/.github/workflows/pipeline.yml +13 -0
- package/dist/templates/default/packages/tests/android-ota-selection.test.ts +8 -2
- package/dist/templates/default/packages/tests/android-runner.test.ts +106 -2
- package/dist/templates/default/packages/tests/mobile-google.test.ts +24 -9
- package/package.json +1 -1
package/dist/disposabl.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -1563,7 +1563,7 @@ import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
|
1563
1563
|
import { Command, CommanderError } from "commander";
|
|
1564
1564
|
import * as p2 from "@clack/prompts";
|
|
1565
1565
|
// package.json
|
|
1566
|
-
var version = "0.17.
|
|
1566
|
+
var version = "0.17.2";
|
|
1567
1567
|
|
|
1568
1568
|
// ../cli/telemetry.ts
|
|
1569
1569
|
var import_proper_lockfile2 = __toESM(require_proper_lockfile(), 1);
|
|
@@ -4,9 +4,10 @@ set -euo pipefail
|
|
|
4
4
|
case "${1:?operation required}" in
|
|
5
5
|
prepare)
|
|
6
6
|
df -Pk .
|
|
7
|
+
available=$(df -Pk . | awk 'END {print $4}')
|
|
7
8
|
# Only disposable GitHub-hosted Linux runners. Keep Android, Java, Node,
|
|
8
9
|
# the checkout and dependency caches intact; these toolchains are unused.
|
|
9
|
-
if [[ "${GITHUB_ACTIONS:-}" == true && "${RUNNER_ENVIRONMENT:-}" == github-hosted && "${RUNNER_OS:-}" == Linux ]]; then
|
|
10
|
+
if [[ "${GITHUB_ACTIONS:-}" == true && "${RUNNER_ENVIRONMENT:-}" == github-hosted && "${RUNNER_OS:-}" == Linux && "$available" =~ ^[0-9]+$ ]] && (( available < 25 * 1024 * 1024 )); then
|
|
10
11
|
unused=(/usr/share/dotnet /usr/local/.ghcup /opt/ghc /opt/hostedtoolcache/CodeQL
|
|
11
12
|
/usr/share/swift /usr/share/miniconda /opt/microsoft/powershell /usr/local/share/powershell
|
|
12
13
|
/usr/local/share/vcpkg /home/linuxbrew)
|
|
@@ -36,7 +37,24 @@ case "${1:?operation required}" in
|
|
|
36
37
|
TIMEFORMAT='Gradle elapsed: %3R seconds; shell and child CPU: %3U user, %3S system'
|
|
37
38
|
status=0
|
|
38
39
|
time ./gradlew :app:assembleRelease --no-daemon --build-cache || status=$?
|
|
40
|
+
if [[ -n "${CCACHE_DIR:-}" ]]; then ccache --show-stats; fi
|
|
39
41
|
exit "$status"
|
|
40
42
|
;;
|
|
43
|
+
prime)
|
|
44
|
+
now=$(date +%s)
|
|
45
|
+
start=${ANDROID_PRIME_STARTED_AT:-}
|
|
46
|
+
[[ "$start" =~ ^[0-9]+$ ]] && (( start <= now )) || { echo 'Missing or invalid warmup start time.' >&2; exit 1; }
|
|
47
|
+
# The first step records the start; leave four minutes for setup-job overhead,
|
|
48
|
+
# signal handling, cache uploads and setup-gradle post-job cleanup.
|
|
49
|
+
remaining=$((start + 16 * 60 - now))
|
|
50
|
+
(( remaining > 0 )) || { echo 'Insufficient time remaining to compile and save cache.' >&2; exit 1; }
|
|
51
|
+
echo "Native compilation budget: ${remaining}s; four-minute reserve from first-step start for job overhead and cache saving."
|
|
52
|
+
timeout --signal=INT --kill-after=15s "${remaining}s" ./gradlew :app:externalNativeBuildRelease --no-daemon --build-cache
|
|
53
|
+
ccache --show-stats
|
|
54
|
+
result=$(find "${CCACHE_DIR:?}" -type f -name '*R' -size +0c -print -quit)
|
|
55
|
+
[[ -n "$result" ]] || { echo 'No compiler result was cached.' >&2; exit 1; }
|
|
56
|
+
inspection=$(ccache --inspect "$result")
|
|
57
|
+
[[ "$inspection" == *' (result)'* ]] || { echo 'Invalid compiler result.' >&2; exit 1; }
|
|
58
|
+
;;
|
|
41
59
|
*) echo "Unknown operation: $1" >&2; exit 1 ;;
|
|
42
60
|
esac
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
name: Prime Android native cache
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
|
|
6
|
+
permissions:
|
|
7
|
+
contents: read
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
prime:
|
|
11
|
+
if: github.ref == 'refs/heads/main'
|
|
12
|
+
runs-on: ubuntu-24.04
|
|
13
|
+
timeout-minutes: 20
|
|
14
|
+
env:
|
|
15
|
+
DO_NOT_TRACK: "1"
|
|
16
|
+
E2E_TELEMETRY_DISABLED: "1"
|
|
17
|
+
EXPO_NO_TELEMETRY: "1"
|
|
18
|
+
EXPO_NO_DOTENV: "1"
|
|
19
|
+
DISPOSABL_MOBILE_CHANNEL: production
|
|
20
|
+
EXPO_PROJECT_ID: 00000000-0000-4000-8000-000000000001
|
|
21
|
+
CCACHE_COMPILERCHECK: content
|
|
22
|
+
CMAKE_C_COMPILER_LAUNCHER: ccache
|
|
23
|
+
CMAKE_CXX_COMPILER_LAUNCHER: ccache
|
|
24
|
+
steps:
|
|
25
|
+
- name: Record warmup start
|
|
26
|
+
run: |
|
|
27
|
+
printf 'ANDROID_PRIME_STARTED_AT=%s\nCCACHE_DIR=%s\n' "$(date +%s)" "$RUNNER_TEMP/ccache" >> "$GITHUB_ENV"
|
|
28
|
+
- uses: actions/checkout@v6
|
|
29
|
+
with: { persist-credentials: false }
|
|
30
|
+
- uses: actions/setup-node@v6
|
|
31
|
+
with: { node-version: "24", package-manager-cache: false }
|
|
32
|
+
- uses: oven-sh/setup-bun@v2
|
|
33
|
+
with: { bun-version: "1.4.4" }
|
|
34
|
+
- run: bun install --frozen-lockfile --filter @disposabl/mobile
|
|
35
|
+
- uses: actions/setup-java@v5
|
|
36
|
+
with: { distribution: temurin, java-version: "17" }
|
|
37
|
+
- uses: android-actions/setup-android@v3
|
|
38
|
+
with: { packages: platform-tools }
|
|
39
|
+
- uses: gradle/actions/setup-gradle@v4
|
|
40
|
+
with: { cache-read-only: false }
|
|
41
|
+
- name: Install compiler cache
|
|
42
|
+
run: |
|
|
43
|
+
sudo apt-get update -qq
|
|
44
|
+
sudo apt-get install -y ccache
|
|
45
|
+
- name: Restore compiler cache
|
|
46
|
+
id: cache
|
|
47
|
+
uses: actions/cache/restore@v4
|
|
48
|
+
with:
|
|
49
|
+
path: ${{ runner.temp }}/ccache
|
|
50
|
+
key: android-ccache-v1-${{ runner.os }}-${{ runner.arch }}-${{ github.sha }}
|
|
51
|
+
- name: Prebuild Android
|
|
52
|
+
if: steps.cache.outputs.cache-hit != 'true'
|
|
53
|
+
working-directory: apps/mobile
|
|
54
|
+
run: bun x --no-install expo prebuild --platform android --no-install
|
|
55
|
+
- name: Compile native targets within budget
|
|
56
|
+
if: steps.cache.outputs.cache-hit != 'true'
|
|
57
|
+
working-directory: apps/mobile/android
|
|
58
|
+
run: bash ../../../.github/scripts/android-runner.sh prime
|
|
59
|
+
- name: Save compiler cache
|
|
60
|
+
if: steps.cache.outputs.cache-hit != 'true'
|
|
61
|
+
uses: actions/cache/save@v4
|
|
62
|
+
with:
|
|
63
|
+
path: ${{ runner.temp }}/ccache
|
|
64
|
+
key: android-ccache-v1-${{ runner.os }}-${{ runner.arch }}-${{ github.sha }}
|
|
@@ -215,6 +215,19 @@ jobs:
|
|
|
215
215
|
- name: Gradle
|
|
216
216
|
uses: gradle/actions/setup-gradle@v4
|
|
217
217
|
with: { cache-read-only: false }
|
|
218
|
+
- name: Restore native compiler cache
|
|
219
|
+
if: github.event_name == 'push'
|
|
220
|
+
id: native-cache
|
|
221
|
+
uses: actions/cache/restore@v4
|
|
222
|
+
with:
|
|
223
|
+
path: ${{ runner.temp }}/ccache
|
|
224
|
+
key: android-ccache-v1-${{ runner.os }}-${{ runner.arch }}-${{ github.sha }}
|
|
225
|
+
- name: Install native compiler cache
|
|
226
|
+
if: github.event_name == 'push' && steps.native-cache.outputs.cache-hit == 'true'
|
|
227
|
+
run: |
|
|
228
|
+
sudo apt-get update -qq
|
|
229
|
+
sudo apt-get install -y ccache
|
|
230
|
+
printf 'CCACHE_DIR=%s\nCCACHE_COMPILERCHECK=content\nCMAKE_C_COMPILER_LAUNCHER=ccache\nCMAKE_CXX_COMPILER_LAUNCHER=ccache\n' "$RUNNER_TEMP/ccache" >> "$GITHUB_ENV"
|
|
218
231
|
- name: Build
|
|
219
232
|
working-directory: apps/mobile
|
|
220
233
|
env:
|
|
@@ -11,7 +11,7 @@ import { tmpdir } from "node:os";
|
|
|
11
11
|
import { join, resolve } from "node:path";
|
|
12
12
|
import { spawnSync } from "node:child_process";
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
function verifyOtaSelection() {
|
|
15
15
|
for (const [channel, tag, reusable, architectures] of [
|
|
16
16
|
["pr-1", "app-pr-1-android", true],
|
|
17
17
|
["production", "app-production-android", true],
|
|
@@ -113,4 +113,10 @@ else process.exit(1);
|
|
|
113
113
|
rmSync(cwd, { recursive: true, force: true });
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
|
-
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
test(
|
|
119
|
+
"OTA selection accepts only source tags supported by the trusted publisher",
|
|
120
|
+
{ timeout: 30000 },
|
|
121
|
+
verifyOtaSelection,
|
|
122
|
+
);
|
|
@@ -3,7 +3,7 @@ import assert from "node:assert/strict";
|
|
|
3
3
|
import { mkdtempSync, writeFileSync, readFileSync, rmSync } from "node:fs";
|
|
4
4
|
import { tmpdir } from "node:os";
|
|
5
5
|
import { join, resolve } from "node:path";
|
|
6
|
-
import { spawnSync } from "node:child_process";
|
|
6
|
+
import { execFileSync, spawnSync } from "node:child_process";
|
|
7
7
|
|
|
8
8
|
test("Android build diagnostics preserve Gradle arguments and failure status", () => {
|
|
9
9
|
const dir = mkdtempSync(join(tmpdir(), "android-build-"));
|
|
@@ -114,6 +114,8 @@ test("Android disk preparation only removes unused hosted-runner toolchains", ()
|
|
|
114
114
|
assert.equal(readFileSync(calls, "utf8"), "");
|
|
115
115
|
}
|
|
116
116
|
assert.equal(run("prepare").status, 0);
|
|
117
|
+
assert.equal(readFileSync(calls, "utf8"), "");
|
|
118
|
+
assert.equal(run("prepare", { AVAILABLE: "1024" }).status, 0);
|
|
117
119
|
assert.equal(
|
|
118
120
|
readFileSync(calls, "utf8"),
|
|
119
121
|
"rm -rf -- /usr/share/dotnet /usr/local/.ghcup /opt/ghc /opt/hostedtoolcache/CodeQL /usr/share/swift /usr/share/miniconda /opt/microsoft/powershell /usr/local/share/powershell /usr/local/share/vcpkg /home/linuxbrew\n",
|
|
@@ -127,8 +129,110 @@ test("Android disk preparation only removes unused hosted-runner toolchains", ()
|
|
|
127
129
|
assert.equal(run("check", { AVAILABLE: "invalid" }).status, 1);
|
|
128
130
|
assert.equal(run("unsupported").status, 1);
|
|
129
131
|
writeFileSync(join(dir, "sudo"), "#!/bin/sh\nexit 42\n", { mode: 0o755 });
|
|
130
|
-
assert.equal(run("prepare").status, 42);
|
|
132
|
+
assert.equal(run("prepare", { AVAILABLE: "1024" }).status, 42);
|
|
131
133
|
} finally {
|
|
132
134
|
rmSync(dir, { recursive: true, force: true });
|
|
133
135
|
}
|
|
134
136
|
});
|
|
137
|
+
|
|
138
|
+
test("native warmup requires completed Gradle work, a real result, and enough remaining time", () => {
|
|
139
|
+
const dir = mkdtempSync(join(tmpdir(), "android-prime-"));
|
|
140
|
+
try {
|
|
141
|
+
writeFileSync(
|
|
142
|
+
join(dir, "gradlew"),
|
|
143
|
+
'#!/bin/sh\nprintf "%s\\n" "$*" > "$GRADLE_CALL"\nif [ "$GRADLE_SLEEP" = 1 ]; then sleep 5; fi\nexit "$GRADLE_RESULT"\n',
|
|
144
|
+
{ mode: 0o755 },
|
|
145
|
+
);
|
|
146
|
+
writeFileSync(
|
|
147
|
+
join(dir, "ccache"),
|
|
148
|
+
'#!/bin/sh\nif [ "$1" = "--inspect" ]; then echo "Entry type: 0 (result)"; fi\n',
|
|
149
|
+
{ mode: 0o755 },
|
|
150
|
+
);
|
|
151
|
+
const script = resolve(
|
|
152
|
+
import.meta.dirname,
|
|
153
|
+
"../../.github/scripts/android-runner.sh",
|
|
154
|
+
);
|
|
155
|
+
const resultFile = join(dir, "testR");
|
|
156
|
+
writeFileSync(resultFile, "cached result fixture");
|
|
157
|
+
const run = (status: number, age: number, sleep = false) =>
|
|
158
|
+
spawnSync("bash", [script, "prime"], {
|
|
159
|
+
cwd: dir,
|
|
160
|
+
encoding: "utf8",
|
|
161
|
+
timeout: 10000,
|
|
162
|
+
env: {
|
|
163
|
+
...process.env,
|
|
164
|
+
PATH: `${dir}:${process.env.PATH}`,
|
|
165
|
+
CCACHE_DIR: dir,
|
|
166
|
+
ANDROID_PRIME_STARTED_AT: String(Math.floor(Date.now() / 1000) - age),
|
|
167
|
+
GRADLE_CALL: join(dir, "gradle-call"),
|
|
168
|
+
GRADLE_RESULT: String(status),
|
|
169
|
+
GRADLE_SLEEP: sleep ? "1" : "0",
|
|
170
|
+
},
|
|
171
|
+
});
|
|
172
|
+
const ok = run(0, 100);
|
|
173
|
+
assert.equal(ok.status, 0, ok.stderr);
|
|
174
|
+
assert.match(ok.stdout, /Native compilation budget: 8[0-9][0-9]s/);
|
|
175
|
+
assert.match(
|
|
176
|
+
readFileSync(join(dir, "gradle-call"), "utf8"),
|
|
177
|
+
/:app:externalNativeBuildRelease/,
|
|
178
|
+
);
|
|
179
|
+
assert.equal(run(124, 100).status, 124);
|
|
180
|
+
const timedOut = run(0, 958, true);
|
|
181
|
+
assert.ok(
|
|
182
|
+
timedOut.status === 124 || timedOut.status === 137,
|
|
183
|
+
`expected timeout failure, got ${timedOut.status}`,
|
|
184
|
+
);
|
|
185
|
+
assert.equal(run(42, 100).status, 42);
|
|
186
|
+
assert.match(run(0, 961).stderr, /Insufficient time remaining/);
|
|
187
|
+
rmSync(resultFile);
|
|
188
|
+
assert.match(run(0, 100).stderr, /No compiler result was cached/);
|
|
189
|
+
} finally {
|
|
190
|
+
rmSync(dir, { recursive: true, force: true });
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
test("native warmup and production use the same exact-commit cache", () => {
|
|
195
|
+
const root = resolve(import.meta.dirname, "../..");
|
|
196
|
+
const primeText = readFileSync(
|
|
197
|
+
join(root, ".github/workflows/android-cache-prime.yml"),
|
|
198
|
+
"utf8",
|
|
199
|
+
);
|
|
200
|
+
const pipelineText = readFileSync(
|
|
201
|
+
join(root, ".github/workflows/pipeline.yml"),
|
|
202
|
+
"utf8",
|
|
203
|
+
);
|
|
204
|
+
const prime = JSON.parse(
|
|
205
|
+
execFileSync(
|
|
206
|
+
process.execPath,
|
|
207
|
+
[
|
|
208
|
+
"-e",
|
|
209
|
+
"console.log(JSON.stringify(Bun.YAML.parse(await Bun.file(process.argv[1]).text())))",
|
|
210
|
+
join(root, ".github/workflows/android-cache-prime.yml"),
|
|
211
|
+
],
|
|
212
|
+
{ encoding: "utf8" },
|
|
213
|
+
),
|
|
214
|
+
) as {
|
|
215
|
+
jobs: {
|
|
216
|
+
prime: {
|
|
217
|
+
if: string;
|
|
218
|
+
"timeout-minutes": number;
|
|
219
|
+
env: Record<string, string>;
|
|
220
|
+
};
|
|
221
|
+
};
|
|
222
|
+
};
|
|
223
|
+
assert.equal(prime.jobs.prime.if, "github.ref == 'refs/heads/main'");
|
|
224
|
+
assert.equal(prime.jobs.prime["timeout-minutes"], 20);
|
|
225
|
+
assert.doesNotMatch(
|
|
226
|
+
JSON.stringify(prime.jobs.prime.env),
|
|
227
|
+
/\$\{\{\s*runner\./,
|
|
228
|
+
);
|
|
229
|
+
assert.match(primeText, /CCACHE_DIR=%s\\n.*\$RUNNER_TEMP\/ccache/);
|
|
230
|
+
assert.doesNotMatch(primeText, /secrets\.|id-token|publish|report/i);
|
|
231
|
+
const key =
|
|
232
|
+
"android-ccache-v1-${{ runner.os }}-${{ runner.arch }}-${{ github.sha }}";
|
|
233
|
+
assert.equal(primeText.split(key).length - 1, 2);
|
|
234
|
+
assert.equal(pipelineText.split(key).length - 1, 1);
|
|
235
|
+
assert.match(primeText, /actions\/cache\/save@v4/);
|
|
236
|
+
assert.match(pipelineText, /actions\/cache\/restore@v4/);
|
|
237
|
+
assert.doesNotMatch(primeText + pipelineText, /CCACHE_SLOPPINESS/);
|
|
238
|
+
});
|
|
@@ -70,15 +70,30 @@ test(
|
|
|
70
70
|
),
|
|
71
71
|
},
|
|
72
72
|
() => {
|
|
73
|
-
const
|
|
74
|
-
"
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
73
|
+
const keys = [
|
|
74
|
+
"CONVEX_URL",
|
|
75
|
+
"CONVEX_SITE_URL",
|
|
76
|
+
"EXPO_PUBLIC_CONVEX_URL",
|
|
77
|
+
"EXPO_PUBLIC_CONVEX_SITE_URL",
|
|
78
|
+
];
|
|
79
|
+
const saved = keys.map((key) => process.env[key]);
|
|
80
|
+
try {
|
|
81
|
+
for (const key of keys) delete process.env[key];
|
|
82
|
+
const configure = createRequire(import.meta.url)(
|
|
83
|
+
"../../apps/mobile/app.config.js",
|
|
84
|
+
);
|
|
85
|
+
const config = configure({ config: { scheme: ["custom", "another"] } });
|
|
86
|
+
assert.deepEqual(config.scheme, [
|
|
87
|
+
"custom",
|
|
88
|
+
"another",
|
|
89
|
+
new URL(mobileAuthReturnUrl).protocol.slice(0, -1),
|
|
90
|
+
]);
|
|
91
|
+
} finally {
|
|
92
|
+
keys.forEach((key, index) => {
|
|
93
|
+
if (saved[index] === undefined) delete process.env[key];
|
|
94
|
+
else process.env[key] = saved[index];
|
|
95
|
+
});
|
|
96
|
+
}
|
|
82
97
|
},
|
|
83
98
|
);
|
|
84
99
|
|