Nightly #346
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Copyright (c) 2022 ZettaScale Technology | |
# | |
# This program and the accompanying materials are made available under the | |
# terms of the Eclipse Public License 2.0 which is available at | |
# http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 | |
# which is available at https://www.apache.org/licenses/LICENSE-2.0. | |
# | |
# SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 | |
# | |
# Contributors: | |
# ZettaScale Zenoh Team, <[email protected]> | |
# | |
name: Nightly | |
on: | |
schedule: | |
- cron: "0 0 * * 1-5" | |
workflow_dispatch: | |
jobs: | |
checks: | |
name: Code checks | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Install Rust toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
components: rustfmt, clippy | |
- name: Code format check | |
uses: actions-rs/cargo@v1 | |
with: | |
command: fmt | |
args: -- --check | |
- name: Clippy check | |
uses: actions-rs/cargo@v1 | |
with: | |
command: clippy | |
args: --all-targets -- -D warnings | |
- name: Environment setup | |
id: env | |
shell: bash | |
run: | | |
# log some info | |
gcc --version || true | |
rustup -V | |
rustup toolchain list | |
rustup default | |
cargo -V | |
rustc -V | |
echo "GITHUB_REF=${GITHUB_REF}" | |
echo "GITHUB_SHA=${GITHUB_SHA:0:8}" | |
GIT_BRANCH=`[[ $GITHUB_REF =~ ^refs/heads/.* ]] && echo ${GITHUB_REF/refs\/heads\//} || true` | |
echo "GIT_BRANCH=${GIT_BRANCH}" >> $GITHUB_OUTPUT | |
GIT_TAG=`[[ $GITHUB_REF =~ ^refs/tags/.* ]] && echo ${GITHUB_REF/refs\/tags\//} || true` | |
echo "GIT_TAG=${GIT_TAG}" >> $GITHUB_OUTPUT | |
ZENOH_FLOW_VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n1) | |
echo "ZENOH_FLOW_VERSION=${ZENOH_FLOW_VERSION}" >> $GITHUB_OUTPUT | |
if [ -n "${GIT_TAG}" ]; then | |
IS_RELEASE="true" | |
echo "IS_RELEASE=${IS_RELEASE}" >> $GITHUB_OUTPUT | |
PKG_VERSION=${ZENOH_FLOW_VERSION} | |
elif [ -n "${GIT_BRANCH}" ]; then | |
PKG_VERSION=${GIT_BRANCH}-${GITHUB_SHA:0:8} | |
else | |
PKG_VERSION=${ZENOH_FLOW_VERSION}-${GITHUB_SHA:0:8} | |
fi | |
echo "PKG_VERSION=${PKG_VERSION}" >> $GITHUB_OUTPUT | |
echo "GIT_TAG=${GIT_TAG}" | |
echo "GIT_BRANCH=${GIT_BRANCH}" | |
echo "IS_RELEASE=${IS_RELEASE}" | |
echo "ZENOH_FLOW_VERSION=${ZENOH_FLOW_VERSION}" | |
echo "PKG_VERSION=${PKG_VERSION}" | |
outputs: | |
GIT_BRANCH: ${{ steps.env.outputs.GIT_BRANCH }} | |
GIT_TAG: ${{ steps.env.outputs.GIT_TAG }} | |
IS_RELEASE: ${{ steps.env.outputs.IS_RELEASE }} | |
ZENOH_FLOW_VERSION: ${{ steps.env.outputs.ZENOH_FLOW_VERSION }} | |
PKG_VERSION: ${{ steps.env.outputs.PKG_VERSION }} | |
tests: | |
name: Tests | |
needs: checks | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Install Rust toolchain | |
uses: actions-rs/toolchain@v1 | |
- name: Run tests | |
uses: actions-rs/cargo@v1 | |
with: | |
command: test | |
args: --release --verbose | |
env: | |
ASYNC_STD_THREAD_COUNT: 4 | |
doc: | |
name: Doc generation | |
needs: checks | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Install Rust toolchain | |
uses: actions-rs/toolchain@v1 | |
- name: generate doc | |
env: | |
RUSTDOCFLAGS: -Dwarnings | |
uses: actions-rs/cargo@v1 | |
with: | |
command: doc | |
args: --no-deps | |
docker_builds: | |
name: Build for ${{ matrix.job.target }} on ${{ matrix.job.container }} | |
needs: checks | |
runs-on: ubuntu-latest | |
container: | |
image: ${{ matrix.job.container }} | |
strategy: | |
fail-fast: false | |
matrix: | |
job: | |
- { target: x86_64-unknown-linux-gnu, arch: amd64, container: "fedora:35" } | |
# - { target: aarch64-unknown-linux-gnu, arch: arm64, container: "fedora:35", use-cross: true } | |
- { target: x86_64-unknown-linux-musl, arch: amd64, container: "alpine:3" } | |
steps: | |
- name: Install prerequisites | |
run: | | |
case ${{ matrix.job.container }} in | |
*fedora*) | |
dnf update -y | |
dnf install -y git curl openssl-devel | |
dnf groupinstall "Development Tools" "Development Libraries" -y | |
case ${{ matrix.job.target }} in | |
aarch64-unknown-linux-gnu) | |
dnf install -y gcc-aarch64-linux-gnu | |
;; | |
esac | |
;; | |
*alpine*) | |
apk update | |
apk add git curl build-base libressl-dev bash | |
;; | |
esac | |
- name: Install Rust toolchain | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
target: ${{ matrix.job.target }} | |
- name: Install cargo rpm | |
run: | | |
case ${{ matrix.job.container }} in | |
*fedora*) cargo install cargo-rpm ;; | |
esac | |
- name: Trust this directory | |
run: git config --global --add safe.directory /__w/zenoh-flow/zenoh-flow | |
- name: Checkout source code | |
uses: actions/checkout@v2 | |
- name: Build | |
uses: actions-rs/cargo@v1 | |
with: | |
use-cross: ${{ matrix.job.use-cross }} | |
command: build | |
args: --release --bins --lib --examples --target=${{ matrix.job.target }} | |
builds: | |
name: Build for ${{ matrix.job.target }} on ${{ matrix.job.os }} | |
needs: checks | |
runs-on: ${{ matrix.job.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
job: | |
- { target: x86_64-unknown-linux-gnu, arch: amd64, os: ubuntu-20.04 } | |
- { | |
target: x86_64-unknown-linux-musl, | |
arch: amd64, | |
os: ubuntu-20.04, | |
use-cross: true, | |
} | |
- { | |
target: arm-unknown-linux-gnueabi, | |
arch: armel, | |
os: ubuntu-20.04, | |
use-cross: true, | |
} | |
- { | |
target: arm-unknown-linux-gnueabihf, | |
arch: armhf, | |
os: ubuntu-20.04, | |
use-cross: true, | |
} | |
- { | |
target: armv7-unknown-linux-gnueabihf, | |
arch: armhf, | |
os: ubuntu-20.04, | |
use-cross: true, | |
} | |
- { | |
target: aarch64-unknown-linux-gnu, | |
arch: arm64, | |
os: ubuntu-20.04, | |
use-cross: true, | |
} | |
- { target: x86_64-unknown-linux-gnu, arch: amd64, os: ubuntu-18.04 } | |
- { | |
target: x86_64-unknown-linux-musl, | |
arch: amd64, | |
os: ubuntu-18.04, | |
use-cross: true, | |
} | |
- { | |
target: arm-unknown-linux-gnueabi, | |
arch: armel, | |
os: ubuntu-18.04, | |
use-cross: true, | |
} | |
- { | |
target: arm-unknown-linux-gnueabihf, | |
arch: armhf, | |
os: ubuntu-18.04, | |
use-cross: true, | |
} | |
- { | |
target: armv7-unknown-linux-gnueabihf, | |
arch: armhf, | |
os: ubuntu-18.04, | |
use-cross: true, | |
} | |
- { | |
target: aarch64-unknown-linux-gnu, | |
arch: arm64, | |
os: ubuntu-18.04, | |
use-cross: true, | |
} | |
- { target: x86_64-apple-darwin, arch: darwin, os: macos-latest } | |
- { target: aarch64-apple-darwin, arch: darwin, os: macos-latest } | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v2 | |
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 | |
shell: bash | |
run: git fetch --tags --force | |
- name: Install prerequisites | |
shell: bash | |
run: | | |
case ${{ matrix.job.target }} in | |
*-linux-gnu*) cargo install cargo-deb ;; | |
esac | |
case ${{ matrix.job.target }} in | |
arm-unknown-linux-gnueabi) | |
sudo apt-get -y update | |
sudo apt-get -y install gcc-arm-linux-gnueabi | |
;; | |
arm*-unknown-linux-gnueabihf) | |
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-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
target: ${{ matrix.job.target }} | |
override: true | |
profile: minimal | |
- name: Build | |
uses: actions-rs/cargo@v1 | |
with: | |
use-cross: ${{ matrix.job.use-cross }} | |
command: build | |
args: --release --bins --lib --target=${{ matrix.job.target }} | |
- name: Debian package - zenoh-flow-daemon | |
if: contains(matrix.job.target, '-linux-gnu') | |
uses: actions-rs/cargo@v1 | |
with: | |
command: deb | |
args: --no-build --target=${{ matrix.job.target }} -p zenoh-flow-daemon | |
- name: Debian package - zfctl | |
if: contains(matrix.job.target, '-linux-gnu') | |
uses: actions-rs/cargo@v1 | |
with: | |
command: deb | |
args: --no-build --target=${{ matrix.job.target }} -p zfctl | |
- name: Debian package - zenoh-flow-plugin | |
if: contains(matrix.job.target, '-linux-gnu') | |
uses: actions-rs/cargo@v1 | |
with: | |
command: deb | |
args: --no-build --target=${{ matrix.job.target }} -p zenoh-flow-plugin | |
- name: Packaging | |
id: package | |
shell: bash | |
run: | | |
TARGET=${{ matrix.job.target }} | |
MAIN_PKG_NAME="${GITHUB_WORKSPACE}/zenoh-${{ needs.checks.outputs.PKG_VERSION }}-${TARGET}.zip" | |
DEBS_PKG_NAME="${GITHUB_WORKSPACE}/zenoh-${{ needs.checks.outputs.PKG_VERSION }}-${TARGET}-deb-pkgs.zip" | |
case ${TARGET} in | |
*linux*) | |
cd "target/${TARGET}/release/" | |
echo "Packaging ${MAIN_PKG_NAME}:" | |
zip ${MAIN_PKG_NAME} libzplugin_zenoh_flow.so zfctl zenoh-flow-daemon | |
cd - | |
echo MAIN_PKG_NAME="${MAIN_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 DEBS_PKG_NAME="${DEBS_PKG_NAME}" >> $GITHUB_OUTPUT | |
fi | |
;; | |
*apple*) | |
cd "target/${TARGET}/release/" | |
echo "Packaging ${MAIN_PKG_NAME}:" | |
zip ${MAIN_PKG_NAME} libzplugin_zenoh_flow.dylib zfctl zenoh-flow-daemon | |
cd - | |
echo MAIN_PKG_NAME="${MAIN_PKG_NAME}" >> $GITHUB_OUTPUT | |
;; | |
esac | |
- name: "Upload packages" | |
uses: actions/upload-artifact@master | |
with: | |
name: ${{ matrix.job.target }} | |
path: | | |
${{ steps.package.outputs.MAIN_PKG_NAME }} | |
${{ steps.package.outputs.DEBS_PKG_NAME }} |