ci #990
This file contains 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
# input for CI | |
# https://github.com/ClementTsang/bottom/blob/master/.github/workflows/ci.yml | |
# https://github.com/heim-rs/heim/blob/master/.github/workflows/ci.yml | |
# https://github.com/BurntSushi/ripgrep/blob/master/.github/workflows/ci.yml | |
name: ci | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
schedule: | |
- cron: '00 01 * * *' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.head_ref || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
rustfmt: | |
name: rustfmt | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@v1 | |
with: | |
toolchain: stable | |
components: rustfmt | |
- run: cargo fmt --all -- --check | |
typos: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: crate-ci/typos@master | |
# with: | |
# files: ./file.txt | |
clippy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@v1 | |
with: | |
toolchain: stable | |
components: clippy | |
- run: cargo clippy --all-targets --workspace -- -D warnings | |
build_and_test: | |
name: ${{ matrix.tuple.build }} | |
needs: [rustfmt, clippy, typos] | |
runs-on: ${{ matrix.tuple.os }} | |
env: | |
CARGO: cargo | |
strategy: | |
fail-fast: false | |
matrix: | |
tuple: | |
# see https://doc.rust-lang.org/nightly/rustc/platform-support.html for platform support / tiers | |
# see https://github.com/cross-rs/cross#supported-targets for supported targets in cross | |
- { build: 'linux-x86_64-pinned', os: 'ubuntu-22.04', target: 'x86_64-unknown-linux-gnu', cross: false, rust: 1.72.0 } | |
- { build: 'windows-x86_64-pinned', os: 'windows-2019', target: 'x86_64-pc-windows-msvc', cross: false, rust: 1.72.0 } | |
- { build: 'macos-x86_64-pinned', os: 'macos-latest', target: 'x86_64-apple-darwin', cross: false, rust: 1.72.0 } | |
- { build: 'linux-x86_64', os: 'ubuntu-latest', target: 'x86_64-unknown-linux-gnu', cross: false, rust: stable } | |
- { build: 'linux-i686', os: 'ubuntu-latest', target: 'i686-unknown-linux-gnu', cross: true, rust: stable } | |
- { build: 'linux-arm', os: 'ubuntu-latest', target: 'aarch64-unknown-linux-gnu', cross: true, rust: stable } # aarch64 | |
# - { build: 'ubuntu-armv7', os: 'ubuntu-latest', target: 'armv7-unknown-linux-gnueabihf', cross: true, rust: stable } # armv7 | |
# - { build: 'ubuntu-armv6', os: 'ubuntu-latest', target: 'arm-unknown-linux-gnueabihf', cross: true, rust: stable } # armv6 | |
- { build: 'macos-x86_64', os: 'macos-latest', target: 'x86_64-apple-darwin', cross: false, rust: stable } | |
# - { build: 'macos-arm', os: 'macos-latest', target: 'aarch64-apple-darwin', cross: true, rust: stable } # arm (tier 2, not in cross) | |
- { build: 'windows-x86_64-msvc', os: 'windows-latest', target: 'x86_64-pc-windows-msvc', cross: false, rust: stable } | |
- { build: 'windows-i686-msvc', os: 'windows-latest', target: 'i686-pc-windows-msvc', cross: false, rust: stable } | |
- { build: 'windows-x86_64-mingw', os: 'windows-latest', target: 'x86_64-pc-windows-gnu', cross: false, rust: stable } | |
# - { build: 'windows-i686-mingw', os: 'windows-latest', target: 'i686-pc-windows-gnu', cross: false, rust: stable } | |
steps: | |
- uses: actions/checkout@v4 | |
# Rustup update can fail on windows since it tries to replace its binary. This is not really | |
# needed anyhow. https://github.com/rust-lang/rustup/issues/3029 | |
- name: Disable rustup self-update | |
shell: bash | |
run: rustup set auto-self-update disable | |
- name: Install toolchain | |
uses: dtolnay/rust-toolchain@v1 | |
with: | |
# this specifies the rustup toolchain | |
toolchain: ${{ matrix.tuple.rust }} | |
target: ${{ matrix.tuple.target }} | |
- name: Install cross | |
if: matrix.tuple.cross != false | |
run: | | |
cargo install cross | |
echo "CARGO=cross" >> $GITHUB_ENV | |
- name: Check | |
run: | | |
echo "cargo command is: ${{ env.CARGO }}" | |
# this runs check for the target to use for (cross) compilation (must exist in rustup) | |
${{ env.CARGO }} check --verbose --target=${{ matrix.tuple.target }} | |
- name: Test | |
run: ${{ env.CARGO }} test --verbose --target=${{ matrix.tuple.target }} --no-fail-fast | |
docs: | |
name: Docs | |
runs-on: ubuntu-latest | |
needs: [build_and_test] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@v1 | |
with: | |
toolchain: stable | |
components: rustfmt | |
env: | |
RUSTDOCFLAGS: -D warnings | |
- run: cargo doc --no-deps --document-private-items --workspace |