diff --git a/.github/workflows/rust-compile.yml b/.github/workflows/rust-compile.yml index 94cb5db8a..00e4b7035 100644 --- a/.github/workflows/rust-compile.yml +++ b/.github/workflows/rust-compile.yml @@ -3,7 +3,7 @@ on: branches: [ $default-branch ] pull_request: -name: Continuous integration +name: Rust concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -14,6 +14,7 @@ env: RUST_BACKTRACE: 1 RUSTFLAGS: "-D warnings" CARGO_TERM_COLOR: always + DEFAULT_FEATURES: tokio,serde,reqwest,sparse jobs: check: @@ -23,12 +24,9 @@ jobs: - uses: actions/checkout@v3 with: submodules: recursive - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - - uses: actions-rs/cargo@v1 - with: - command: check + - uses: actions-rust-lang/setup-rust-toolchain@v1 + - name: Run clippy + run: cargo check check-rustdoc-links: name: Check intra-doc links @@ -37,65 +35,147 @@ jobs: - uses: actions/checkout@v3 with: submodules: recursive - - uses: actions-rs/toolchain@v1 - with: - profile: minimal + - 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 - test: - name: Test Suite - runs-on: ${{ matrix.os }} - needs: check - strategy: - fail-fast: false - matrix: - os: [ "ubuntu-latest", "windows-latest", "macOS-latest" ] + fmt: + name: Ensure 'cargo fmt' has been run + runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + - uses: actions-rust-lang/setup-rust-toolchain@v1 with: - submodules: recursive - # The tests require data that is stored in LFS - lfs: true - - uses: actions-rs/toolchain@v1 - with: - profile: minimal components: rustfmt + - name: Rustfmt Check + uses: actions-rust-lang/rustfmt@v1 - - uses: actions-rs/cargo@v1 - with: - command: test - args: --all-features -- --nocapture - - fmt: - name: Rustfmt + clippy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 with: submodules: recursive - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - - run: rustup component add rustfmt - - uses: actions-rs/cargo@v1 + - uses: actions-rust-lang/setup-rust-toolchain@v1 with: - command: fmt - args: --all -- --check + components: clippy + - name: Run clippy + run: cargo clippy - clippy: - runs-on: ubuntu-latest + build: + name: ${{ matrix.job.name }} + runs-on: ${{ matrix.job.os }} + needs: [ check ] + strategy: + fail-fast: false + matrix: + job: + - { name: "Linux-x86_64", target: x86_64-unknown-linux-musl, os: ubuntu-latest, use-cross: true } + # - { name: "Linux-aarch64", target: aarch64-unknown-linux-musl, os: ubuntu-latest, use-cross: true, 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 } + env: + BUILD_CMD: cargo # The build and test command to use if not overwritten steps: - - uses: actions/checkout@v3 + - name: Checkout source code + uses: actions/checkout@v3 with: submodules: recursive - - uses: actions-rs/toolchain@v1 + lfs: ${{ !matrix.job.skip-tests }} + + - name: Install prerequisites + shell: bash + run: | + case ${{ matrix.job.target }} in + arm-unknown-linux-*) sudo apt-get -y update ; sudo apt-get -y install gcc-arm-linux-gnueabihf ;; + aarch64-unknown-linux-gnu) sudo apt-get -y update ; sudo apt-get -y install gcc-aarch64-linux-gnu ;; + esac + + - name: Install Rust toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 with: - profile: minimal - components: clippy - - uses: actions-rs/clippy-check@v1 + target: ${{ matrix.job.target }} + components: rustfmt + + - name: Install cross + if: matrix.job.use-cross + uses: taiki-e/install-action@v2 with: - token: ${{ secrets.GITHUB_TOKEN }} - args: --all-features -- -D warnings + tool: cross + + - name: Overwrite build command env variable + if: matrix.job.use-cross + shell: bash + run: echo "BUILD_CMD=cross" >> $GITHUB_ENV + + - 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: Set build options + id: build-options + shell: bash + run: | + unset CARGO_BUILD_OPTIONS + case ${{ matrix.job.target }} in + *-musl*) CARGO_BUILD_OPTIONS="--no-default-features --features rustls-tls" ;; + *) CARGO_BUILD_OPTIONS="" ;; + esac + echo "CARGO_BUILD_OPTIONS=${CARGO_BUILD_OPTIONS}" >> $GITHUB_OUTPUT + + - name: Build + uses: actions-rs/cargo@v1 + with: + use-cross: ${{ matrix.job.use-cross }} + command: build + args: --target=${{ matrix.job.target }} ${{ steps.build-options.outputs.CARGO_BUILD_OPTIONS}} --features ${{ env.DEFAULT_FEATURES }} + + - name: Set test options + id: test-options + if: ${{ !matrix.job.skip-tests }} + shell: bash + run: | + unset CARGO_TEST_OPTIONS + case ${{ matrix.job.target }} in + *-musl*) CARGO_TEST_OPTIONS="--exclude tools" ;; + *) CARGO_TEST_OPTIONS="" ;; + esac + echo "CARGO_TEST_OPTIONS=${CARGO_TEST_OPTIONS}" >> $GITHUB_OUTPUT + + - name: Run tests + if: ${{ !matrix.job.skip-tests }} + uses: actions-rs/cargo@v1 + with: + use-cross: ${{ matrix.job.use-cross }} + command: test + args: --workspace --features ${{ env.DEFAULT_FEATURES }} --target=${{ matrix.job.target }} ${{ steps.build-options.outputs.CARGO_BUILD_OPTIONS}} ${{ steps.test-options.outputs.CARGO_TEST_OPTIONS}} -- --nocapture diff --git a/crates/rattler_solve/src/libsolv/wrapper/pool.rs b/crates/rattler_solve/src/libsolv/wrapper/pool.rs index 337d66578..62e733c45 100644 --- a/crates/rattler_solve/src/libsolv/wrapper/pool.rs +++ b/crates/rattler_solve/src/libsolv/wrapper/pool.rs @@ -2,6 +2,7 @@ use super::{ffi, repo::Repo, solvable::SolvableId, solver::Solver}; use crate::libsolv::c_string; use crate::libsolv::wrapper::ffi::Id; use rattler_conda_types::MatchSpec; +use std::ffi::c_char; use std::{ convert::TryInto, ffi::{CStr, CString}, @@ -66,7 +67,7 @@ extern "C" fn log_callback( _pool: *mut ffi::Pool, user_data: *mut c_void, flags: i32, - str: *const i8, + str: *const c_char, ) { unsafe { // We have previously stored a `BoxedLogCallback` in `user_data`, so now we can retrieve it