Skip to content

Commit

Permalink
Merge pull request #216 from fuzzypixelz/fix/release-workflow
Browse files Browse the repository at this point in the history
Fix Release workflow
  • Loading branch information
milyin authored Dec 7, 2023
2 parents 542c6b8 + eefc18e commit 04ceff3
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 93 deletions.
44 changes: 15 additions & 29 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,82 +18,68 @@ jobs:
os: [ubuntu-latest, macOS-latest, windows-latest]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
components: rustfmt, clippy
run: rustup component add rustfmt clippy

- name: Clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all --examples --features=logger-autoinit --features=shared-memory -- -D warnings
- name: Run clippy
run: cargo clippy --all-targets --all-features -- --deny warnings

- name: Run rustfmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: -- --check
run: cargo fmt --check

- name: Check for feature leaks
uses: actions-rs/cargo@v1
with:
command: test
args: --no-default-features
run: cargo test --no-default-features

- name: build and install
- name: Build and install
shell: bash
run: |
mkdir -p build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=~/local
cmake --build . --target install --config Release
- name: run cmake tests with zenoh-c as dynamic library
- name: Run cmake tests with zenoh-c as dynamic library
shell: bash
run: |
cd build
cmake .. -DZENOHC_LIB_STATIC=FALSE -DCMAKE_BUILD_TYPE=Release
cmake --build . --target tests --config Release
ctest -C Release --output-on-failure -E "(unit_z_api_alignment_test|build_z_build_static)"
- name: run cmake tests with zenoh-c as static library
- name: Run cmake tests with zenoh-c as static library
shell: bash
run: |
cd build
cmake .. -DZENOHC_LIB_STATIC=TRUE -DCMAKE_BUILD_TYPE=Release
cmake --build . --target tests --config Release
ctest -C Release --output-on-failure -E "(unit_z_api_alignment_test|build_z_build_shared)"
- name: make examples with zenoh-c
- name: Build examples with zenoh-c
shell: bash
run: |
cd build
cmake --build . --target examples
- name: make examples with zenoh-c as subbroject and static library and in debug mode
- name: Build examples with zenoh-c as subbroject and static library and in debug mode
shell: bash
run: |
mkdir -p build_examples_subproj && cd build_examples_subproj
cmake ../examples -DCMAKE_BUILD_TYPE=Debug -DZENOHC_LIB_STATIC=TRUE
cmake --build . --config Debug
- name: make examples with zenoh-c as installed package
- name: Build examples with zenoh-c as installed package
shell: bash
run: |
mkdir -p build_examples_findproj && cd build_examples_findproj
cmake ../examples -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=~/local -DZENOHC_SOURCE=PACKAGE
cmake --build . --config Release
- name: Run rust tests
uses: actions-rs/cargo@v1
with:
command: test
args: --verbose --release --features=logger-autoinit --features=shared-memory
run: cargo test --verbose --release --features=logger-autoinit --features=shared-memory

- name: Upload artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
# Artifact name
name: zenoh-c-${{ matrix.os }}
Expand Down
97 changes: 36 additions & 61 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,17 @@ jobs:
name: Code checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
components: rustfmt, clippy
run: rustup component add rustfmt clippy

- name: Code format check
uses: actions-rs/cargo@v1
with:
command: fmt
args: -- --check
run: cargo fmt --check

- name: Clippy check
uses: actions-rs/cargo@v1
with:
command: clippy
args: --features=logger-autoinit --features=shared-memory -- -D warnings
run: cargo clippy --all-targets --all-features -- --deny warnings

