feat: add optional on_complete hook to canister endpoints
#1565
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: CI | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| schedule: | |
| - cron: "0 4 * * 0,3" # 4 a.m. UTC every Sun and Wed, keep actions-cache available | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| # All jobs use `actions-rust-lang/setup-rust-toolchain@v1`, which handles both | |
| # toolchain installation and Rust-specific caching (via Swatinem/rust-cache) | |
| # internally. No separate `actions/cache` step is needed. Caches are | |
| # automatically separated per job (the key includes the job name, OS, and a | |
| # hash of Cargo.lock). | |
| jobs: | |
| msrv: | |
| name: cargo build with MSRV | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-24.04, macos-15] | |
| fail-fast: false | |
| steps: | |
| - name: Install Rust toolchain | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| with: | |
| toolchain: 1.88.0 # MSRV, should sync with `rust-version` in `Cargo.toml` | |
| target: wasm32-unknown-unknown | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Run builds | |
| run: | | |
| cargo build --workspace --exclude ic-cdk-e2e-tests --target wasm32-unknown-unknown | |
| cargo build --workspace --exclude ic-cdk-e2e-tests --target wasm32-unknown-unknown --release | |
| cargo build --example=work | |
| test: | |
| name: cargo test | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-24.04, macos-15] | |
| fail-fast: false | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| # No explicit `toolchain` — uses the channel from rust-toolchain.toml. | |
| - name: Install Rust toolchain | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| - name: Download pocket-ic server | |
| run: bash scripts/download_pocket_ic_server.sh | |
| - name: Install protoc (macOS) | |
| if: runner.os == 'macOS' | |
| run: brew install protobuf | |
| - name: Install protoc (Ubuntu) | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y protobuf-compiler | |
| - name: Run tests | |
| run: | |
| | # https://github.com/rust-lang/cargo/issues/6669 we have to run ALL tests with two commands | |
| cargo test --all-targets --no-fail-fast | |
| cargo test --doc | |
| wasm64: | |
| name: wasm64 e2e | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-24.04, macos-15] | |
| fail-fast: false | |
| steps: | |
| - name: Install Rust toolchain | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| with: | |
| # Pinned to a known-good nightly. wasm64 is a tier-3 target built via | |
| # `-Zbuild-std`, so it's sensitive to nightly regressions. Only bump when | |
| # there's a specific reason (new feature needed, dep requires newer compiler). | |
| toolchain: nightly-2025-05-09 # 1.88.0 | |
| # Do NOT add `target: wasm64-unknown-unknown` here. wasm64 is a tier-3 | |
| # target with no pre-built `rust-std`, so `rustup target add` would fail. | |
| # Instead, `rust-src` is needed so that `-Zbuild-std` can compile `std` | |
| # from source for the wasm64 target. | |
| components: rust-src | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Download pocket-ic server | |
| run: bash scripts/download_pocket_ic_server.sh | |
| - name: Install protoc (macOS) | |
| if: runner.os == 'macOS' | |
| run: brew install protobuf | |
| - name: Install protoc (Ubuntu) | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y protobuf-compiler | |
| - name: Run tests | |
| run: WASM64=1 cargo test --package ic-cdk-e2e-tests --no-fail-fast | |
| fmt: | |
| name: cargo fmt | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| # No explicit `toolchain` — uses the channel from rust-toolchain.toml. | |
| - name: Install Rust toolchain | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| - name: Check formatting | |
| run: | | |
| cargo fmt --all -- --check | |
| clippy: | |
| name: cargo clippy | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| # No explicit `toolchain` — uses the channel from rust-toolchain.toml. | |
| - name: Install Rust toolchain | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| - name: Install cargo-hack | |
| uses: taiki-e/install-action@v2 | |
| with: | |
| tool: cargo-hack@0.6 | |
| - name: Install protoc (Ubuntu) | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y protobuf-compiler | |
| - name: Run clippy | |
| run: | | |
| cargo hack clippy --feature-powerset --no-dev-deps --keep-going -- -D warnings | |
| cargo clippy --tests --benches --keep-going -- -D warnings | |
| doc: | |
| name: cargo doc | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| # No explicit `toolchain` — uses the channel from rust-toolchain.toml. | |
| - name: Install Rust toolchain | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| - name: Install protoc (Ubuntu) | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y protobuf-compiler | |
| - name: Run doc | |
| run: | | |
| RUSTDOCFLAGS="-D warnings" cargo doc | |
| docsrs: | |
| name: docsrs | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Install nightly Rust toolchain | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| with: | |
| toolchain: nightly | |
| target: wasm32-unknown-unknown | |
| - name: Build docs (docs.rs simulation) | |
| run: | | |
| RUSTDOCFLAGS="--cfg docsrs -D warnings" cargo +nightly doc --no-deps --all-features --target wasm32-unknown-unknown \ | |
| -p ic-cdk \ | |
| -p ic-cdk-bitcoin-canister \ | |
| -p ic-cdk-executor \ | |
| -p ic-cdk-management-canister \ | |
| -p ic-cdk-timers | |
| aggregate: | |
| name: ci:required | |
| if: ${{ always() }} | |
| needs: [msrv, test, wasm64, fmt, clippy, doc, docsrs] | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: check msrv result | |
| if: ${{ needs.msrv.result != 'success' }} | |
| run: exit 1 | |
| - name: check test result | |
| if: ${{ needs.test.result != 'success' }} | |
| run: exit 1 | |
| - name: check wasm64 result | |
| if: ${{ needs.wasm64.result != 'success' }} | |
| run: exit 1 | |
| - name: check fmt result | |
| if: ${{ needs.fmt.result != 'success' }} | |
| run: exit 1 | |
| - name: check clippy result | |
| if: ${{ needs.clippy.result != 'success' }} | |
| run: exit 1 | |
| - name: check docsrs result | |
| if: ${{ needs.docsrs.result != 'success' }} | |
| run: exit 1 |