fix: simplify ci #852
Workflow file for this run
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
on: | ||
push: | ||
branches: [ $default-branch ] | ||
pull_request: | ||
name: Rust | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
env: | ||
RUST_LOG: info | ||
RUST_BACKTRACE: 1 | ||
RUSTFLAGS: "-D warnings" | ||
CARGO_TERM_COLOR: always | ||
DEFAULT_FEATURES: tokio,serde,reqwest,sparse,sysinfo,libsolv_rs | ||
jobs: | ||
check-rustdoc-links: | ||
name: Check intra-doc links | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
submodules: recursive | ||
- uses: actions-rust-lang/setup-rust-toolchain@v1 | ||
- run: | | ||
for package in $(cargo metadata --no-deps --format-version=1 | jq -r '.packages[] | .name'); do | ||
cargo rustdoc -p "$package" --all-features -- -D warnings -W unreachable-pub | ||
done | ||
clippy: | ||
name: Style | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
submodules: recursive | ||
- uses: actions-rust-lang/setup-rust-toolchain@v1 | ||
with: | ||
components: clippy, rustfmt | ||
- name: Run rustfmt | ||
uses: actions-rust-lang/rustfmt@v1 | ||
- name: Run clippy | ||
run: cargo clippy | ||
build: | ||
name: ${{ matrix.job.name }} | ||
runs-on: ${{ matrix.job.os }} | ||
needs: [ check ] | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
include: | ||
# - { name: "Linux-x86_64", target: x86_64-unknown-linux-musl, os: ubuntu-latest } | ||
- { name: "Linux-aarch64", target: aarch64-unknown-linux-musl, os: ubuntu-latest, skip-tests: true } | ||
# - { name: "Linux-arm", target: arm-unknown-linux-musleabi, os: ubuntu-latest, use-cross: true } | ||
# - { name: "Linux-mips", target: mips-unknown-linux-musl, os: ubuntu-latest, use-cross: true, skip-tests: true } | ||
# - { name: "Linux-mipsel", target: mipsel-unknown-linux-musl, os: ubuntu-latest, use-cross: true, skip-tests: true } | ||
# - { name: "Linux-mips64", target: mips64-unknown-linux-muslabi64, os: ubuntu-latest, use-cross: true, skip-tests: true } | ||
# - { name: "Linux-mips64el", target: mips64el-unknown-linux-muslabi64, os: ubuntu-latest, use-cross: true, skip-tests: true } | ||
# - { name: "Linux-powerpc", target: powerpc-unknown-linux-gnu, os: ubuntu-latest, use-cross: true, skip-tests: true } | ||
# - { name: "Linux-powerpc64", target: powerpc64-unknown-linux-gnu, os: ubuntu-latest, use-cross: true, skip-tests: true } | ||
# - { name: "Linux-powerpc64le", target: powerpc-unknown-linux-gnu, os: ubuntu-latest, use-cross: true, skip-tests: true } | ||
# - { name: "Linux-s390x", target: s390x-unknown-linux-gnu, os: ubuntu-latest, use-cross: true, skip-tests: true } | ||
# - { name: "macOS-x86_64", target: x86_64-apple-darwin, os: macOS-latest } | ||
# - { name: "macOS-aarch64", target: aarch64-apple-darwin, os: macOS-latest, skip-tests: true } | ||
# - { name: "Windows-x86_64", target: x86_64-pc-windows-msvc, os: windows-latest } | ||
# - { name: "Windows-aarch64", target: aarch64-pc-windows-msvc, os: windows-latest, skip-tests: true } | ||
steps: | ||
- name: Checkout source code | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: recursive | ||
lfs: ${{ !matrix.skip-tests }} | ||
- name: Install Rust toolchain | ||
uses: actions-rust-lang/setup-rust-toolchain@v1 | ||
with: | ||
target: ${{ matrix.target }} | ||
components: rustfmt | ||
cache: false | ||
- uses: taiki-e/setup-cross-toolchain-action@v1 | ||
with: | ||
target: ${{ matrix.target }} | ||
if: contains(matrix.target, '-musl') | ||
- uses: Swatinem/rust-cache@v2 | ||
# - name: Add macOS cross build capability | ||
# if: matrix.job.target == 'aarch64-apple-darwin' | ||
# shell: bash | ||
# run: | | ||
# echo "SDKROOT=$(xcrun -sdk macosx --show-sdk-path)" >> $GITHUB_ENV | ||
# echo "MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx --show-sdk-platform-version)" >> $GITHUB_ENV | ||
- name: Show version information (Rust, cargo, GCC) | ||
shell: bash | ||
run: | | ||
gcc --version || true | ||
rustup -V | ||
rustup toolchain list | ||
cargo -V | ||
rustc -V | ||
- name: Use rusttls on musl targets. | ||
id: build-options | ||
run: echo "CARGO_BUILD_OPTIONS=${CARGO_BUILD_OPTIONS} --no-default-features --features rusttls-tls" >> $GITHUB_OUTPUT | ||
if: contains(matrix.target, '-musl') | ||
- name: Build | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: build | ||
args: --all-targets ${{ steps.build-options.outputs.CARGO_BUILD_OPTIONS}} --features ${{ env.DEFAULT_FEATURES }} | ||
- name: Set test options | ||
id: test-options | ||
if: ${{ !matrix.skip-tests }} | ||
run: echo "CARGO_TEST_OPTIONS=${CARGO_TEST_OPTIONS} --exclude tools" >> $GITHUB_OUTPUT | ||
- name: Run tests | ||
if: ${{ !matrix.skip-tests }} | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
use-cross: ${{ matrix.use-cross }} | ||
command: test | ||
args: --workspace --features ${{ env.DEFAULT_FEATURES }} ${{ steps.build-options.outputs.CARGO_BUILD_OPTIONS}} ${{ steps.test-options.outputs.CARGO_TEST_OPTIONS}} -- --nocapture |