- name: Environment setup
id: env
shell: bash
Expand All @@ -56,26 +52,26 @@ jobs:
echo "GITHUB_SHA=${GITHUB_SHA:0:8}"
GIT_BRANCH=`[[ $GITHUB_REF =~ ^refs/heads/.* ]] && echo ${GITHUB_REF/refs\/heads\//} || true`
echo "GIT_BRANCH=${GIT_BRANCH}"
echo ::set-output name=GIT_BRANCH::"${GIT_BRANCH}"
echo "GIT_BRANCH=${GIT_BRANCH}" >> $GITHUB_OUTPUT
GIT_TAG=`[[ $GITHUB_REF =~ ^refs/tags/.* ]] && echo ${GITHUB_REF/refs\/tags\//} || true`
echo "GIT_TAG=${GIT_TAG}"
echo ::set-output name=GIT_TAG::"${GIT_TAG}"
echo "GIT_TAG=${GIT_TAG}" >> $GITHUB_OUTPUT
ZENOH_VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n1)
echo "ZENOH_VERSION=${ZENOH_VERSION}"
echo ::set-output name=ZENOH_VERSION::"${ZENOH_VERSION}"
echo "ZENOH_VERSION=${ZENOH_VERSION}" >> $GITHUB_OUTPUT
if [ -n "${GIT_TAG}" ]; then
IS_RELEASE="true"
echo "IS_RELEASE=${IS_RELEASE}"
echo ::set-output name=IS_RELEASE::"${IS_RELEASE}"
echo "IS_RELEASE=${IS_RELEASE}" >> $GITHUB_OUTPUT
PKG_VERSION=${ZENOH_VERSION}
elif [ -n "${GIT_BRANCH}" ]; then
PKG_VERSION=${GIT_BRANCH}-${GITHUB_SHA:0:8}
else
PKG_VERSION=${ZENOH_VERSION}-${GITHUB_SHA:0:8}
fi
echo "PKG_VERSION=${PKG_VERSION}"
echo ::set-output name=PKG_VERSION::"${PKG_VERSION}"
echo "PKG_VERSION=${PKG_VERSION}" >> $GITHUB_OUTPUT
outputs:
GIT_BRANCH: ${{ steps.env.outputs.GIT_BRANCH }}
GIT_TAG: ${{ steps.env.outputs.GIT_TAG }}
Expand All @@ -91,40 +87,30 @@ jobs:
fail-fast: false
matrix:
job:
- { target: x86_64-unknown-linux-gnu, arch: amd64, os: ubuntu-20.04 }
- {
target: arm-unknown-linux-gnueabi,
arch: armel,
os: ubuntu-20.04,
use-cross: true,
}
- { target: x86_64-unknown-linux-gnu, arch: amd64, os: ubuntu-20.04, build-cmd: "cargo" }
- { target: arm-unknown-linux-gnueabi, arch: armel, os: ubuntu-20.04, build-cmd: "cross" }
- {
target: arm-unknown-linux-gnueabihf,
arch: armhf,
os: ubuntu-20.04,
use-cross: true,
build-cmd: "cross",
}
- {
target: armv7-unknown-linux-gnueabihf,
arch: armhf,
os: ubuntu-20.04,
use-cross: true,
build-cmd: "cross",
}
- {
target: aarch64-unknown-linux-gnu,
arch: arm64,
os: ubuntu-20.04,
use-cross: true,
}
- { target: x86_64-apple-darwin, arch: darwin, os: macos-latest }
- { target: aarch64-apple-darwin, arch: darwin, os: macos-latest }
- { target: x86_64-pc-windows-msvc, arch: win64, os: windows-2019 }
- { target: x86_64-pc-windows-gnu, arch: win64, os: windows-2019 }
- { target: aarch64-unknown-linux-gnu, arch: arm64, os: ubuntu-20.04, build-cmd: "cross" }
- { target: x86_64-apple-darwin, arch: darwin, os: macos-latest, build-cmd: "cargo" }
- { target: aarch64-apple-darwin, arch: darwin, os: macos-latest, build-cmd: "cargo" }
- { target: x86_64-pc-windows-msvc, arch: win64, os: windows-2019, build-cmd: "cargo" }
- { target: x86_64-pc-windows-gnu, arch: win64, os: windows-2019, build-cmd: "cargo" }
env:
CMAKE_CROSSCOMPILING: ON
steps:
- name: Checkout source code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 500 # NOTE: get long history for git-version crate to correctly compute a version
- name: Fetch Git tags # NOTE: workaround for https://github.com/actions/checkout/issues/290
Expand Down Expand Up @@ -152,34 +138,23 @@ jobs:
;;
esac
cargo install cross --git https://github.com/cross-rs/cross
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.job.target }}
override: true
profile: minimal
run: |
rustup set profile minimal
rustup target add ${{ matrix.job.target }}
- name: Build
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.job.use-cross }}
command: build
args: --release --target=${{ matrix.job.target }} --features=logger-autoinit --features=shared-memory
- name: Build for ${{ matrix.job.target }} target
run: ${{ matrix.job.build-cmd }} build --release --target=${{ matrix.job.target }} --features=logger-autoinit --features=shared-memory

