This repository has been archived by the owner on Feb 15, 2024. It is now read-only.
add more time to the syncing progress subscription + fix clippy and fmt #916
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
name: Rust checks and tests | |
on: | |
push: | |
paths-ignore: | |
- '**.md' | |
- '.gitignore' | |
pull_request: | |
paths-ignore: | |
- '**.md' | |
- '.gitignore' | |
workflow_dispatch: | |
inputs: | |
test-macos-and-windows: | |
description: "run macOS and Windows tests" | |
required: true | |
default: false | |
type: boolean | |
concurrency: | |
group: push-${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
# Not needed in CI, should make things a bit faster | |
CARGO_INCREMENTAL: 0 | |
CARGO_TERM_COLOR: always | |
MAX_TARGET_SIZE: 1024 # MB | |
# TODO: AES flag is such that we have decent performance on ARMv8, remove once `aes` crate bumps MSRV to at least | |
# 1.61: https://github.com/RustCrypto/block-ciphers/issues/373 | |
RUSTFLAGS: -C strip=symbols -C opt-level=s --cfg aes_armv8 | |
jobs: | |
fmt: | |
runs-on: ${{ fromJson(github.repository_owner == 'subspace' && '["self-hosted", "ubuntu-20.04-x86-64"]' || 'ubuntu-22.04') }} | |
steps: | |
- name: git checkout | |
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 | |
- name: cargo fmt | |
uses: actions-rs/cargo@ae10961054e4aa8b4aa7dffede299aaf087aa33b # @v1.0.1 | |
with: | |
command: fmt | |
args: --all -- --check | |
clippy: | |
strategy: | |
fail-fast: false | |
matrix: | |
os: ${{ fromJson(github.repository_owner == 'subspace' && '[["self-hosted", "ubuntu-20.04-x86-64"], ["self-hosted", "macos-12-arm64"], ["self-hosted", "windows-server-2022-x86-64"]]' || '["ubuntu-20.04", "macos-12", "windows-2022"]') }} | |
run-all: | |
- ${{ inputs.test-macos-and-windows == true || github.ref == 'refs/heads/main' }} | |
exclude: # exclude macos-12 and windows-2022 when the condition is false | |
- run-all: false | |
os: macos-12 | |
- run-all: false | |
os: windows-2022 | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: git checkout | |
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 | |
# On macOS, we need a proper Clang version, not Apple's custom version without wasm32 support | |
- name: Install LLVM and Clang | |
uses: KyleMayes/install-llvm-action@8852e4d5c58653ed05135c0a5d949d9c2febcb00 # v1.6.1 | |
with: | |
version: "15.0" | |
- name: Install Protoc | |
uses: arduino/setup-protoc@9b1ee5b22b0a3f1feb8c2ff99b32c89b3c3191e9 # v2.0.0 | |
with: | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
# Workaround to resolve link error with C:\msys64\mingw64\bin\libclang.dll | |
- name: Remove msys64 | |
run: Remove-Item -LiteralPath "C:\msys64\" -Force -Recurse | |
if: runner.os == 'Windows' | |
continue-on-error: true | |
- name: Add cache | |
uses: actions/cache@69d9d449aced6a2ede0bc19182fadc3a0a42d2b0 # v3.2.6 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/bin | |
key: ${{ runner.os }}-${{ runner.arch }}-cargo-${{ hashFiles('**/Cargo.toml') }} | |
- name: Clean unused crate source checkouts and git repo checkouts | |
run: cargo cache | |
- uses: actions-rs/clippy-check@b5b5f21f4797c02da247df37026fcd0a5024aa4d # v1.0.7 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
args: --locked -- -D warnings | |
- name: Clean unused artifacts | |
run: cargo sweep --maxsize ${{ env.MAX_TARGET_SIZE }} | |
test: | |
strategy: | |
matrix: | |
os: ${{ fromJson(github.repository_owner == 'subspace' && '[["self-hosted", "ubuntu-20.04-x86-64"], ["self-hosted", "macos-12-arm64"], ["self-hosted", "windows-server-2022-x86-64"]]' || '["ubuntu-20.04", "macos-12", "windows-2022"]') }} | |
run-all: | |
- ${{ inputs.test-macos-and-windows || github.ref == 'refs/heads/master' }} | |
exclude: # exclude macos-12 and window-2022 when the condition is false | |
- run-all: false | |
os: macos-12 | |
- run-all: false | |
os: windows-2022 | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: git checkout | |
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 | |
# On macOS, we need a proper Clang version, not Apple's custom version without wasm32 support | |
- name: Install LLVM and Clang | |
uses: KyleMayes/install-llvm-action@8852e4d5c58653ed05135c0a5d949d9c2febcb00 # v1.6.1 | |
with: | |
version: "15.0" | |
if: runner.os == 'macOS' | |
- name: Install Protoc | |
uses: arduino/setup-protoc@9b1ee5b22b0a3f1feb8c2ff99b32c89b3c3191e9 # v2.0.0 | |
with: | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
# Workaround to resolve link error with C:\msys64\mingw64\bin\libclang.dll | |
- name: Remove msys64 | |
run: Remove-Item -LiteralPath "C:\msys64\" -Force -Recurse | |
if: runner.os == 'Windows' | |
continue-on-error: true | |
- name: Add cache | |
uses: actions/cache@69d9d449aced6a2ede0bc19182fadc3a0a42d2b0 # v3.2.6 | |
if: runner.os != 'Windows' | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/bin | |
~/.cargo/git | |
target | |
key: test-${{ runner.os }}-${{ hashFiles('rust-toolchain.toml') }}-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: test-${{ runner.os }}-${{ hashFiles('rust-toolchain.toml') }} | |
- name: Install utils for caching | |
if: runner.os != 'Windows' | |
run: | | |
test -x ~/.cargo/bin/cargo-sweep || cargo install cargo-sweep | |
test -x ~/.cargo/bin/cargo-cache || cargo install cargo-cache --no-default-features --features ci-autoclean cargo-cache | |
- name: Clean unused crate source checkouts and git repo checkouts | |
if: runner.os != 'Windows' | |
run: cargo cache | |
- name: Build and run tests | |
run: cargo test --locked --test integration --release --features=integration-test -- --test-threads=1 --nocapture | |
- name: Clean unused artifacts | |
if: runner.os != 'Windows' | |
run: cargo sweep --maxsize ${{ env.MAX_TARGET_SIZE }} | |
docs: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: git checkout | |
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 | |
- name: Install Protoc | |
uses: arduino/setup-protoc@9b1ee5b22b0a3f1feb8c2ff99b32c89b3c3191e9 # v2.0.0 | |
with: | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Configure cache | |
uses: Swatinem/rust-cache@359a70e43a0bb8a13953b04a90f76428b4959bb6 # v2.2.0 | |
- name: Check Documentation | |
run: cargo doc --locked --no-deps --lib | |
env: | |
RUSTDOCFLAGS: "-D rustdoc::broken-intra-doc-links -D rustdoc::private_intra_doc_links" |