Skip to content
This repository was archived by the owner on Feb 12, 2026. It is now read-only.

Commit f9e2e33

Browse files
committed
fix: add proper dependency chain for frontend builds
CRITICAL FIX: Frontends need Candid-generated TypeScript declarations Changes: - Added Job 2: Generate TypeScript declarations from .did files - Frontend builds now depend on declarations being available - Proper build order: Canisters → Declarations → Frontends → Docker Image - Updated documentation to reflect build pipeline Build order: 1. Build IC canisters (Rust → WASM + .did files) 2. Generate TypeScript declarations using didc 3. Build frontends with IC declarations available 4. Create Docker runtime image This fixes the missing dependency that would cause frontend builds to fail when importing from @/declarations/*
1 parent 61e3662 commit f9e2e33

2 files changed

Lines changed: 98 additions & 5 deletions

File tree

.github/workflows/build-artifacts.yml

Lines changed: 91 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,84 @@ jobs:
7777
retention-days: 7
7878

7979
# ============================================================================
80-
# Job 2: Build Frontend Artifacts in Parallel
80+
# Job 2: Generate TypeScript Bindings from Candid
81+
# ============================================================================
82+
generate-declarations:
83+
runs-on: ubuntu-latest
84+
needs: [build-canisters]
85+
86+
steps:
87+
- name: Checkout repository
88+
uses: actions/checkout@v4
89+
90+
- name: Download canister artifacts
91+
uses: actions/download-artifact@v4
92+
with:
93+
name: ic-canisters
94+
path: artifacts/canisters
95+
96+
- name: Install dfx
97+
run: |
98+
DFX_VERSION=0.29.1 sh -ci "$(curl -fsSL https://internetcomputer.org/install.sh)"
99+
100+
- name: Setup Node.js
101+
uses: actions/setup-node@v4
102+
with:
103+
node-version: '20'
104+
105+
- name: Install didc (Candid compiler)
106+
run: |
107+
cargo install didc
108+
109+
- name: Generate TypeScript declarations
110+
run: |
111+
echo "📝 Generating TypeScript bindings from Candid files..."
112+
113+
# Create declarations output directory
114+
mkdir -p src/declarations
115+
116+
# Generate declarations for each canister
117+
for canister in btc_vault_backend mock_unlock ethereum_vault_unlock bitcoin_price_threshold; do
118+
if [ -f "artifacts/canisters/${canister}.did" ]; then
119+
echo "Generating declarations for $canister..."
120+
mkdir -p "src/declarations/$canister"
121+
122+
# Generate TypeScript declarations using didc
123+
didc bind "artifacts/canisters/${canister}.did" -t ts > "src/declarations/$canister/index.d.ts"
124+
didc bind "artifacts/canisters/${canister}.did" -t js > "src/declarations/$canister/index.js"
125+
126+
# Copy the .did file
127+
cp "artifacts/canisters/${canister}.did" "src/declarations/$canister/"
128+
fi
129+
done
130+
131+
# Download external canister declarations (evm_rpc, xrc, ic_siwb_provider)
132+
mkdir -p src/declarations/evm_rpc
133+
mkdir -p src/declarations/xrc
134+
mkdir -p src/declarations/ic_siwb_provider
135+
136+
curl -fsSL https://github.com/internet-computer-protocol/evm-rpc-canister/releases/latest/download/evm_rpc.did -o src/declarations/evm_rpc/evm_rpc.did
137+
curl -fsSL https://raw.githubusercontent.com/dfinity/exchange-rate-canister/refs/heads/main/src/xrc/xrc.did -o src/declarations/xrc/xrc.did
138+
139+
# Generate TypeScript for external canisters
140+
didc bind src/declarations/evm_rpc/evm_rpc.did -t ts > src/declarations/evm_rpc/index.d.ts
141+
didc bind src/declarations/evm_rpc/evm_rpc.did -t js > src/declarations/evm_rpc/index.js
142+
didc bind src/declarations/xrc/xrc.did -t ts > src/declarations/xrc/index.d.ts
143+
didc bind src/declarations/xrc/xrc.did -t js > src/declarations/xrc/index.js
144+
145+
- name: Upload declarations
146+
uses: actions/upload-artifact@v4
147+
with:
148+
name: ic-declarations
149+
path: src/declarations/
150+
retention-days: 7
151+
152+
# ============================================================================
153+
# Job 3: Build Frontend Artifacts (depends on declarations)
81154
# ============================================================================
82155
build-frontends:
83156
runs-on: ubuntu-latest
157+
needs: [generate-declarations]
84158
strategy:
85159
matrix:
86160
frontend:
@@ -101,6 +175,20 @@ jobs:
101175
- name: Checkout repository
102176
uses: actions/checkout@v4
103177

178+
- name: Download IC declarations (if needed)
179+
if: matrix.frontend.needs_ic == true
180+
uses: actions/download-artifact@v4
181+
with:
182+
name: ic-declarations
183+
path: src/declarations
184+
185+
- name: Copy declarations to frontend (if needed)
186+
if: matrix.frontend.needs_ic == true
187+
run: |
188+
echo "📋 Copying IC declarations to ${{ matrix.frontend.dir }}/src/declarations"
189+
mkdir -p ${{ matrix.frontend.dir }}/src/declarations
190+
cp -r src/declarations/* ${{ matrix.frontend.dir }}/src/declarations/
191+
104192
- name: Setup Node.js
105193
uses: actions/setup-node@v4
106194
with:
@@ -141,11 +229,11 @@ jobs:
141229
retention-days: 7
142230

143231
# ============================================================================
144-
# Job 3: Build and Push Docker Image
232+
# Job 4: Build and Push Docker Image
145233
# ============================================================================
146234
build-image:
147235
runs-on: ubuntu-latest
148-
needs: [build-canisters, build-frontends]
236+
needs: [build-canisters, generate-declarations, build-frontends]
149237
permissions:
150238
contents: read
151239
packages: write

docs/CI_BUILT_IMAGES_MIGRATION.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,13 +327,18 @@ Breakdown:
327327
Total Deployment Time: 4 minutes
328328
329329
Breakdown:
330-
├── CI build (parallel - already done): 0 min*
330+
├── CI build (already done in background): 0 min*
331331
├── Pull pre-built image: 1 min
332332
├── Deploy Ethereum contracts: 1 min
333333
├── Deploy canisters: 1 min
334334
└── Start services: 1 min
335335
336-
*CI build runs in background (6 minutes total, but parallel)
336+
*CI build pipeline (runs automatically on push):
337+
Job 1: Build canisters (3 min)
338+
Job 2: Generate declarations (1 min) - depends on Job 1
339+
Job 3: Build frontends (2 min, parallel) - depends on Job 2
340+
Job 4: Create Docker image (1 min) - depends on Jobs 1-3
341+
Total CI time: ~7 minutes (but doesn't block deployment)
337342
```
338343

339344
**Improvement**: 78% faster deployment time!

0 commit comments

Comments
 (0)