-
Notifications
You must be signed in to change notification settings - Fork 180
chore: speed up ios e2e builds #1032
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
Changes from all commits
6524b43
c76c972
7531dd5
0d38d80
f6b6f1c
d7fcbaa
77978e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,7 @@ | |
| "analyze:tree-shaking:web": "yarn web:build && node ./scripts/analyze-tree-shaking.cjs web", | ||
| "android": "yarn build:deps && react-native run-android", | ||
| "android:ci": "./scripts/mobile-ci-build-android.sh", | ||
| "build:deps": "yarn workspaces foreach --from @selfxyz/mobile-app --topological --recursive run build", | ||
| "build:deps": "node ../scripts/build-deps-if-changed.mjs @selfxyz/mobile-app", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainOn cache miss this may skip needed builds; see script’s shallow-fetch issue Because After applying the script fix, please verify no false skips: 🏁 Script executed: #!/bin/bash
# Should print "Building @selfxyz/common..." or "@selfxyz/mobile-sdk-alpha..." at least once when cache is empty
node ./scripts/build-deps-if-changed.mjs @selfxyz/mobile-app || trueLength of output: 281 Don't treat git-diff failures as "no changes" — make the script build on diff error or fetch the base before diff Observed: running node ./scripts/build-deps-if-changed.mjs @selfxyz/mobile-app produced "fatal: ambiguous argument 'origin/dev...HEAD'" then "Skipping @selfxyz/*; no changes" — this false skip on cache miss will break downstream iOS builds.
Locations: app/package.json (build:deps) and scripts/build-deps-if-changed.mjs. 🤖 Prompt for AI Agents |
||
| "bump-version:major": "npm version major && yarn sync-versions", | ||
| "bump-version:minor": "npm version minor && yarn sync-versions", | ||
| "bump-version:patch": "npm version patch && yarn sync-versions", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,6 +47,7 @@ | |
| ], | ||
| "scripts": { | ||
| "build": "rm -rf dist && tsup && yarn postbuild", | ||
| "build:deps": "node ../../scripts/build-deps-if-changed.mjs @selfxyz/mobile-sdk-alpha", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unblock CI: type/module resolution for subpath “constants/analytics” fails pre-build Lint/types fail with “Unable to resolve …/constants/analytics” when dist isn’t built. Exports point Apply: "exports": {
@@
},
+ "typesVersions": {
+ "*": {
+ "constants/analytics": ["src/constants/analytics.ts"],
+ "stores": ["src/stores.ts"],
+ "browser": ["src/browser.ts"],
+ "*": ["src/*"]
+ }
+ },Optional follow-up: add a
🤖 Prompt for AI Agents |
||
| "postbuild": "node ./scripts/postBuild.mjs", | ||
| "demo:android": "yarn workspace demo-app android", | ||
| "demo:ios": "yarn workspace demo-app ios", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| #!/usr/bin/env node | ||
| import { execSync } from 'node:child_process'; | ||
|
|
||
| const workspace = process.argv[2]; | ||
| if (!workspace) { | ||
| console.error('Usage: build-deps-if-changed <workspace>'); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| const baseRef = process.env.GITHUB_BASE_REF | ||
| ? `origin/${process.env.GITHUB_BASE_REF}` | ||
| : 'origin/dev'; | ||
| let diff; | ||
| try { | ||
| diff = execSync(`git diff --name-only ${baseRef}...HEAD`, { | ||
| encoding: 'utf8', | ||
| }) | ||
| .split('\n') | ||
| .filter(Boolean); | ||
| } catch { | ||
| diff = []; | ||
| } | ||
|
Comment on lines
+10
to
+22
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Fix: shallow-fetch makes diff empty; builds get silently skipped on cache miss actions/checkout defaults to fetch-depth: 1, so Apply: -const baseRef = process.env.GITHUB_BASE_REF
- ? `origin/${process.env.GITHUB_BASE_REF}`
- : 'origin/dev';
-let diff;
-try {
- diff = execSync(`git diff --name-only ${baseRef}...HEAD`, {
- encoding: 'utf8',
- })
- .split('\n')
- .filter(Boolean);
-} catch {
- diff = [];
-}
+const baseBranch = process.env.GITHUB_BASE_REF || 'dev';
+const baseRef = `origin/${baseBranch}`;
+let diff = null;
+try {
+ // Ensure base ref exists for shallow clones
+ try {
+ execSync(`git rev-parse --verify ${baseRef}`, { stdio: 'ignore' });
+ } catch {
+ execSync(`git fetch --no-tags --depth=1 origin ${baseBranch}:${baseRef}`, { stdio: 'ignore' });
+ }
+ diff = execSync(`git diff --name-only ${baseRef}...HEAD`, { encoding: 'utf8' })
+ .split('\n')
+ .filter(Boolean);
+} catch (e) {
+ console.warn(`[build-deps-if-changed] Unable to compute diff against ${baseRef}: ${e?.message ?? e}`);
+ // Leave diff=null to trigger safe default: build all deps
+}
@@
-for (const [pkg, dir] of deps) {
- const changed = diff.some(f => f.startsWith(dir));
+for (const [pkg, dir] of deps) {
+ const changed = diff ? diff.some(f => f.startsWith(dir)) : true;
if (changed) {
console.log(`Building ${pkg}...`);
execSync(`yarn workspace ${pkg} build`, { stdio: 'inherit' });
} else {
console.log(`Skipping ${pkg}; no changes`);
}
}Also applies to: 33-41 |
||
|
|
||
| const deps = | ||
| { | ||
| '@selfxyz/mobile-app': [ | ||
| ['@selfxyz/common', 'common/'], | ||
| ['@selfxyz/mobile-sdk-alpha', 'packages/mobile-sdk-alpha/'], | ||
| ], | ||
| '@selfxyz/mobile-sdk-alpha': [['@selfxyz/common', 'common/']], | ||
| }[workspace] || []; | ||
|
|
||
| for (const [pkg, dir] of deps) { | ||
| const changed = diff.some(f => f.startsWith(dir)); | ||
| if (changed) { | ||
| console.log(`Building ${pkg}...`); | ||
| execSync(`yarn workspace ${pkg} build`, { stdio: 'inherit' }); | ||
| } else { | ||
| console.log(`Skipping ${pkg}; no changes`); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Cache logic incomplete: restore happens, but nothing saves post-build
You invoke the composite (which currently saves too early). Move the save to after the “Build dependencies (cache miss)” step so future runs hit the cache.
Apply:
- name: Cache Built Dependencies id: built-deps uses: ./.github/actions/cache-built-deps with: cache-version: ${{ env.GH_CACHE_VERSION }}-${{ env.NODE_VERSION_SANITIZED }} - name: Build dependencies (cache miss) if: steps.built-deps.outputs.cache-hit != 'true' run: | echo "Cache miss for built dependencies. Building now..." yarn workspace @selfxyz/mobile-app run build:deps --silent || { echo "❌ Dependency build failed"; exit 1; } echo "✅ Dependencies built successfully" + - name: Save Built Dependencies + if: steps.built-deps.outputs.cache-hit != 'true' + uses: actions/cache/save@v4 + with: + path: | + common/dist + packages/mobile-sdk-alpha/dist + key: built-deps-${{ env.GH_CACHE_VERSION }}-${{ env.NODE_VERSION_SANITIZED }}-${{ hashFiles('common/**/*', 'packages/mobile-sdk-alpha/**/*', '!common/dist/**', '!packages/mobile-sdk-alpha/dist/**', '!common/**/__tests__/**', '!common/**/*.test.*', '!common/**/*.spec.*', '!packages/mobile-sdk-alpha/**/__tests__/**', '!packages/mobile-sdk-alpha/**/*.test.*', '!packages/mobile-sdk-alpha/**/*.spec.*') }}Optional: switch to a dedicated
.github/actions/cache-built-deps-saveto avoid directactions/cacheusage in workflows, matching your guidelines. I can add that if you want.