Skip to content

Commit 2ed8bcf

Browse files
authored
feat: modernize sdk/qrcode build pipeline (#872)
* Modernize qrcode build * chore(qrcode): add lint helpers * fix sdk qrcode * add new qrcode ci * fix formatting * qrcode fixes * fixes * fixes rd2 * enable corepack * enable corepack * build caching * update caching * cr feedback
1 parent 29c620b commit 2ed8bcf

24 files changed

+791
-130
lines changed
Lines changed: 253 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,253 @@
1+
name: QRCode SDK CI
2+
3+
env:
4+
# Build environment versions
5+
NODE_VERSION: 22
6+
# Cache versioning - increment these to bust caches when needed
7+
GH_CACHE_VERSION: v1 # Global cache version
8+
GH_YARN_CACHE_VERSION: v1 # Yarn-specific cache version
9+
GH_SDK_CACHE_VERSION: v1 # SDK build cache version
10+
11+
on:
12+
pull_request:
13+
paths:
14+
- "sdk/qrcode/**"
15+
- "common/**"
16+
- ".github/workflows/qrcode-sdk-ci.yml"
17+
- ".github/actions/**"
18+
push:
19+
branches: [main, develop]
20+
paths:
21+
- "sdk/qrcode/**"
22+
- "common/**"
23+
24+
jobs:
25+
# Build dependencies once and cache for other jobs
26+
build:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v4
30+
31+
- name: Use Node.js ${{ env.NODE_VERSION }}
32+
uses: actions/setup-node@v4
33+
with:
34+
node-version: ${{ env.NODE_VERSION }}
35+
36+
- name: Enable Corepack
37+
run: corepack enable
38+
39+
- name: Cache Yarn dependencies
40+
id: yarn-cache
41+
uses: actions/cache@v4
42+
with:
43+
path: |
44+
.yarn/cache
45+
node_modules
46+
sdk/qrcode/node_modules
47+
common/node_modules
48+
key: ${{ runner.os }}-${{ env.GH_YARN_CACHE_VERSION }}-node${{ env.NODE_VERSION }}-yarn-${{ hashFiles('yarn.lock') }}
49+
restore-keys: |
50+
${{ runner.os }}-${{ env.GH_YARN_CACHE_VERSION }}-node${{ env.NODE_VERSION }}-yarn-
51+
52+
- name: Install Dependencies
53+
uses: ./.github/actions/yarn-install
54+
55+
- name: Build dependencies
56+
shell: bash
57+
run: |
58+
yarn workspace @selfxyz/common build
59+
yarn workspace @selfxyz/qrcode build
60+
61+
- name: Cache build artifacts
62+
uses: actions/cache/save@v4
63+
with:
64+
path: |
65+
common/dist
66+
sdk/qrcode/dist
67+
key: qrcode-sdk-build-${{ env.GH_SDK_CACHE_VERSION }}-${{ github.sha }}
68+
69+
# Quality checks job
70+
quality-checks:
71+
runs-on: ubuntu-latest
72+
needs: build
73+
steps:
74+
- uses: actions/checkout@v4
75+
76+
- name: Use Node.js ${{ env.NODE_VERSION }}
77+
uses: actions/setup-node@v4
78+
with:
79+
node-version: ${{ env.NODE_VERSION }}
80+
81+
- name: Enable Corepack
82+
run: corepack enable
83+
84+
- name: Cache Yarn dependencies
85+
id: yarn-cache
86+
uses: actions/cache@v4
87+
with:
88+
path: |
89+
.yarn/cache
90+
node_modules
91+
sdk/qrcode/node_modules
92+
common/node_modules
93+
key: ${{ runner.os }}-${{ env.GH_YARN_CACHE_VERSION }}-node${{ env.NODE_VERSION }}-yarn-${{ hashFiles('yarn.lock') }}
94+
restore-keys: |
95+
${{ runner.os }}-${{ env.GH_YARN_CACHE_VERSION }}-node${{ env.NODE_VERSION }}-yarn-
96+
97+
- name: Install Dependencies
98+
uses: ./.github/actions/yarn-install
99+
100+
- name: Restore build artifacts
101+
uses: actions/cache/restore@v4
102+
with:
103+
path: |
104+
common/dist
105+
sdk/qrcode/dist
106+
key: qrcode-sdk-build-${{ env.GH_SDK_CACHE_VERSION }}-${{ github.sha }}
107+
fail-on-cache-miss: true
108+
109+
- name: Run linter
110+
run: yarn workspace @selfxyz/qrcode lint:imports:check
111+
112+
- name: Check Prettier formatting
113+
run: yarn workspace @selfxyz/qrcode lint
114+
115+
- name: Type checking
116+
run: yarn workspace @selfxyz/qrcode types
117+
118+
- name: Log cache status
119+
run: |
120+
echo "Cache hit results:"
121+
echo "- Yarn cache hit: ${{ steps.yarn-cache.outputs.cache-hit }}"
122+
123+
# Build verification job
124+
build-verification:
125+
runs-on: ubuntu-latest
126+
needs: build
127+
steps:
128+
- uses: actions/checkout@v4
129+
130+
- name: Use Node.js ${{ env.NODE_VERSION }}
131+
uses: actions/setup-node@v4
132+
with:
133+
node-version: ${{ env.NODE_VERSION }}
134+
135+
- name: Enable Corepack
136+
run: corepack enable
137+
138+
- name: Cache Yarn dependencies
139+
id: yarn-cache
140+
uses: actions/cache@v4
141+
with:
142+
path: |
143+
.yarn/cache
144+
node_modules
145+
sdk/qrcode/node_modules
146+
common/node_modules
147+
key: ${{ runner.os }}-${{ env.GH_YARN_CACHE_VERSION }}-node${{ env.NODE_VERSION }}-yarn-${{ hashFiles('yarn.lock') }}
148+
restore-keys: |
149+
${{ runner.os }}-${{ env.GH_YARN_CACHE_VERSION }}-node${{ env.NODE_VERSION }}-yarn-
150+
151+
- name: Install Dependencies
152+
uses: ./.github/actions/yarn-install
153+
154+
- name: Restore build artifacts
155+
uses: actions/cache/restore@v4
156+
with:
157+
path: |
158+
common/dist
159+
sdk/qrcode/dist
160+
key: qrcode-sdk-build-${{ env.GH_SDK_CACHE_VERSION }}-${{ github.sha }}
161+
fail-on-cache-miss: true
162+
163+
- name: Verify build output
164+
run: |
165+
echo "Checking build output structure..."
166+
ls -la sdk/qrcode/dist/
167+
echo "Checking ESM build..."
168+
ls -la sdk/qrcode/dist/esm/
169+
echo "Checking CJS build..."
170+
ls -la sdk/qrcode/dist/cjs/
171+
echo "Checking type definitions..."
172+
if ! find sdk/qrcode/dist/esm -maxdepth 1 -name '*.d.ts' | grep -q .; then
173+
echo "No .d.ts files found in dist/esm"; exit 1;
174+
fi
175+
find sdk/qrcode/dist/esm -maxdepth 1 -name '*.d.ts' -ls
176+
177+
- name: Test package exports
178+
run: |
179+
echo "Testing package exports..."
180+
node -e "
181+
const pkg = require('./sdk/qrcode/package.json');
182+
console.log('Package exports:', JSON.stringify(pkg.exports, null, 2));
183+
"
184+
185+
- name: Verify bundle size
186+
run: yarn workspace @selfxyz/qrcode size-limit
187+
188+
- name: Log cache status
189+
run: |
190+
echo "Cache hit results:"
191+
echo "- Yarn cache hit: ${{ steps.yarn-cache.outputs.cache-hit }}"
192+
193+
# Integration test job
194+
integration-test:
195+
runs-on: ubuntu-latest
196+
needs: build
197+
steps:
198+
- uses: actions/checkout@v4
199+
200+
- name: Use Node.js ${{ env.NODE_VERSION }}
201+
uses: actions/setup-node@v4
202+
with:
203+
node-version: ${{ env.NODE_VERSION }}
204+
205+
- name: Enable Corepack
206+
run: corepack enable
207+
208+
- name: Cache Yarn dependencies
209+
id: yarn-cache
210+
uses: actions/cache@v4
211+
with:
212+
path: |
213+
.yarn/cache
214+
node_modules
215+
sdk/qrcode/node_modules
216+
common/node_modules
217+
key: ${{ runner.os }}-${{ env.GH_YARN_CACHE_VERSION }}-node${{ env.NODE_VERSION }}-yarn-${{ hashFiles('yarn.lock') }}
218+
restore-keys: |
219+
${{ runner.os }}-${{ env.GH_YARN_CACHE_VERSION }}-node${{ env.NODE_VERSION }}-yarn-
220+
221+
- name: Install Dependencies
222+
uses: ./.github/actions/yarn-install
223+
224+
- name: Restore build artifacts
225+
uses: actions/cache/restore@v4
226+
with:
227+
path: |
228+
common/dist
229+
sdk/qrcode/dist
230+
key: qrcode-sdk-build-${{ env.GH_SDK_CACHE_VERSION }}-${{ github.sha }}
231+
fail-on-cache-miss: true
232+
233+
- name: Run tests
234+
run: yarn workspace @selfxyz/qrcode test
235+
236+
- name: Test package import
237+
run: |
238+
echo "Testing package import..."
239+
node -e "
240+
try {
241+
const { SelfQRcode, SelfQRcodeWrapper, countries } = require('./sdk/qrcode/dist/cjs/index.cjs');
242+
console.log('✅ Package import successful');
243+
console.log('Exported components:', Object.keys({ SelfQRcode, SelfQRcodeWrapper, countries }));
244+
} catch (error) {
245+
console.error('❌ Package import failed:', error.message);
246+
process.exit(1);
247+
}
248+
"
249+
250+
- name: Log cache status
251+
run: |
252+
echo "Cache hit results:"
253+
echo "- Yarn cache hit: ${{ steps.yarn-cache.outputs.cache-hit }}"

app/scripts/bundle-analyze-ci.cjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ function formatBytes(bytes) {
2525
return Math.round((bytes / Math.pow(1024, i)) * 100) / 100 + ' ' + sizes[i];
2626
}
2727

28-
function checkBundleSize(bundleSize, platform) {
29-
const thresholdMB = BUNDLE_THRESHOLDS_MB[platform];
28+
function checkBundleSize(bundleSize, targetPlatform) {
29+
const thresholdMB = BUNDLE_THRESHOLDS_MB[targetPlatform];
3030
const thresholdBytes = thresholdMB * 1024 * 1024;
3131

3232
console.log(`\n📦 Bundle size: ${formatBytes(bundleSize)}`);

app/scripts/mobile-deploy-confirm.cjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ function displayPlatformVersions(platform, versions) {
353353
const currentBuild = versions.ios.build;
354354
const nextBuild = versions.versionJson
355355
? versions.versionJson.ios.build + 1
356-
: parseInt(currentBuild) + 1;
356+
: parseInt(currentBuild, 10) + 1;
357357
const lastDeployed = versions.versionJson
358358
? getTimeAgo(versions.versionJson.ios.lastDeployed)
359359
: 'Unknown';
@@ -371,7 +371,7 @@ function displayPlatformVersions(platform, versions) {
371371
const currentBuild = versions.android.versionCode;
372372
const nextBuild = versions.versionJson
373373
? versions.versionJson.android.build + 1
374-
: parseInt(currentBuild) + 1;
374+
: parseInt(currentBuild, 10) + 1;
375375
const lastDeployed = versions.versionJson
376376
? getTimeAgo(versions.versionJson.android.lastDeployed)
377377
: 'Unknown';
@@ -391,7 +391,7 @@ function displayPlatformVersions(platform, versions) {
391391
if (versions.versionJson) {
392392
if (platform === PLATFORMS.IOS || platform === PLATFORMS.BOTH) {
393393
const jsonBuild = versions.versionJson.ios.build;
394-
const actualBuild = parseInt(versions.ios.build);
394+
const actualBuild = parseInt(versions.ios.build, 10);
395395
if (jsonBuild !== actualBuild) {
396396
console.log(
397397
`\n${CONSOLE_SYMBOLS.WARNING} iOS build mismatch: version.json has ${jsonBuild}, but Xcode has ${actualBuild}`,
@@ -401,7 +401,7 @@ function displayPlatformVersions(platform, versions) {
401401

402402
if (platform === PLATFORMS.ANDROID || platform === PLATFORMS.BOTH) {
403403
const jsonBuild = versions.versionJson.android.build;
404-
const actualBuild = parseInt(versions.android.versionCode);
404+
const actualBuild = parseInt(versions.android.versionCode, 10);
405405
if (jsonBuild !== actualBuild) {
406406
console.log(
407407
`\n${CONSOLE_SYMBOLS.WARNING} Android build mismatch: version.json has ${jsonBuild}, but gradle has ${actualBuild}`,

app/scripts/tests/tree-shaking.test.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('Tree Shaking Infrastructure Tests', () => {
2424
assert(stats.isFile(), `${script} should be a file`);
2525

2626
// Check if file is executable (has execute permission)
27-
const isExecutable = (stats.mode & parseInt('111', 8)) !== 0;
27+
const isExecutable = (stats.mode & 0o111) !== 0;
2828
assert(isExecutable, `${script} should be executable`);
2929
});
3030
});

app/src/providers/authProvider.web.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,10 @@ export const AuthProvider = ({
191191
} else {
192192
return { success: false, error: 'No private key provided' };
193193
}
194-
} catch (error: unknown) {
194+
} catch (err: unknown) {
195195
return {
196196
success: false,
197-
error: error instanceof Error ? error.message : String(error),
197+
error: err instanceof Error ? err.message : String(err),
198198
};
199199
}
200200
})();

app/src/screens/prove/ProofRequestStatusScreen.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,11 @@ const SuccessScreen: React.FC = () => {
8686
if (isFocused && !countdownStarted && selfApp?.deeplinkCallback) {
8787
if (selfApp?.deeplinkCallback) {
8888
try {
89-
new URL(selfApp.deeplinkCallback);
90-
setCountdown(5);
91-
setCountdownStarted(true);
89+
const url = new URL(selfApp.deeplinkCallback);
90+
if (url) {
91+
setCountdown(5);
92+
setCountdownStarted(true);
93+
}
9294
} catch (error) {
9395
console.warn(
9496
'Invalid deep link URL provided:',

app/tests/src/providers/passportDataProvider.test.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,15 @@ describe('PassportDataProvider', () => {
180180
);
181181

182182
const updateCount = getByTestId('update-count');
183-
const initialCount = parseInt(updateCount.props.children);
183+
const initialCount = parseInt(updateCount.props.children, 10);
184184

185185
// Wait for updates to occur
186186
await waitFor(
187187
() => {
188-
const newCount = parseInt(getByTestId('update-count').props.children);
188+
const newCount = parseInt(
189+
getByTestId('update-count').props.children,
190+
10,
191+
);
189192
expect(newCount).toBeGreaterThan(initialCount);
190193
},
191194
{ timeout: 1000 },

common/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export {
3535
ID_CARD_ATTESTATION_ID,
3636
PASSPORT_ATTESTATION_ID,
3737
PCR0_MANAGER_ADDRESS,
38+
REDIRECT_URL,
3839
RPC_URL,
3940
TREE_URL,
4041
TREE_URL_STAGING,

0 commit comments

Comments
 (0)