feat: initial contracts setup #47
Workflow file for this run
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: Build Project and Run Tests | |
| on: | |
| push: | |
| branches: ["main"] | |
| pull_request: | |
| types: [opened, synchronize, reopened, labeled, unlabeled] | |
| env: | |
| CARGO_TERM_COLOR: always | |
| PKG_CONFIG_PATH: /usr/lib/pkgconfig | |
| PUBLIC_STELLAR_NETWORK: local | |
| permissions: | |
| contents: read | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| # ---- Fast checks first ---- | |
| # Fail in seconds on lint / format before the multi-minute CLI build + | |
| # Docker network below, so trivial fixes don't pay the full cost. | |
| - run: npm ci | |
| - run: npm run lint | |
| - run: npm run format:check | |
| # ---- Slow path: CLI toolchain, local network, contract codegen ---- | |
| - uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 | |
| with: | |
| # NB: ~/.cargo/bin is deliberately NOT cached here. Keying the | |
| # stellar-scaffold binary on this repo's Cargo.lock would restore a | |
| # binary built from an unrelated CLI revision. | |
| path: | | |
| ~/.cargo/registry/index/ | |
| ~/.cargo/registry/cache/ | |
| ~/.cargo/git/db/ | |
| target/ | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| - run: | |
| sudo apt-get update && sudo apt-get install -y libudev-dev | |
| libdbus-1-dev pkg-config | |
| # binstall fetches a prebuilt stellar-scaffold-cli instead of compiling it | |
| - name: Install cargo-binstall | |
| uses: cargo-bins/cargo-binstall@e00d2c94cc0067b77737821097a62d91c0301baa # v1.21.1 | |
| - name: Install stellar-scaffold | |
| run: | | |
| if ! command -v stellar-scaffold &> /dev/null; then | |
| echo "stellar-scaffold not found, installing..." | |
| # --locked so the source-build fallback uses the CLI's published | |
| # Cargo.lock instead of resolving fresh soroban deps whose MSRV | |
| # may outrun the pinned toolchain. | |
| cargo binstall --locked stellar-scaffold-cli | |
| else | |
| echo "stellar-scaffold already installed. Clear cache to force reinstall." | |
| fi | |
| - name: Start Stellar local network | |
| # No tagged releases upstream, so this pins main as read on 2026-08-14 | |
| uses: stellar/quickstart@864f91d804c0061bd11ef8872d3e318581febb55 | |
| with: | |
| enable: "core,rpc" | |
| - name: Add master account as default identity | |
| run: | | |
| mkdir -p .config/stellar/identity | |
| echo 'secret_key = "SC5O7VZUXDJ6JBDSZ74DSERXL7W3Y5LTOAMRF7RQRL3TAGAPS7LUVG3L"' > .config/stellar/identity/me.toml | |
| - name: Build with Scaffold and build client packages | |
| run: | | |
| # Setting pipefail so a failed build's exit status isn't overwritten | |
| # by a successful call of `tee` | |
| set -o pipefail | |
| STELLAR_SCAFFOLD_ENV=development stellar-scaffold build \ | |
| --build-clients 2>&1 | tee build_clients.log | |
| - name: Check client generation summary | |
| run: | | |
| # Extract the number after "Failed: " | |
| FAILED=$(grep -Eo "Failed: [0-9]+" build_clients.log | awk '{print $2}') | |
| if [ -z "$FAILED" ]; then | |
| # Only reachable when the build exited 0, so a missing summary line | |
| # means nothing failed rather than that the generator died early. | |
| echo "Could not find 'Failed: N' in build_clients.log, all clients succeeded." | |
| exit 0 | |
| fi | |
| if [ "$FAILED" -gt 0 ]; then | |
| echo "Client generation summary check failed: Failed: $FAILED" | |
| echo "Check the \"Build with Scaffold\" step logs." | |
| exit 1 | |
| fi | |
| # Assert that client generation worked by checking the actual build | |
| # artifacts rather than relying on exit status, which could still be 0 | |
| # even if nothing was built. | |
| - name: Check generated clients | |
| run: | | |
| INDEX=app-lib/clients/index.ts | |
| if [ ! -s "$INDEX" ]; then | |
| echo "Expected $INDEX to exist and be non-empty after client generation." | |
| exit 1 | |
| fi | |
| # Count one exported const per contract | |
| EXPECTED=$(find contracts -mindepth 1 -maxdepth 1 -type d | wc -l | tr -d ' ') | |
| ACTUAL=$(grep -c "^export const " "$INDEX" || true) | |
| if [ "$ACTUAL" -ne "$EXPECTED" ]; then | |
| echo "Expected $EXPECTED client(s) in $INDEX, found $ACTUAL." | |
| echo "Partial client generation, check the \"Build with Scaffold\" step." | |
| grep "^export const " "$INDEX" || echo "(no exports)" | |
| exit 1 | |
| fi | |
| echo "Generated $ACTUAL client(s)." | |
| - run: npm run build --workspaces --if-present | |
| - name: Install Playwright browser | |
| run: npx playwright install --with-deps chromium | |
| working-directory: e2e | |
| - name: Run smoke tests | |
| run: npx playwright test | |
| working-directory: e2e |