reactivate ci targets for arm linux and windows mingw

This commit is contained in:
figsoda 2022-10-14 10:12:51 -04:00
parent bda6c27062
commit 628e14f281
3 changed files with 75 additions and 21 deletions

View File

@ -6,55 +6,94 @@ jobs:
build: build:
name: build name: build
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
env:
CARGO: cargo
strategy: strategy:
matrix: matrix:
include: 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 - target: x86_64-apple-darwin
os: macos-latest os: macos-latest
# - target: x86_64-pc-windows-gnu
# os: windows-latest - target: x86_64-pc-windows-gnu
# ext: .exe os: windows-latest
no-zstd-thin: true
ext: .exe
- target: x86_64-pc-windows-msvc - target: x86_64-pc-windows-msvc
os: windows-latest os: windows-latest
ext: .exe ext: .exe
- target: x86_64-unknown-linux-gnu - target: x86_64-unknown-linux-gnu
os: ubuntu-latest os: ubuntu-latest
- target: x86_64-unknown-linux-musl - target: x86_64-unknown-linux-musl
os: ubuntu-latest os: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Install dependencies (musl) - name: Install cross (non-x86_64 linux)
if: ${{ matrix.target == 'x86_64-unknown-linux-musl' }} 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: | run: |
sudo apt-get update 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: | run: |
rustup toolchain install stable --profile minimal -t ${{ matrix.target }} echo "EXTRA_CARGO_FLAGS=--no-default-features --features flate2/zlib,zip/deflate-zlib" >> $GITHUB_ENV
cargo +stable build --target ${{ matrix.target }}
cargo +stable test --target ${{ matrix.target }} - 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 - name: Release on nightly
run: | run: |
rustup toolchain install nightly --profile minimal -t ${{ matrix.target }} ${{ env.CARGO }} +nightly build --release --target ${{ matrix.target }} $EXTRA_CARGO_FLAGS
cargo +nightly build --release --target ${{ matrix.target }}
env: env:
OUCH_ARTIFACTS_FOLDER: artifacts OUCH_ARTIFACTS_FOLDER: artifacts
RUSTFLAGS: -C strip=symbols RUSTFLAGS: -C strip=symbols
- name: Upload bianry - name: Upload bianry
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v3
with: with:
name: ouch-${{ matrix.target }}${{ matrix.ext }} name: ouch-${{ matrix.target }}${{ matrix.ext }}
path: target/${{ matrix.target }}/release/ouch${{ matrix.ext }} path: target/${{ matrix.target }}/release/ouch${{ matrix.ext }}
- name: Upload artifacts (musl) - name: Upload artifacts (musl)
if: ${{ matrix.target == 'x86_64-unknown-linux-musl' }} if: matrix.target == 'x86_64-unknown-linux-musl'
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v3
with: with:
name: artifacts name: artifacts
path: artifacts path: artifacts
@ -64,7 +103,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: "Cargo: clippy, fmt" - name: "Cargo: clippy, fmt"
run: | run: |

2
Cross.toml Normal file
View File

@ -0,0 +1,2 @@
[build.env]
passthrough = ["RUSTFLAGS"]

View File

@ -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 fs_err as fs;
use rand::{Rng, RngCore}; use rand::{Rng, RngCore};
#[macro_export] #[macro_export]
macro_rules! ouch { macro_rules! ouch {
($($e:expr),*) => { ($($e:expr),*) => {
::assert_cmd::Command::cargo_bin("ouch") $crate::utils::cargo_bin()
.expect("Failed to find ouch executable")
$(.arg($e))* $(.arg($e))*
.unwrap(); .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 // write random content to a file
pub fn write_random_content(file: &mut impl Write, rng: &mut impl RngCore) { pub fn write_random_content(file: &mut impl Write, rng: &mut impl RngCore) {
let mut data = Vec::new(); let mut data = Vec::new();