Skip to content

Commit d4c73e7

Browse files
committed
add setup-node-modules
1 parent ee20865 commit d4c73e7

2 files changed

Lines changed: 155 additions & 13 deletions

File tree

.github/workflows/push-eas-update.yml

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,22 @@ env:
4141
TARGET_CHANNEL: ${{ inputs.channel }}
4242

4343
jobs:
44+
setup-dependencies:
45+
name: Setup Dependencies
46+
needs:
47+
- validate-pr
48+
uses: ./.github/workflows/setup-node-modules.yml
49+
with:
50+
ref: ${{ inputs.commit_hash }}
51+
fetch-depth: 0
52+
upload-artifact: true
53+
artifact-name: node-modules-eas-update
54+
artifact-retention-days: 1
55+
4456
fingerprint-comparison:
4557
name: Compare Expo Fingerprints
58+
needs:
59+
- setup-dependencies
4660
runs-on: ubuntu-latest
4761
outputs:
4862
branch_fingerprint: ${{ steps.branch_fingerprint.outputs.fingerprint }}
@@ -67,24 +81,34 @@ jobs:
6781
with:
6882
node-version: '20'
6983

84+
- name: Download node_modules artifact (PR commit)
85+
uses: actions/download-artifact@v4
86+
with:
87+
name: node-modules-eas-update
88+
7089
- name: Install dependencies (workflow branch)
7190
run: |
7291
echo "📦 Installing dependencies for current branch..."
73-
yarn install --immutable
92+
yarn install --immutable --mode=skip-build
7493
75-
- name: Generate fingerprint (workflow branch)
94+
- name: Generate fingerprint (target commit)
7695
id: branch_fingerprint
7796
run: |
7897
echo "🧬 Generating fingerprint for current branch..."
7998
FINGERPRINT=$(yarn fingerprint:generate)
8099
echo "fingerprint=$FINGERPRINT" >> "$GITHUB_OUTPUT"
81100
echo "Target PR fingerprint: $FINGERPRINT"
82101
102+
- name: Download node_modules artifact (base branch)
103+
uses: actions/download-artifact@v4
104+
with:
105+
name: node-modules-eas-update
106+
83107
- name: Install dependencies (base branch)
84108
working-directory: main
85109
run: |
86110
echo "📦 Installing dependencies for base branch snapshot (${BASE_BRANCH_REF})..."
87-
yarn install --immutable
111+
yarn install --immutable --mode=skip-build
88112
89113
- name: Generate fingerprint (base branch)
90114
id: main_fingerprint
@@ -178,6 +202,7 @@ jobs:
178202
- fingerprint-comparison
179203
- approval
180204
- validate-pr
205+
- setup-dependencies
181206
if: >
182207
needs.fingerprint-comparison.outputs.fingerprints_equal == 'true' &&
183208
needs.approval.result == 'success'
@@ -240,6 +265,21 @@ jobs:
240265
with:
241266
node-version: '20'
242267

