CI: Build for Gentoo #149
This file contains hidden or 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
name: Build DATUM Gateway | |
on: | |
schedule: | |
- cron: '0 0 1 * *' | |
push: | |
pull_request: | |
jobs: | |
build: | |
strategy: | |
matrix: | |
os: | |
- gentoo/stage3:hardened | |
config: | |
- cmake_args: "-DENABLE_API=ON -DCMAKE_C_COMPILER=gcc" | |
- cmake_args: "-DENABLE_API=ON -DCMAKE_C_COMPILER=clang" | |
- cmake_args: "-DENABLE_API=OFF" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Build inside Docker | |
run: | | |
PACKAGES_CLANG='clang' | |
PACKAGES_GCC='gcc' | |
case "${{ matrix.os }}" in | |
debian:*|ubuntu:*) | |
INSTALL_CMD="apt update && apt install -y" | |
PACKAGES="git libc6-dev cmake libcurl4-openssl-dev libjansson-dev libsodium-dev pkgconf" | |
PACKAGES_API="libmicrohttpd-dev" | |
;; | |
almalinux:*|amazonlinux:*|fedora:*|oraclelinux:*) | |
INSTALL_CMD="dnf install -y" | |
[[ "${{ matrix.os }}" =~ ^almalinux: ]] && INSTALL_CMD="dnf install -y dnf-plugins-core && dnf config-manager --set-enabled crb && $INSTALL_CMD" | |
[[ "${{ matrix.os }}" =~ ^oraclelinux: ]] && INSTALL_CMD="dnf install -y dnf-plugins-core && dnf config-manager --set-enabled ol9_codeready_builder && $INSTALL_CMD" | |
[[ "${{ matrix.os }}" =~ ^(alma|oracle)linux: ]] && INSTALL_CMD="dnf install -y epel-release && $INSTALL_CMD" | |
PACKAGES="git cmake libcurl-devel jansson-devel libsodium-devel pkgconf" | |
PACKAGES_API="libmicrohttpd-devel" | |
[[ "${{ matrix.config.cmake_args }}" =~ clang|gcc ]] || PACKAGES="$PACKAGES gcc" | |
;; | |
alpine:*) | |
INSTALL_CMD="apk add --no-cache" | |
PACKAGES="git build-base cmake argp-standalone curl-dev jansson-dev libsodium-dev" | |
PACKAGES_API="libmicrohttpd-dev" | |
;; | |
archlinux:*) | |
INSTALL_CMD="pacman -Syu --noconfirm" | |
PACKAGES="git base-devel cmake curl jansson libsodium" | |
PACKAGES_API="libmicrohttpd" | |
;; | |
clearlinux:*) | |
INSTALL_CMD="swupd bundle-add" | |
PACKAGES="git c-basic devpkg-curl devpkg-jansson devpkg-libsodium" | |
PACKAGES_API="devpkg-libmicrohttpd" | |
PACKAGES_CLANG="llvm" | |
PACKAGES_GCC='' # included in c-basic | |
;; | |
gentoo/*) | |
INIT_CMD=' | |
emerge --sync --quiet | |
' | |
INSTALL_CMD="emerge -1 sec-keys/openpgp-keys-gentoo-release && getuto && cat /etc/portage/make.conf && USE='-perl -extra -static-analyzer -compiler-rt -openmp -sanitize -adns -alt-svc -ftp -hsts -http2 -http3 -imap -pop3 -progress-meter -psl -quic -curl_quic_openssl -smtp -tftp -websockets -nls' emerge -vuDtkg1 --noreplace --jobs=\$(nproc) --buildpkg" | |
PACKAGES="dev-vcs/git dev-build/cmake net-misc/curl dev-libs/jansson dev-libs/libsodium virtual/pkgconfig" | |
PACKAGES_API="net-libs/libmicrohttpd" | |
PACKAGES_CLANG="llvm-core/clang" | |
POSTINSTALL_CMD=' | |
set +ex | |
source /etc/profile | |
set -ex | |
' | |
;; | |
esac | |
PACKAGES="$PACKAGES ${{ matrix.config.extra_deps }}" | |
if [[ "${{ matrix.config.cmake_args }}" =~ ENABLE_API=ON ]]; then | |
PACKAGES="$PACKAGES $PACKAGES_API" | |
fi | |
if [[ "${{ matrix.config.cmake_args }}" =~ CMAKE_C_COMPILER=gcc ]]; then | |
PACKAGES="$PACKAGES $PACKAGES_GCC" | |
elif [[ "${{ matrix.config.cmake_args }}" =~ CMAKE_C_COMPILER=clang ]]; then | |
PACKAGES="$PACKAGES $PACKAGES_CLANG" | |
fi | |
CMD="set -ex | |
${INIT_CMD} | |
${INSTALL_CMD} ${PACKAGES} | |
${POSTINSTALL_CMD} | |
git config --global --add safe.directory /workspace | |
mkdir -p build | |
cd build | |
cmake /workspace -DCMAKE_C_FLAGS='-Wall -Werror' ${{ matrix.config.cmake_args }} | |
make -j\$(nproc) | |
./datum_gateway --help | |
" | |
docker run \ | |
-v "${{ github.workspace }}:/workspace":ro \ | |
"${{ matrix.os }}" \ | |
/bin/sh -c "${CMD}" |