Merge pull request #51 from 0xOlivanode/feature/testing-setup #61
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: Soroban CI | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - develop | |
| paths: | |
| - "soroban-client/**" | |
| - "soroban-contract/**" | |
| - ".github/workflows/**" | |
| pull_request: | |
| branches: | |
| - main | |
| - develop | |
| paths: | |
| - "soroban-client/**" | |
| - "soroban-contract/**" | |
| jobs: | |
| client: | |
| name: Next.js Client CI | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: soroban-client | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| - name: Cache node modules | |
| uses: actions/cache@v4 | |
| with: | |
| path: soroban-client/node_modules | |
| key: ${{ runner.os }}-node-${{ hashFiles('soroban-client/package-lock.json', 'soroban-client/yarn.lock', 'soroban-client/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-node- | |
| - name: Install dependencies | |
| run: | | |
| if [ -f package-lock.json ]; then | |
| npm ci | |
| elif [ -f yarn.lock ]; then | |
| yarn install --frozen-lockfile | |
| elif [ -f pnpm-lock.yaml ]; then | |
| npm install -g pnpm && pnpm install --frozen-lockfile | |
| else | |
| npm install | |
| fi | |
| - name: Run linter | |
| run: npm run lint --if-present | |
| continue-on-error: true | |
| - name: Build client | |
| run: npm run build | |
| env: | |
| CI: true | |
| # Add any required env vars for Next.js build | |
| # NEXT_PUBLIC_STELLAR_NETWORK: testnet | |
| - name: Run tests | |
| run: npm test -- --passWithNoTests | |
| if: hashFiles('soroban-client/package.json') != '' | |
| soroban: | |
| name: Soroban Contracts CI | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v4 | |
| - name: Cache Cargo registry | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cargo/registry | |
| key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo-registry- | |
| - name: Cache Cargo index | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cargo/git | |
| key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo-index- | |
| - name: Cache target directory | |
| uses: actions/cache@v4 | |
| with: | |
| path: soroban-contract/target | |
| key: ${{ runner.os }}-target-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-target- | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: wasm32-unknown-unknown | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libdbus-1-dev pkg-config libudev-dev | |
| - name: Install Soroban CLI | |
| run: | | |
| cargo install --locked soroban-cli --features opt || \ | |
| cargo install --locked soroban-cli | |
| - name: Check contract formatting | |
| working-directory: soroban-contract | |
| run: cargo fmt --all -- --check | |
| continue-on-error: true | |
| - name: Build contracts | |
| working-directory: soroban-contract | |
| run: | | |
| cargo build --release --target wasm32-unknown-unknown -p ticket_nft | |
| cargo build --release --target wasm32-unknown-unknown -p tba_account | |
| soroban contract build | |
| - name: Optimize contracts | |
| working-directory: soroban-contract | |
| run: soroban contract optimize --wasm target/wasm32-unknown-unknown/release/*.wasm | |
| continue-on-error: true | |
| - name: Run clippy | |
| working-directory: soroban-contract | |
| run: cargo clippy --all-targets -- -D warnings | |
| continue-on-error: true | |
| - name: Run contract tests | |
| working-directory: soroban-contract | |
| run: cargo test --workspace | |
| integration: | |
| name: Integration Tests | |
| runs-on: ubuntu-latest | |
| needs: [client, soroban] | |
| if: github.event_name == 'pull_request' | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: wasm32-unknown-unknown | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libdbus-1-dev pkg-config | |
| - name: Install Soroban CLI | |
| run: cargo install --locked soroban-cli | |
| - name: Install client dependencies | |
| working-directory: soroban-client | |
| run: npm ci 2>/dev/null || npm install | |
| - name: Build contracts | |
| working-directory: soroban-contract | |
| run: soroban contract build | |
| - name: Run integration tests | |
| working-directory: soroban-client | |
| run: npm run test:integration --if-present | |
| continue-on-error: true |