Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix macos; Add macos to ci #511

Merged
merged 2 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 25 additions & 15 deletions .github/workflows/binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,48 @@ name: binaries
jobs:
# release binaries
release-bins:
runs-on: ubuntu-latest
runs-on: ${{ matrix.job.os }}
env:
RUSTFLAGS: "-C target-feature=+crt-static"
BUILD_CMD: cargo
strategy:
fail-fast: false
matrix:
targets:
- x86_64-unknown-linux-musl
- aarch64-unknown-linux-musl
- arm-unknown-linux-musleabi
job:
- { target: x86_64-unknown-linux-musl, os: ubuntu-latest, use-cross: true }
- { target: aarch64-unknown-linux-musl, os: ubuntu-latest, use-cross: true }
- { target: arm-unknown-linux-musleabi, os: ubuntu-latest, use-cross: true }
- { target: x86_64-apple-darwin, os: macos-12 }

steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
- name: Populate cache
uses: ./.github/workflows/cache

- name: Overwrite build command env variable
if: matrix.job.use-cross
shell: bash
run: |
echo "BUILD_CMD=cross" >> $GITHUB_ENV
RUSTFLAGS="-C target-feature=-crt-static" cargo install cross --git https://github.com/cross-rs/cross

- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
target: ${{ matrix.targets }}
- run: RUSTFLAGS="-C target-feature=-crt-static" cargo install cross --git https://github.com/cross-rs/cross
- run: cross build -p backhand-cli --bin add-backhand --bin replace-backhand --locked --target ${{ matrix.targets }} --profile=dist
target: ${{ matrix.job.target }}

- run: $BUILD_CMD build -p backhand-cli --bin add-backhand --bin replace-backhand --features xz-static --locked --target ${{ matrix.job.target }} --profile=dist
# default features, but replace gzip with gzip-zune-inflate
- run: cross build -p backhand-cli --bin unsquashfs-backhand --locked --target ${{ matrix.targets }} --profile=dist --no-default-features --features zstd,xz,gzip-zune-inflate
- run: $BUILD_CMD build -p backhand-cli --bin unsquashfs-backhand --locked --target ${{ matrix.job.target }} --profile=dist --no-default-features --features zstd,xz-static,gzip-zune-inflate
- name: archive
run: |
tar -czvf backhand-${{ matrix.targets }}.tar.gz \
-C target/${{ matrix.targets }}/dist/ $BINS
tar -czvf backhand-${{ matrix.job.target }}.tar.gz \
-C target/${{ matrix.job.target }}/dist/ $BINS

- uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: backhand-${{ matrix.targets }}.tar.gz
path: backhand-${{ matrix.targets }}.tar.gz
name: backhand-${{ matrix.job.target }}.tar.gz
path: backhand-${{ matrix.job.target }}.tar.gz

# check semvar before release!
- name: Check semver
Expand All @@ -61,8 +71,8 @@ jobs:
uses: svenstaro/upload-release-action@04733e069f2d7f7f0b4aebc4fbdbce8613b03ccd # v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: backhand-${{ matrix.targets }}.tar.gz
asset_name: backhand-${{ github.ref_name }}-${{ matrix.targets }}.tar.gz
file: backhand-${{ matrix.job.target }}.tar.gz
asset_name: backhand-${{ github.ref_name }}-${{ matrix.job.target }}.tar.gz
tag: ${{ github.ref }}
prerelease: true
overwrite: true
32 changes: 17 additions & 15 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,19 @@ name: ci
jobs:
# build/test all supported targets for library and bins (skipping slow and squashfs-tools tests)
cross-test:
runs-on: ubuntu-latest
runs-on: ${{ matrix.job.os }}
env:
RUSTFLAGS: "-C target-feature=+crt-static"
BUILD_CMD: cargo
strategy:
# By default, this is set to `true`, which means that a single CI job
# failure will cause all outstanding jobs to be canceled. This slows down
# development because it means that errors need to be encountered and
# fixed one at a time.
fail-fast: false
matrix:
target:
- x86_64-unknown-linux-musl
- aarch64-unknown-linux-musl
- arm-unknown-linux-musleabi
- armv7-unknown-linux-musleabi
job:
- { target: x86_64-unknown-linux-musl, os: ubuntu-latest, use-cross: true }
- { target: aarch64-unknown-linux-musl, os: ubuntu-latest, use-cross: true }
- { target: arm-unknown-linux-musleabi, os: ubuntu-latest, use-cross: true }
- { target: armv7-unknown-linux-musleabi, os: ubuntu-latest, use-cross: true }
- { target: x86_64-apple-darwin, os: macos-12 }
toolchain:
- stable
# msrv of backhand-cli
Expand All @@ -40,16 +38,20 @@ jobs:
- name: Populate cache
uses: ./.github/workflows/cache

