update ci and clean guest-examples (#96) #262
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 | |
| on: | |
| push: | |
| branches: | |
| - "master" | |
| - "feat/**" | |
| - "fix/**" | |
| tags: | |
| - "v*.*.*" # Semantic version tags | |
| pull_request: | |
| branches: ["master"] | |
| env: | |
| CARGO_TERM_COLOR: always | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| # Fast format check - fails early if formatting is wrong | |
| check-fmt: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Setup toolchain | |
| run: | | |
| rustup toolchain install 1.84.1 --profile minimal --component rustfmt | |
| rustup default 1.84.1 | |
| - uses: Swatinem/rust-cache@v2 | |
| - name: Check format | |
| run: cargo fmt --all -- --check | |
| check-wasm: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Setup toolchain | |
| run: | | |
| rustup toolchain install 1.84.1 --profile minimal --component clippy | |
| rustup default 1.84.1 | |
| - uses: Swatinem/rust-cache@v2 | |
| - name: Check wasm | |
| run: make check-wasm | |
| # Root workspace clippy linting | |
| clippy-root: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Setup toolchain | |
| run: | | |
| rustup toolchain install 1.84.1 --profile minimal --component clippy | |
| rustup default 1.84.1 | |
| - uses: Swatinem/rust-cache@v2 | |
| - name: Clippy root workspace | |
| run: make clippy-root | |
| # Guest examples clippy linting | |
| clippy-guests: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Setup toolchain | |
| run: | | |
| rustup toolchain install nightly-2025-06-09 --profile minimal --component clippy | |
| rustup default nightly-2025-06-09 | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| cache-bin: "false" | |
| - name: Install polkatool and pvq-program-metadata-gen | |
| run: | | |
| make polkatool | |
| make pvq-program-metadata-gen | |
| - name: Clippy guest examples | |
| run: make clippy-guests | |
| # Run tests | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Setup toolchain | |
| run: | | |
| rustup toolchain install 1.84.1 --profile minimal | |
| rustup default 1.84.1 | |
| - uses: Swatinem/rust-cache@v2 | |
| - name: Make dummy poc-guest files | |
| run: make dummy-guests | |
| - name: Run tests | |
| run: make test | |
| # Generate guest program list dynamically | |
| generate-guest-matrix: | |
| runs-on: ubuntu-latest | |
| # Run on main branches, release branches, or when explicitly requested | |
| if: | | |
| github.ref == 'refs/heads/master' || | |
| startsWith(github.ref, 'refs/heads/release/') || | |
| startsWith(github.ref, 'refs/tags/v') || | |
| contains(github.event.pull_request.labels.*.name, 'full-build') | |
| outputs: | |
| guest-matrix: ${{ steps.generate-matrix.outputs.guest-matrix }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Generate guest matrix | |
| id: generate-matrix | |
| run: | | |
| # Extract package names from Cargo.toml files | |
| guests=$(find guest-examples -name "Cargo.toml" -not -path "guest-examples/Cargo.toml" | xargs -I{} sh -c 'grep "^name" "{}" | cut -d"=" -f2 | tr -d " \""' | jq -R -s -c 'split("\n")[:-1]') | |
| echo "guest-matrix=$guests" >> $GITHUB_OUTPUT | |
| echo "Found guest programs: $guests" | |
| # Build guest programs in parallel using dynamic matrix | |
| build-guest: | |
| runs-on: ubuntu-latest | |
| needs: generate-guest-matrix | |
| strategy: | |
| matrix: | |
| guest: ${{ fromJson(needs.generate-guest-matrix.outputs.guest-matrix) }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Setup toolchain | |
| run: | | |
| rustup toolchain install nightly-2025-06-09 --profile minimal --component rust-src | |
| rustup default nightly-2025-06-09 | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| cache-bin: "false" | |
| prefix-key: "${{ matrix.guest }}" | |
| - name: Install polkatool and pvq-program-metadata-gen | |
| run: | | |
| make polkatool | |
| make pvq-program-metadata-gen | |
| - name: Build guest ${{ matrix.guest }} | |
| run: make guest-${{ matrix.guest }} | |
| - name: Upload guest artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: guest-${{ matrix.guest }} | |
| path: | | |
| output/guest-${{ matrix.guest }}.polkavm | |
| output/guest-${{ matrix.guest }}-metadata.bin | |
| output/guest-${{ matrix.guest }}-metadata.json | |
| if-no-files-found: warn | |
| retention-days: 1 | |
| # Collect all guest artifacts (optional - for when you need all guests together) | |
| collect-guests: | |
| runs-on: ubuntu-latest | |
| needs: [generate-guest-matrix, build-guest] | |
| if: github.event_name == 'push' || contains(github.event.pull_request.labels.*.name, 'full-build') | |
| steps: | |
| - name: Download all guest artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: guest-* | |
| path: output/ | |
| merge-multiple: true | |
| - name: Upload combined guests | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: all-guests | |
| path: output/ | |
| retention-days: 7 |