From 628e14f281787e2ba31d1552f0e504921ef7a848 Mon Sep 17 00:00:00 2001 From: figsoda Date: Fri, 14 Oct 2022 10:12:51 -0400 Subject: [PATCH] reactivate ci targets for arm linux and windows mingw --- .github/workflows/build-and-test.yml | 75 +++++++++++++++++++++------- Cross.toml | 2 + tests/utils.rs | 19 +++++-- 3 files changed, 75 insertions(+), 21 deletions(-) create mode 100644 Cross.toml diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 5315328..ef28d4e 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -6,55 +6,94 @@ jobs: build: name: build runs-on: ${{ matrix.os }} + env: + CARGO: cargo strategy: matrix: include: + - target: aarch64-unknown-linux-gnu + os: ubuntu-latest + no-zstd-thin: true + + - target: aarch64-unknown-linux-musl + os: ubuntu-latest + no-zstd-thin: true + + - target: armv7-unknown-linux-gnueabihf + os: ubuntu-latest + no-zstd-thin: true + + - target: armv7-unknown-linux-musleabihf + os: ubuntu-latest + no-zstd-thin: true + - target: x86_64-apple-darwin os: macos-latest - # - target: x86_64-pc-windows-gnu - # os: windows-latest - # ext: .exe + + - target: x86_64-pc-windows-gnu + os: windows-latest + no-zstd-thin: true + ext: .exe + - target: x86_64-pc-windows-msvc os: windows-latest ext: .exe + - target: x86_64-unknown-linux-gnu os: ubuntu-latest + - target: x86_64-unknown-linux-musl os: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - - name: Install dependencies (musl) - if: ${{ matrix.target == 'x86_64-unknown-linux-musl' }} + - name: Install cross (non-x86_64 linux) + if: "!contains(matrix.target, 'x86_64') && runner.os == 'Linux'" + run: | + pushd "$(mktemp -d)" + wget https://github.com/cross-rs/cross/releases/download/v0.2.4/cross-x86_64-unknown-linux-musl.tar.gz + tar xf cross-x86_64-unknown-linux-musl.tar.gz + cp cross ~/.cargo/bin + popd + echo CARGO=cross >> $GITHUB_ENV + + - name: Install dependencies (x86_64-unknown-linux-musl) + if: matrix.target == 'x86_64-unknown-linux-musl' run: | sudo apt-get update - sudo apt-get install help2man musl-tools + sudo apt-get install musl-tools - - name: Build and test on stable + - name: Set up extra cargo flags + if: matrix.no-zstd-thin run: | - rustup toolchain install stable --profile minimal -t ${{ matrix.target }} - cargo +stable build --target ${{ matrix.target }} - cargo +stable test --target ${{ matrix.target }} + echo "EXTRA_CARGO_FLAGS=--no-default-features --features flate2/zlib,zip/deflate-zlib" >> $GITHUB_ENV + + - name: Install Rust + run: | + rustup toolchain install stable nightly --profile minimal -t ${{ matrix.target }} + + - name: Test on stable + run: | + ${{ env.CARGO }} +stable test --target ${{ matrix.target }} $EXTRA_CARGO_FLAGS - name: Release on nightly run: | - rustup toolchain install nightly --profile minimal -t ${{ matrix.target }} - cargo +nightly build --release --target ${{ matrix.target }} + ${{ env.CARGO }} +nightly build --release --target ${{ matrix.target }} $EXTRA_CARGO_FLAGS env: OUCH_ARTIFACTS_FOLDER: artifacts RUSTFLAGS: -C strip=symbols - name: Upload bianry - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: ouch-${{ matrix.target }}${{ matrix.ext }} path: target/${{ matrix.target }}/release/ouch${{ matrix.ext }} - + - name: Upload artifacts (musl) - if: ${{ matrix.target == 'x86_64-unknown-linux-musl' }} - uses: actions/upload-artifact@v2 + if: matrix.target == 'x86_64-unknown-linux-musl' + uses: actions/upload-artifact@v3 with: name: artifacts path: artifacts @@ -64,7 +103,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: "Cargo: clippy, fmt" run: | diff --git a/Cross.toml b/Cross.toml new file mode 100644 index 0000000..1a4557b --- /dev/null +++ b/Cross.toml @@ -0,0 +1,2 @@ +[build.env] +passthrough = ["RUSTFLAGS"] diff --git a/tests/utils.rs b/tests/utils.rs index a365dde..a2b9231 100644 --- a/tests/utils.rs +++ b/tests/utils.rs @@ -1,18 +1,31 @@ -use std::{io::Write, path::PathBuf}; +use std::{env, io::Write, path::PathBuf}; +use assert_cmd::Command; use fs_err as fs; use rand::{Rng, RngCore}; #[macro_export] macro_rules! ouch { ($($e:expr),*) => { - ::assert_cmd::Command::cargo_bin("ouch") - .expect("Failed to find ouch executable") + $crate::utils::cargo_bin() $(.arg($e))* .unwrap(); } } +pub fn cargo_bin() -> Command { + env::vars() + .find_map(|(k, v)| { + (k.starts_with("CARGO_TARGET_") && k.ends_with("_RUNNER")).then(|| { + let mut runner = v.split_whitespace(); + let mut cmd = Command::new(runner.next().unwrap()); + cmd.args(runner).arg(assert_cmd::cargo::cargo_bin("ouch")); + cmd + }) + }) + .unwrap_or_else(|| Command::cargo_bin("ouch").expect("Failed to find ouch executable")) +} + // write random content to a file pub fn write_random_content(file: &mut impl Write, rng: &mut impl RngCore) { let mut data = Vec::new();