name: Build
on:
push:
pull_request:
schedule:
- cron: "0 0 * * 6"
jobs:
check-other-targets:
name: Type checking
runs-on: ubuntu-latest
strategy:
matrix:
rust: [1.32.0, 1.36.0, stable]
target:
- { triple: x86_64-unknown-netbsd, std: true }
- { triple: wasm32-wasi, std: true }
- { triple: thumbv7em-none-eabihf, std: false }
exclude:
- rust: 1.32.0
target: { triple: thumbv7em-none-eabihf, std: false }
- rust: 1.32.0
target: { triple: wasm32-wasi, std: true }
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Cache installed binaries
uses: actions/cache@v2
id: cache-binaries
with:
path: ~/.cargo/bin
key: ${{ runner.os }}-cargo-hack
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target.triple }}
override: true
- name: Install cargo-hack
run: cargo +stable install cargo-hack
if: steps.cache-binaries.outputs.cache-hit != 'true'
- name: Cache cargo output
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ matrix.rust }}-${{ matrix.target.triple }}-${{ hashFiles('**/Cargo.toml') }}
- name: Check feature powerset
uses: actions-rs/cargo@v1
with:
command: hack
args: check --no-dev-deps --feature-powerset --optional-deps --skip default,libc,winapi,stdweb,std --target ${{ matrix.target.triple }}
if: matrix.target.std == false
- name: Check feature powerset
uses: actions-rs/cargo@v1
with:
command: hack
args: check --no-dev-deps --feature-powerset --optional-deps --skip default,libc,winapi,stdweb,std --features std --target ${{ matrix.target.triple }}
if: matrix.rust == '1.32.0' && matrix.target.std == true
- name: Check feature powerset
uses: actions-rs/cargo@v1
with:
command: hack
args: check --no-dev-deps --feature-powerset --optional-deps --skip default,libc,winapi,stdweb --target ${{ matrix.target.triple }}
if: matrix.rust != '1.32.0' && matrix.target.std == true
check-web:
name: Type checking (web)
runs-on: ubuntu-latest
strategy:
matrix:
rust: [1.36.0, stable]
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Cache installed binaries
uses: actions/cache@v2
id: cache
with:
path: ~/.cargo/bin
key: ${{ runner.os }}-cargo-web
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
target: wasm32-unknown-unknown
override: true
- name: Install cargo-web
run: cargo +stable install cargo-web
if: steps.cache.outputs.cache-hit != 'true'
- name: Cache cargo output
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ matrix.rust }}-wasm32-unknown-unknown-${{ hashFiles('**/Cargo.toml') }}
- name: "Check #![no_std] compatibility"
uses: actions-rs/cargo@v1
with:
command: web
args: check --no-default-features
- name: "Check #![no_std] compatibility with serde, rand"
uses: actions-rs/cargo@v1
with:
command: web
args: check --no-default-features --features serde,rand
- name: Check all-features
uses: actions-rs/cargo@v1
with:
command: web
args: check --all-features
test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
rust: [1.32.0, 1.36.0, stable] os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Cache installed binaries
uses: actions/cache@v2
id: cache-binaries
with:
path: ~/.cargo/bin
key: ${{ runner.os }}-cargo-hack
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
- name: Install cargo-hack
run: cargo +stable install cargo-hack
if: steps.cache-binaries.outputs.cache-hit != 'true'
- name: Install GNU tar
run: |
brew install gnu-tar
echo "::add-path::/usr/local/opt/gnu-tar/libexec/gnubin"
if: matrix.os == 'macOS-latest'
- name: Cache cargo output
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ matrix.rust }}-${{ matrix.os }}-${{ hashFiles('**/Cargo.toml') }}2
- name: Test feature powerset (--lib)
uses: actions-rs/cargo@v1
with:
command: hack
args: test --feature-powerset --optional-deps --skip default,libc,winapi,stdweb,std --features std --lib
if: matrix.rust == '1.32.0'
- name: Test feature powerset (--lib)
uses: actions-rs/cargo@v1
with:
command: hack
args: test --feature-powerset --optional-deps --skip default,libc,winapi,stdweb --lib
if: matrix.rust != '1.32.0'
- name: Test documentation
uses: actions-rs/cargo@v1
with:
command: test
args: --all-features --doc
fmt:
name: Formatting
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
components: rustfmt
- name: Run `cargo fmt -- --check`
uses: actions-rs/cargo@v1
with:
command: fmt
args: -- --check
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Cache cargo output
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ubuntu-latest-cargo-stable-ubuntu-latest-${{ hashFiles('**/Cargo.toml') }}
- name: Run clippy
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features
documentation:
name: Documentation
runs-on: ubuntu-latest
needs:
- check-other-targets
- check-web
- test
- fmt
- clippy
steps:
- name: Checkout
uses: actions/checkout@v2
with:
persist-credentials: false
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
- name: Build documentation
uses: actions-rs/cargo@v1
with:
command: doc
args: --all-features
env:
RUSTFLAGS: --cfg __time_02_docs
RUSTDOCFLAGS: --cfg __time_02_docs
- name: Publish documentation
uses: JamesIves/github-pages-deploy-action@releases/v3
with:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
BRANCH: gh-pages
FOLDER: target/doc
SINGLE_COMMIT: true
if: github.event_name == 'push' && github.ref == format('refs/heads/{0}', github.event.repository.master_branch)