From 7fa27044b6c775a55d9c85bdb75e9376d52414b5 Mon Sep 17 00:00:00 2001 From: Francis6-git Date: Mon, 1 Jun 2026 22:06:12 +0100 Subject: [PATCH] ci: optimize contract wasm compilation loop and target paths --- .github/workflows/ci.yml | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a9ffde80..31fef30e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,9 +4,9 @@ name: CI on: push: - branches: [ main, develop ] + branches: [main, develop] pull_request: - branches: [ main, develop ] + branches: [main, develop] jobs: frontend: @@ -19,14 +19,13 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: '20' - cache: 'npm' + node-version: "20" + cache: "npm" cache-dependency-path: package-lock.json - name: Install dependencies run: npm ci - - name: Lint run: npm run lint working-directory: frontend @@ -68,8 +67,8 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: '20' - cache: 'npm' + node-version: "20" + cache: "npm" cache-dependency-path: package-lock.json - name: Install dependencies @@ -128,7 +127,7 @@ jobs: - name: Rust Cache uses: Swatinem/rust-cache@v2 with: - workspaces: "contracts -> target" + workspace: "contracts -> target" - name: Check Formatting run: cargo fmt --all -- --check @@ -167,19 +166,28 @@ jobs: - name: Install Stellar CLI run: | curl -fsSL https://github.com/stellar/stellar-cli/raw/main/install.sh | sh -s -- --install-deps + echo "$HOME/.stellar-cli/bin" >> $GITHUB_PATH shell: bash - name: Optimize WASM files run: | set -euo pipefail - WASMS=$(find contracts/target -type f -name "*.wasm" -print) + + # Target the precise release build directory + RELEASE_DIR="contracts/target/wasm32-unknown-unknown/release" + + # Use your strict selection logic to target un-optimized raw binaries only + WASMS=$(find "$RELEASE_DIR" -maxdepth 1 -type f -name "*.wasm" ! -name "*.optimized.wasm") + if [ -z "$WASMS" ]; then - echo "No wasm files found" + echo "Error: No raw WASM files found in $RELEASE_DIR" exit 1 fi + for w in $WASMS; do - out="${w%%.wasm}.optimized.wasm" - echo "Optimizing $w -> $out" + filename=$(basename "$w") + out="$RELEASE_DIR/${filename%.wasm}.optimized.wasm" + echo "Optimizing $filename -> $(basename "$out")" stellar contract optimize --wasm "$w" --wasm-out "$out" done shell: bash @@ -188,5 +196,5 @@ jobs: uses: actions/upload-artifact@v4 with: name: optimized-wasm - path: | - contracts/target/**/**/*.optimized.wasm + path: contracts/target/wasm32-unknown-unknown/release/*.optimized.wasm + if-no-files-found: error