- name: Debian package - libzenohc
if: contains(matrix.job.target, '-linux-gnu')
uses: actions-rs/cargo@v1
with:
command: deb
args: --no-build --no-strip --target=${{ matrix.job.target }} --variant=libzenohc
run: cargo deb --no-build --no-strip --target=${{ matrix.job.target }} --variant=libzenohc

- name: Debian package - libzenohc-dev
if: contains(matrix.job.target, '-linux-gnu')
uses: actions-rs/cargo@v1
with:
command: deb
args: --no-build --no-strip --target=${{ matrix.job.target }} --variant=libzenohc-dev
run: cargo deb --no-build --no-strip --target=${{ matrix.job.target }} --variant=libzenohc-dev

- name: Packaging
id: package
Expand All @@ -197,15 +172,15 @@ jobs:
zip -r ${LIB_PKG_NAME} lib
cd -
zip -r ${LIB_PKG_NAME} include
echo ::set-output name=LIB_PKG_NAME::"${LIB_PKG_NAME}"
echo "LIB_PKG_NAME=${LIB_PKG_NAME}" >> $GITHUB_OUTPUT
# check if debian packages has been created and packages them in a single tgz
if [[ -d target/${TARGET}/debian ]]; then
cd target/${TARGET}/debian
echo "Packaging ${DEBS_PKG_NAME}:"
zip ${DEBS_PKG_NAME} *.deb
cd -
echo ::set-output name=DEBS_PKG_NAME::"${DEBS_PKG_NAME}"
echo "DEBS_PKG_NAME=${DEBS_PKG_NAME}" >> $GITHUB_OUTPUT
fi
;;
*apple*)
Expand All @@ -215,7 +190,7 @@ jobs:
zip -r ${LIB_PKG_NAME} lib
cd -
zip -r ${LIB_PKG_NAME} include
echo ::set-output name=LIB_PKG_NAME::"${LIB_PKG_NAME}"
echo "LIB_PKG_NAME=${LIB_PKG_NAME}" >> $GITHUB_OUTPUT
;;
*windows*)
cd "target/${TARGET}/release/"
Expand All @@ -224,7 +199,7 @@ jobs:
7z -y -r a "${LIB_PKG_NAME}" lib
cd -
7z -y -r a "${LIB_PKG_NAME}" include
echo ::set-output name=LIB_PKG_NAME::"${LIB_PKG_NAME}"
echo "LIB_PKG_NAME=${LIB_PKG_NAME}" >> $GITHUB_OUTPUT
;;
esac
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function(configure_cargo_toml cargo_toml_dir CARGO_PROJECT_VERSION CARGO_LIB_NAM
${CMAKE_CURRENT_SOURCE_DIR}/splitguide.yaml
${CMAKE_CURRENT_SOURCE_DIR}/cbindgen.toml
${CMAKE_CURRENT_SOURCE_DIR}/Cargo.lock
${CMAKE_CURRENT_SOURCE_DIR}/rust-toolchain
${CMAKE_CURRENT_SOURCE_DIR}/rust-toolchain.toml
DESTINATION ${cargo_toml_dir})
endif()
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/Cargo.toml.in" "${cargo_toml_dir}/Cargo.toml" @ONLY)
Expand Down
1 change: 0 additions & 1 deletion rust-toolchain

This file was deleted.

2 changes: 2 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[toolchain]
channel = "1.72.0"
2 changes: 1 addition & 1 deletion src/queryable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ pub extern "C" fn z_query_drop(this: &mut z_owned_query_t) {
#[no_mangle]
pub extern "C" fn z_query_clone(query: Option<&z_query_t>) -> z_owned_query_t {
match query {
Some(query) => unsafe { core::mem::transmute(query.as_ref().map(|q| q.clone())) },
Some(query) => unsafe { core::mem::transmute(query.as_ref().cloned()) },
None => z_query_null(),
}
}
Expand Down

0 comments on commit 04ceff3

Please sign in to comment.