From 3b9c4a9d33c48f733ad373fad136f3ebf99acfe7 Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Sat, 20 Mar 2021 15:20:55 +0100 Subject: [PATCH] ci: Run target-agnostic build/test steps only once (#132) * ci: Run target-agnostic build/test steps only once A lot of these steps - except apk building - are not target-specific (do not have a `--target` option; `target:` on `actions-rs/toolchain` only specifies what targets to install). This is a waste of time despite all duplication running in parallel, and could be used to run a target-specific apk build in parallel with host-side tests instead. It should be fine to perform just the apk build step on Windows, and leave the rest (tests, documentation) to Linux runners only - most of those steps were not ran on Windows anyway. This takes CI time down from 6m30s to just under 5m, with around 3m spent in apk building (in parallel), 3m40s spent testing all cates and docs on the host, and under 5m for apk building on Windows (defining the baseline for total build completion time). * ci: Build-test docs separately This build takes about a minute and seems to recheck all crates anyway, and is hence better ran in parallel rather than synchronously with the tests. --- .github/workflows/rust.yml | 74 +++++++++++++++++++++++++++----------- 1 file changed, 54 insertions(+), 20 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 9cf66715..d234e0a9 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -34,6 +34,7 @@ jobs: rust-target: 'aarch64-linux-android' runs-on: ${{ matrix.os }} + name: Build apk steps: - uses: actions/checkout@v2 @@ -45,13 +46,40 @@ jobs: target: ${{ matrix.rust-target }} override: true - - if: runner.os != 'Windows' - name: Test ndk-sys + - name: Install cargo-apk + run: + cargo install --path cargo-apk + + - name: Cargo check for target ${{ matrix.rust-target }} + run: cargo check -p ndk --target ${{ matrix.rust-target }} --all-features + + - name: Cargo apk build for target ${{ matrix.rust-target }} + run: cargo apk build -p ndk-examples --target ${{ matrix.rust-target }} --examples + + build-host: + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + rust-channel: ['stable', 'nightly'] + + runs-on: ${{ matrix.os }} + name: Host-side tests + + steps: + - uses: actions/checkout@v2 + + - name: Installing Rust ${{ matrix.rust-channel }} + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.rust-channel }} + override: true + + - name: Test ndk-sys run: cargo test -p ndk-sys --all-features - - if: runner.os != 'Windows' - name: Test ndk + - name: Test ndk run: cargo test -p ndk --all-features @@ -59,13 +87,11 @@ jobs: run: cargo test -p ndk-build --all-features - - if: runner.os != 'Windows' - name: Test ndk-glue + - name: Test ndk-glue run: cargo test -p ndk-glue --all-features - - if: runner.os != 'Windows' - name: Test ndk-macro + - name: Test ndk-macro run: cargo test -p ndk-macro --all-features @@ -73,19 +99,27 @@ jobs: run: cargo test -p cargo-apk --all-features - - if: runner.os != 'Windows' - name: Document all crates + docs: + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + rust-channel: ['stable', 'nightly'] + + runs-on: ${{ matrix.os }} + name: Build-test docs + + steps: + - uses: actions/checkout@v2 + + - name: Installing Rust ${{ matrix.rust-channel }} + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.rust-channel }} + override: true + + - name: Document all crates env: RUSTDOCFLAGS: -Dwarnings run: cargo doc --all --all-features - - - name: Install cargo-apk - run: - cargo install --path cargo-apk - - - name: Cargo check for target ${{ matrix.rust-target }} - run: cargo check -p ndk --target ${{ matrix.rust-target }} --all-features - - - name: Cargo apk build for target ${{ matrix.rust-target }} - run: cargo apk build -p ndk-examples --target ${{ matrix.rust-target }} --examples