Kp/init swift #58
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: Rust CI | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| env: | |
| CARGO_TERM_COLOR: always | |
| RUSTFLAGS: -D warnings | |
| RUST_BACKTRACE: 1 | |
| # Default placeholder values for Ditto environment variables | |
| # These will be overridden by repository secrets in the build-and-test job | |
| jobs: | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Rust | |
| uses: actions-rs/toolchain@v1 | |
| with: | |
| profile: minimal | |
| toolchain: 1.86 | |
| components: rustfmt, clippy | |
| override: true | |
| - name: Check formatting | |
| working-directory: ./rust | |
| run: cargo fmt --all -- --check | |
| - name: Lint | |
| working-directory: ./rust | |
| run: cargo clippy --profile ci --all-targets --all-features -- -D warnings | |
| build-and-test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Rust | |
| uses: actions-rs/toolchain@v1 | |
| with: | |
| profile: minimal | |
| toolchain: 1.86 | |
| components: rustfmt, clippy | |
| override: true | |
| - name: Cache cargo registry and target directory | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| rust/target | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('rust/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo- | |
| - name: Install cargo-nextest | |
| uses: taiki-e/install-action@nextest | |
| - name: Build and Test | |
| working-directory: ./rust | |
| env: | |
| # Ditto environment variables from secrets | |
| DITTO_APP_ID: ${{ secrets.DITTO_APP_ID }} | |
| DITTO_PLAYGROUND_TOKEN: ${{ secrets.DITTO_PLAYGROUND_TOKEN }} | |
| # Build profile settings | |
| CARGO_PROFILE_CI_LTO: "thin" | |
| CARGO_PROFILE_CI_CODEGEN_UNITS: "1" | |
| CARGO_PROFILE_CI_DEBUG: "false" | |
| CARGO_PROFILE_CI_OPT_LEVEL: "3" | |
| CARGO_PROFILE_CI_OVERFLOW_CHECKS: "true" | |
| run: | | |
| # Verify environment variables are set | |
| echo "DITTO_APP_ID: $DITTO_APP_ID" | |
| echo "DITTO_PLAYGROUND_TOKEN: ${DITTO_PLAYGROUND_TOKEN:0:4}..." | |
| # Build with the CI profile | |
| cargo build --profile ci | |
| # Run tests with nextest | |
| cargo nextest run --workspace --all-features --test-threads=1 | |
| - name: Run Benchmarks | |
| working-directory: ./rust | |
| run: cargo bench --profile ci || true |