268+
- name: Download node_modules artifact
269+
uses: actions/download-artifact@v4
270+
with:
271+
name: node-modules-eas-update
272+
273+
- name: Verify downloaded artifacts
274+
run: |
275+
echo "✅ Verifying downloaded artifacts..."
276+
if [ ! -d "node_modules" ]; then
277+
echo "❌ node_modules directory not found"
278+
exit 1
279+
fi
280+
echo "📦 node_modules size: $(du -sh node_modules | cut -f1)"
281+
echo "✅ Artifacts verified"
282+
243283
- name: Determine signing secret name
244284
shell: bash
245285
env:
@@ -286,16 +326,6 @@ jobs:
286326
echo "✅ Set secret for key: $key"
287327
done
288328
289-
- name: Install dependencies
290-
run: |
291-
echo "📦 Installing dependencies..."
292-
yarn install --immutable
293-
294-
- name: Setup project
295-
run: |
296-
echo "🔧 Running setup for GitHub CI..."
297-
yarn setup:github-ci
298-
299329
- name: Display configuration
300330
run: |
301331
TARGET_RUNTIME_VERSION=$(node -p "require('./package.json').version")
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# Reusable workflow for setting up node_modules
2+
# This workflow installs dependencies and runs the project setup, then uploads
3+
# the prepared node_modules as an artifact for consumption by other workflows.
4+
5+
name: Setup Node Modules
6+
7+
on:
8+
workflow_call:
9+
inputs:
10+
ref:
11+
description: 'Git ref to checkout (e.g., refs/pull/123/head or branch name)'
12+
required: false
13+
type: string
14+
default: ''
15+
fetch-depth:
16+
description: 'Number of commits to fetch (0 for all history)'
17+
required: false
18+
type: number
19+
default: 1
20+
upload-artifact:
21+
description: 'Whether to upload node_modules as an artifact'
22+
required: false
23+
type: boolean
24+
default: true
25+
artifact-name:
26+
description: 'Name of the artifact to upload'
27+
required: false
28+
type: string
29+
default: 'node-modules'
30+
artifact-retention-days:
31+
description: 'Number of days to retain the artifact'
32+
required: false
33+
type: number
34+
default: 1
35+
outputs:
36+
cache-hit:
37+
description: 'Whether the node_modules cache was hit'
38+
value: ${{ jobs.setup.outputs.cache-hit }}
39+
cache-key:
40+
description: 'The cache key used for node_modules'
41+
value: ${{ jobs.setup.outputs.cache-key }}
42+
43+
permissions:
44+
contents: read
45+
46+
jobs:
47+
setup:
48+
name: Setup Node Modules
49+
runs-on: ubuntu-latest
50+
outputs:
51+
cache-hit: ${{ steps.cache-node-modules.outputs.cache-hit }}
52+
cache-key: ${{ steps.cache-key.outputs.key }}
53+
steps:
54+
- name: Checkout repository
55+
uses: actions/checkout@v4
56+
with:
57+
ref: ${{ inputs.ref }}
58+
fetch-depth: ${{ inputs.fetch-depth }}
59+
60+
- name: Setup Node.js
61+
uses: actions/setup-node@v4
62+
with:
63+
node-version: '20'
64+
65+
- name: Install dependencies
66+
run: |
67+
echo "📦 Installing dependencies..."
68+
yarn install --immutable
69+
70+
- name: Setup project
71+
run: |
72+
echo "🔧 Running setup for GitHub CI..."
73+
yarn setup:github-ci
74+
75+
- name: Verify setup completed
76+
run: |
77+
echo "✅ Verifying setup artifacts..."
78+
# Check that critical setup artifacts exist
79+
if [ ! -d "node_modules" ]; then
80+
echo "❌ node_modules directory not found"
81+
exit 1
82+
fi
83+
if [ ! -f "app/util/termsOfUse/termsOfUseContent.ts" ]; then
84+
echo "❌ Terms of Use content not generated"
85+
exit 1
86+
fi
87+
echo "🔍 Checking yarn setup..."
88+
echo " Node version: $(node --version)"
89+
echo " Yarn version: $(yarn --version)"
90+
echo " Corepack version: $(corepack --version)"
91+
echo "✅ Setup verification passed"
92+
93+
- name: Debug - List .yarn contents
94+
run: |
95+
echo "📂 Contents of .yarn directory:"
96+
ls -la .yarn/ || echo "No .yarn directory"
97+
echo "📊 .yarn size: $(du -sh .yarn 2>/dev/null || echo 'N/A')"
98+
echo "📄 install-state.gz exists: $(test -f .yarn/install-state.gz && echo 'yes' || echo 'no')"
99+
echo "📁 cache dir exists: $(test -d .yarn/cache && echo 'yes' || echo 'no')"
100+
101+
- name: Upload node_modules artifact
102+
if: inputs.upload-artifact
103+
uses: actions/upload-artifact@v4
104+
with:
105+
name: ${{ inputs.artifact-name }}
106+
path: |
107+
node_modules
108+
app/util/termsOfUse/termsOfUseContent.ts
109+
scripts/inpage-bridge/dist
110+
retention-days: ${{ inputs.artifact-retention-days }}
111+
compression-level: 1
112+
if-no-files-found: warn

0 commit comments

Comments
 (0)