fix: frontend ci test fixe #351
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| branches: [ main, develop ] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| rust-tests: | |
| name: Rust Tests & Quality | |
| runs-on: ubuntu-latest | |
| env: | |
| STELLAR_CLI_VERSION: 23.4.0 | |
| defaults: | |
| run: | |
| working-directory: ./smart-contract | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| # Pinned to 1.96.0: Rust 1.97 changed the size of core::num::TryFromIntError, | |
| # which breaks the (unmaintained, transitive) ethnum 1.5.2 crate with E0512 | |
| # ("cannot transmute between types of different sizes"). No fixed ethnum | |
| # release exists yet, so pin below 1.97 until soroban's dep tree drops it. | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@1.96.0 | |
| with: | |
| components: rustfmt, clippy | |
| targets: wasm32-unknown-unknown, wasm32v1-none | |
| - name: Ensure wasm32v1-none target is available | |
| run: rustup target add wasm32v1-none | |
| # Use the official Stellar CLI GitHub Action (v23.4.0) | |
| # Replaces the old manual soroban-cli curl install | |
| - name: Install Stellar CLI | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| mkdir -p "$HOME/.local/bin" | |
| arch="$(uname -m)" | |
| case "$arch" in | |
| x86_64) asset_arch="x86_64" ;; | |
| aarch64|arm64) asset_arch="aarch64" ;; | |
| *) echo "Unsupported architecture: $arch"; exit 1 ;; | |
| esac | |
| version="${STELLAR_CLI_VERSION}" | |
| base_url="https://github.com/stellar/stellar-cli/releases/download/v${version}" | |
| urls=( | |
| "${base_url}/stellar-cli-${version}-${asset_arch}-unknown-linux-gnu.tar.gz" | |
| "${base_url}/stellar-cli-${version}-${asset_arch}-unknown-linux-musl.tar.gz" | |
| ) | |
| success="false" | |
| for url in "${urls[@]}"; do | |
| echo "Attempting download: ${url}" | |
| if curl -fL --retry 6 --retry-all-errors --retry-delay 5 -o stellar-cli.tar.gz "${url}"; then | |
| success="true" | |
| break | |
| fi | |
| done | |
| if [ "$success" != "true" ]; then | |
| echo "Failed to download stellar-cli v${version} from GitHub releases." | |
| exit 1 | |
| fi | |
| tmpdir="$(mktemp -d)" | |
| tar -xzf stellar-cli.tar.gz -C "$tmpdir" | |
| stellar_path="$(find "$tmpdir" -type f -name stellar | head -n 1)" | |
| if [ -z "$stellar_path" ]; then | |
| echo "Could not find 'stellar' binary in downloaded archive." | |
| exit 1 | |
| fi | |
| mv "$stellar_path" "$HOME/.local/bin/stellar" | |
| chmod +x "$HOME/.local/bin/stellar" | |
| echo "$HOME/.local/bin" >> "$GITHUB_PATH" | |
| stellar --version | |
| - name: Cache Cargo registry | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo-registry- | |
| - name: Cache Cargo build | |
| uses: actions/cache@v4 | |
| with: | |
| # Fixed: scoped to actual target dir relative to repo root, | |
| # not the working-directory (which would resolve incorrectly) | |
| path: smart-contract/target | |
| key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo-build- | |
| - name: Check formatting | |
| run: cargo fmt --all -- --check | |
| - name: Run clippy | |
| run: cargo clippy --all-targets --all-features -- -D warnings | |
| - name: Run tests | |
| run: cargo test --release --all-features | |
| # Use stellar contract build instead of raw cargo build --target wasm32 | |
| # This ensures proper metadata, optimizer flags, and correct wasm output paths | |
| - name: Build WASM contracts | |
| run: stellar contract build | |
| - name: Upload WASM artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wasm-artifacts | |
| path: smart-contract/target/wasm32-unknown-unknown/release/*.wasm | |
| retention-days: 7 | |
| frontend-tests: | |
| name: Frontend Tests & Quality | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: ./frontend | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| cache-dependency-path: frontend/package-lock.json | |
| - name: Install dependencies | |
| run: | | |
| npm ci | |
| npm install @rollup/rollup-linux-x64-gnu --save-optional | |
| npm install lightningcss-linux-x64-gnu --save-optional | |
| - name: Run npm audit | |
| run: npm audit --audit-level=critical || true | |
| # Fixed: was running `npm run build` here (type check) AND again below (build verification) | |
| # Use tsc --noEmit for type checking, keep the real build separate | |
| - name: Type checking | |
| run: npx tsc --noEmit | |
| - name: Lint code | |
| run: npm run lint --if-present | |
| - name: Run tests | |
| run: npm test --if-present | |
| - name: Build | |
| run: npm run build | |
| - name: Upload frontend artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: frontend-artifacts | |
| # Fixed: artifacts are uploaded from the job that produces them, | |
| # not from a downstream job that can't access other jobs' filesystems | |
| path: frontend/.next/ | |
| retention-days: 7 | |
| frontend-e2e: | |
| name: Frontend E2E (Playwright) | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: ./frontend | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| cache-dependency-path: frontend/package-lock.json | |
| - name: Install dependencies | |
| run: | | |
| npm ci | |
| npm install @rollup/rollup-linux-x64-gnu --save-optional | |
| npm install lightningcss-linux-x64-gnu --save-optional | |
| - name: Install Playwright browsers | |
| run: npx playwright install --with-deps | |
| - name: Run Playwright tests | |
| run: npm run e2e | |
| - name: Upload Playwright report | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: playwright-report | |
| path: frontend/playwright-report/ | |
| retention-days: 7 | |
| - name: Upload Playwright test results | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: playwright-test-results | |
| path: frontend/test-results/ | |
| retention-days: 7 | |
| build-verification: | |
| name: Build Verification | |
| runs-on: ubuntu-latest | |
| needs: [ rust-tests, frontend-tests, frontend-e2e ] | |
| steps: | |
| - name: All builds passed | |
| run: echo "All upstream jobs completed successfully" |