Skip to content

Commit

Permalink
ci: Run target-agnostic build/test steps only once (#132)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
MarijnS95 authored Mar 20, 2021
1 parent 006b740 commit 3b9c4a9
Showing 1 changed file with 54 additions and 20 deletions.
74 changes: 54 additions & 20 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
rust-target: 'aarch64-linux-android'

runs-on: ${{ matrix.os }}
name: Build apk

steps:
- uses: actions/checkout@v2
Expand All @@ -45,47 +46,80 @@ 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

- name: Test ndk-build
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

- name: Test cargo-apk
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

0 comments on commit 3b9c4a9

Please sign in to comment.