Skip to content

anng: adapt to NNG v2.0.0-alpha.7 API #210

anng: adapt to NNG v2.0.0-alpha.7 API

anng: adapt to NNG v2.0.0-alpha.7 API #210

permissions:
contents: read
on:
push:
branches: [ main ]
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
name: build
jobs:
linux-sys:
name: nng-sys on linux / ${{ matrix.name }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- name: system + bindgen
features: # no-default-features, so this won't vendor, and system implies bindgen
# clang and cmake for installing NNG, clang-dev for bindgen
apt: clang cmake libclang-dev
# until nng v2 is available via apt, we need to manually install nng
# for the checks that expect nng to be installed in the system
#
# TODO(flxo): remove the manual installation of nng and replace with
# a `apt install libnng2 libnng-dev` or similar, once the apt
# packages are available. Same applies for `brew` and others.
install_nng: true
env: {}
- name: vendored + bindgen
features: --features vendored,bindgen
# vendored nng and clang-dev for bindgen
apt: clang cmake libclang-dev
env: {}
- name: vendored + bundled
features: --features vendored
# vendored nng with bundled bindings, default generator (Unix Makefiles)
apt: clang cmake
env: {}
- name: vendored with Ninja + bundled
features: --features vendored
# vendored nng with bundled bindings, ninja generator
apt: clang cmake ninja-build
env:
CMAKE_GENERATOR: Ninja
- name: vendored with stats + bundled
features: --features vendored,vendored-stats
# vendored nng to get stats, bundled bindings
apt: clang cmake
env: {}
- name: vendored with tls + bundled
features: --features vendored,tls
# vendored nng to guarantee we get tls, bundled bindings, need to
# link against mbedtls.
apt: clang cmake libmbedtls-dev
env: {}
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # tag=v6.0.1
with:
submodules: true
- name: Install dependencies
run: |
sudo apt-get install -y ${{ matrix.apt }}
- name: Build and install NNG
if: matrix.install_nng
run: .github/scripts/install-nng.sh
- name: Install stable
uses: dtolnay/rust-toolchain@f7ccc83f9ed1e5b9c81d8a67d7ad1a747e22a561 # branch=master
with:
toolchain: stable
- name: cargo test -p nng-sys --no-default-features ${{ matrix.features }}
run: cargo test -p nng-sys --locked --all-targets --no-default-features ${{ matrix.features }}
env: ${{ matrix.env }}
linux-nng:
name: nng on linux / not vendored or bindgen
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # tag=v6.0.1
with:
submodules: true
# the nng crate is not yet upgraded to nng v2. install nng v1.x (libnng1 and libnng-dev)
- name: Install dependencies
run: |
sudo apt-get install -y libnng1 libnng-dev
- name: Install stable
uses: dtolnay/rust-toolchain@f7ccc83f9ed1e5b9c81d8a67d7ad1a747e22a561 # branch=master
with:
toolchain: stable
- name: cargo test -p nng --no-default-features
run: cargo test -p nng --locked --all-targets --no-default-features
env:
NNG_NO_VENDOR: "1"
linux-force-no-vendor:
name: nng on linux / NNG_NO_VENDOR
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # tag=v6.0.1
with:
submodules: true
# we test this by not installing nng, and checking that building _fails_
- name: Install stable
uses: dtolnay/rust-toolchain@f7ccc83f9ed1e5b9c81d8a67d7ad1a747e22a561 # branch=master
with:
toolchain: stable
- name: cargo build -p nng-sys --features vendored
run: |
if cargo build -p nng-sys --locked --features vendored 2>&1; then
echo "Build should have failed with NNG_NO_VENDOR=1"
exit 1
fi
echo "Build correctly failed when NNG_NO_VENDOR is set"
env:
NNG_NO_VENDOR: "1"
macos-sys:
name: nng-sys on macOS / ${{ matrix.name }}
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
include:
- name: system nng
features:
brew: cmake
install_nng: true
env:
# /usr/local/include is not a standard C compiler search path
CFLAGS: -I/usr/local/include
# /usr/local/lib is not in the default library search path on macOS
RUSTFLAGS: -L native=/usr/local/lib
- name: vendored
features: --features vendored
brew: cmake
env: {}
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # tag=v6.0.1
with:
submodules: true
- name: Install dependencies
run: |
brew install ${{ matrix.brew }}
- name: Build and install NNG
if: matrix.install_nng
run: .github/scripts/install-nng.sh
- name: Install stable
uses: dtolnay/rust-toolchain@f7ccc83f9ed1e5b9c81d8a67d7ad1a747e22a561 # branch=master
with:
toolchain: stable
- name: cargo test -p nng-sys --no-default-features ${{ matrix.features }}
run: cargo test -p nng-sys --locked --all-targets --no-default-features ${{ matrix.features }}
env: ${{ matrix.env }}
win-sys:
name: nng-sys on Windows ${{ matrix.features }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# chocolatey does not have nng as a pre-built library
# - os: windows-latest
# features:
# choco: libnng-dev
- os: windows-2022
features: --features vendored
choco: llvm cmake
# chocolatey cmake (4.1.2) doesn't have VS2026 yet (landed in 4.2)
# - os: windows-2025
# features: --features vendored
# choco: llvm cmake
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # tag=v6.0.1
with:
submodules: true
- name: Install dependencies
# echo "C:\Program Files\NASM" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
run: |
choco install ${{ matrix.choco }}
- name: Install stable
uses: dtolnay/rust-toolchain@f7ccc83f9ed1e5b9c81d8a67d7ad1a747e22a561 # branch=master
with:
toolchain: stable
- name: cargo test -p nng-sys --no-default-features ${{ matrix.features }}
run: cargo test -p nng-sys --locked --all-targets --no-default-features ${{ matrix.features }}