- name: Overwrite build command env variable
if: matrix.job.use-cross
shell: bash
run: |
echo "BUILD_CMD=cross" >> $GITHUB_ENV
RUSTFLAGS="-C target-feature=-crt-static" cargo install cross --git https://github.com/cross-rs/cross
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain }}
# install cross
- run: RUSTFLAGS="-C target-feature=-crt-static" cargo install cross --git https://github.com/cross-rs/cross
# build lib and bins with cross
- run: cross build ${{ matrix.features }} --target ${{ matrix.target }} --release --locked --workspace
- run: $BUILD_CMD build ${{ matrix.features }} --target ${{ matrix.job.target }} --release --locked --workspace --features xz-static
# test with cross, skipping slow test and tests that use more then qemu default memory
- run: CROSS_CONTAINER_OPTS="--network host" RUST_LOG=info cross test --workspace --release ${{ matrix.features }} --target ${{ matrix.target }} --locked -- --skip slow --skip no_qemu

- run: CROSS_CONTAINER_OPTS="--network host" RUST_LOG=info $BUILD_CMD test --workspace --release ${{ matrix.features }} --target ${{ matrix.job.target }} --features xz-static --locked -- --skip slow --skip no_qemu
# build/test all supported on native x86_64 arch for library and bins (all tests)
build-test-native:
runs-on: ubuntu-latest
Expand Down
9 changes: 6 additions & 3 deletions backhand-cli/src/bin/unsquashfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,11 +563,12 @@ fn extract_all<'a, S: ParallelIterator<Item = &'a Node<SquashfsFileReader>>>(
}
InnerNode::CharacterDevice(SquashfsCharacterDevice { device_number }) => {
if root_process {
#[allow(clippy::unnecessary_fallible_conversions)]
match mknod(
&filepath,
SFlag::S_IFCHR,
Mode::from_bits(mode_t::from(node.header.permissions)).unwrap(),
dev_t::from(*device_number),
dev_t::try_from(*device_number).unwrap(),
) {
Ok(_) => {
if args.info && !args.quiet {
Expand Down Expand Up @@ -603,11 +604,12 @@ fn extract_all<'a, S: ParallelIterator<Item = &'a Node<SquashfsFileReader>>>(
}
}
InnerNode::BlockDevice(SquashfsBlockDevice { device_number }) => {
#[allow(clippy::unnecessary_fallible_conversions)]
match mknod(
&filepath,
SFlag::S_IFBLK,
Mode::from_bits(mode_t::from(node.header.permissions)).unwrap(),
dev_t::from(*device_number),
dev_t::try_from(*device_number).unwrap(),
) {
Ok(_) => {
if args.info && !args.quiet {
Expand Down Expand Up @@ -649,11 +651,12 @@ fn extract_all<'a, S: ParallelIterator<Item = &'a Node<SquashfsFileReader>>>(
}
}
InnerNode::Socket => {
#[allow(clippy::unnecessary_fallible_conversions)]
match mknod(
&filepath,
SFlag::S_IFSOCK,
Mode::from_bits(mode_t::from(node.header.permissions)).unwrap(),
dev_t::from(0_u64),
dev_t::try_from(0_u64).unwrap(),
) {
Ok(_) => {
if args.info && !args.quiet {
Expand Down
Loading