Gentoo Systemd with Overlay CI #66
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: Gentoo Systemd with Overlay CI | |
| on: | |
| workflow_dispatch: | |
| jobs: | |
| gentoo-userver: | |
| runs-on: ubuntu-latest | |
| env: | |
| BINHOST_IP: ${{ secrets.BINHOST_IP }} | |
| BINHOST_PORT: ${{ secrets.BINHOST_PORT }} | |
| BINHOST_CERT: ${{ secrets.BINHOST_CERT }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| # ---------- Build Gentoo base image ---------- | |
| - name: Build Gentoo image | |
| run: | | |
| docker build -t gentoo-systemd -f docker/gentoo/systemd.Dockerfile . | |
| - name: Run Gentoo container (systemd) | |
| run: | | |
| docker run --privileged -d \ | |
| --name gentoo-test \ | |
| --cgroupns=host \ | |
| -v /sys/fs/cgroup:/sys/fs/cgroup:rw \ | |
| gentoo-systemd /sbin/init | |
| echo "Waiting for systemd to initialize..." | |
| sleep 15 | |
| docker ps | grep gentoo-test | |
| # ---------- Sync Gentoo tree ---------- | |
| - name: Sync gentoo tree (webrsync) | |
| run: | | |
| docker exec gentoo-test bash -lc 'emerge-webrsync' | |
| # ---------- Configure USE flags ---------- | |
| - name: Configure USE flags | |
| run: | | |
| docker exec gentoo-test bash -lc ' | |
| mkdir -p /etc/portage/package.use | |
| # userver main package | |
| echo "dev-cpp/userver postgres redis mongodb mysql rabbitmq kafka sqlite utest odbc uboost-coro" > /etc/portage/package.use/userver | |
| # Dependencies to be built from source with explicit USE flags | |
| echo "dev-libs/re2 icu" >> /etc/portage/package.use/userver-deps | |
| echo "dev-libs/cyrus-sasl static-libs" >> /etc/portage/package.use/userver-deps | |
| echo "dev-lang/python ssl" >> /etc/portage/package.use/userver-deps | |
| echo "dev-libs/crypto++ static-libs" >> /etc/portage/package.use/userver-deps | |
| echo "dev-libs/libbson static-libs" >> /etc/portage/package.use/userver-deps | |
| echo "dev-libs/libev static-libs" >> /etc/portage/package.use/userver-deps | |
| echo "dev-libs/openssl static-libs" >> /etc/portage/package.use/userver-deps | |
| echo "net-dns/c-ares static-libs" >> /etc/portage/package.use/userver-deps | |
| echo "net-misc/curl static-libs" >> /etc/portage/package.use/userver-deps | |
| echo "net-nds/openldap static-libs" >> /etc/portage/package.use/userver-deps | |
| echo "sys-libs/zlib static-libs" >> /etc/portage/package.use/userver-deps | |
| echo "dev-libs/hiredis static-libs" >> /etc/portage/package.use/userver-deps | |
| echo "dev-libs/mongo-c-driver static-libs" >> /etc/portage/package.use/userver-deps | |
| echo "dev-db/postgresql static-libs" >> /etc/portage/package.use/userver-deps | |
| echo "dev-db/unixODBC static-libs" >> /etc/portage/package.use/userver-deps | |
| echo "dev-libs/jemalloc stats" >> /etc/portage/package.use/userver-deps | |
| # Heavy packages USE flags (binary-friendly) | |
| echo "dev-build/ninja -doc -test" > /etc/portage/package.use/ninja | |
| echo "dev-util/ccache static-c++ -doc -redis -test -verify-sig" > /etc/portage/package.use/ccache | |
| echo "dev-build/cmake ncurses -dap -doc -gui -test -verify-sig" > /etc/portage/package.use/cmake | |
| echo "llvm-core/llvm binutils-plugin libffi zstd -debug -debuginfod -doc -exegesis -libedit -test -verify-sig -xml -z3" > /etc/portage/package.use/llvm | |
| echo "llvm-core/clang extra pie static-analyzer -debug -doc -ieee-long-double -test -verify-sig -xml" > /etc/portage/package.use/clang | |
| echo "dev-libs/boost bzip2 context nls stacktrace zlib -debug -doc -icu -lzma -mpi -numpy -python -test -test-full -tools -zstd" > /etc/portage/package.use/boost | |
| echo "dev-db/postgresql icu lz4 nls numa pam readline server ssl static-libs systemd uring zlib zstd -debug -doc -kerberos -ldap -llvm -oauth -perl -python -selinux -tcl -uuid -xml" > /etc/portage/package.use/postgresql | |
| echo "dev-db/redis jemalloc ssl systemd -selinux -tcmalloc -test" > /etc/portage/package.use/redis | |
| echo "dev-db/mariadb backup pam perl server systemd -bindist -columnstore -cracklib -debug -extraengine -galera -innodb-lz4 -innodb-lzo -innodb-snappy -jdbc -jemalloc -kerberos -latin1 -mroonga -numa -odbc -oqgraph -profiling -rocksdb -s3 -selinux -sphinx -sst-mariabackup -sst-rsync -static -systemtap -tcmalloc -test -xml -yassl" > /etc/portage/package.use/mariadb | |
| echo "dev-libs/librdkafka lz4 ssl zstd -sasl -static-libs" > /etc/portage/package.use/librdkafka | |
| echo "dev-db/mongodb ssl tools -debug -kerberos -mongosh" > /etc/portage/package.use/mongodb | |
| ' | |
| # ---------- Accept MongoDB SSPL license ---------- | |
| - name: Accept MongoDB SSPL license | |
| run: | | |
| docker exec gentoo-test bash -lc ' | |
| mkdir -p /etc/portage/package.license | |
| echo "dev-db/mongodb SSPL-1" > /etc/portage/package.license/mongodb | |
| ' | |
| # ---------- Accept ~amd64 keywords ---------- | |
| - name: Accept ~amd64 keywords | |
| run: | | |
| docker exec gentoo-test bash -lc ' | |
| mkdir -p /etc/portage/package.accept_keywords | |
| echo "dev-cpp/amqp-cpp ~amd64" > /etc/portage/package.accept_keywords/amqp-cpp | |
| echo "=dev-db/mongodb-8.0.12 ~amd64" > /etc/portage/package.accept_keywords/mongodb | |
| ' | |
| # ---------- Configure ABI / PYTHON / CPU_FLAGS ---------- | |
| - name: Configure ABI / PYTHON / CPU_FLAGS | |
| run: | | |
| docker exec gentoo-test bash -lc ' | |
| mkdir -p /etc/portage/env | |
| mkdir -p /etc/portage/package.env | |
| # llvm | |
| echo "ABI_X86=\"64\"" > /etc/portage/env/llvm | |
| echo "LLVM_TARGETS=\"AArch64 AMDGPU ARM AVR BPF Hexagon Lanai LoongArch MSP430 Mips NVPTX PowerPC RISCV SPIRV Sparc SystemZ VE WebAssembly X86 XCore\"" >> /etc/portage/env/llvm | |
| echo "llvm-core/llvm llvm" > /etc/portage/package.env/llvm | |
| # clang | |
| echo "ABI_X86=\"64\"" > /etc/portage/env/clang | |
| echo "PYTHON_SINGLE_TARGET=\"python3_13\"" >> /etc/portage/env/clang | |
| echo "llvm-core/clang clang" > /etc/portage/package.env/clang | |
| # boost | |
| echo "ABI_X86=\"64\"" > /etc/portage/env/boost | |
| echo "PYTHON_TARGETS=\"python3_13\"" >> /etc/portage/env/boost | |
| echo "dev-libs/boost boost" > /etc/portage/package.env/boost | |
| # PostgreSQL | |
| echo "ABI_X86=\"64\"" > /etc/portage/env/postgresql | |
| echo "LLVM_SLOT=\"21\"" >> /etc/portage/env/postgresql | |
| echo "PYTHON_SINGLE_TARGET=\"python3_13\"" >> /etc/portage/env/postgresql | |
| echo "dev-db/postgresql postgresql" > /etc/portage/package.env/postgresql | |
| ' | |
| # ---------- Install base tools and sync userver overlay ---------- | |
| - name: Install base tools and sync userver overlay | |
| run: | | |
| docker exec gentoo-test bash -lc ' | |
| emerge -v app-eselect/eselect-repository dev-vcs/git | |
| eselect repository add userver-framework git https://github.com/userver-framework/userver-overlay.git || true | |
| git clone https://github.com/userver-framework/userver-overlay.git /var/db/repos/userver-framework || true | |
| ' | |
| # ---------- Install self-signed binhost certificate ---------- | |
| - name: Install binhost SSL certificate | |
| run: | | |
| docker exec gentoo-test bash -lc " | |
| mkdir -p /usr/local/share/ca-certificates/binhost | |
| printf '%s\n' \"${BINHOST_CERT}\" > /usr/local/share/ca-certificates/binhost/binhost.crt | |
| update-ca-certificates | |
| " | |
| # ---------- Remove all existing binhosts ---------- | |
| - name: Remove all existing binhosts | |
| run: | | |
| docker exec gentoo-test bash -lc ' | |
| rm -rf /etc/portage/binrepos.conf | |
| mkdir -p /etc/portage/binrepos.conf | |
| ' | |
| # ---------- Configure single IP-based binhost (echo lines) ---------- | |
| - name: Configure single IP-based binhost | |
| run: | | |
| docker exec gentoo-test bash -lc " | |
| echo '[custom-binhost]' > /etc/portage/binrepos.conf/custom-binhost.conf | |
| echo 'priority = 9999' >> /etc/portage/binrepos.conf/custom-binhost.conf | |
| echo 'sync-uri = https://${BINHOST_IP}:${BINHOST_PORT}/ci-binpkgs' >> /etc/portage/binrepos.conf/custom-binhost.conf | |
| " | |
| # ---------- Sync Gentoo tree ---------- | |
| - name: Sync gentoo tree again (webrsync) | |
| run: | | |
| docker exec gentoo-test bash -lc 'emerge-webrsync' | |
| # ---------- Install heavy packages (binpkg) ---------- | |
| - name: Install heavy packages from custom binhost | |
| run: | | |
| docker exec gentoo-test bash -lc ' | |
| FEATURES="binpkg-ignore-signature" \ | |
| emerge -v --getbinpkg --binpkg-respect-use=n --verbose \ | |
| dev-build/ninja \ | |
| dev-lang/go \ | |
| =dev-libs/libfmt-11.1.4 \ | |
| dev-build/cmake \ | |
| dev-util/ccache \ | |
| llvm-core/llvm \ | |
| llvm-core/clang \ | |
| dev-db/postgresql \ | |
| dev-db/redis \ | |
| dev-db/mariadb \ | |
| dev-libs/boost \ | |
| dev-db/mongodb \ | |
| dev-libs/librdkafka | |
| ' | |
| # ---------- Build userver ---------- | |
| - name: Build userver | |
| run: | | |
| docker exec gentoo-test bash -lc 'emerge -v dev-cpp/userver' | |
| # ---------- Create non-root user in container ---------- | |
| - name: Create non-root user in container | |
| run: | | |
| docker exec gentoo-test bash -lc ' | |
| set -e | |
| getent group tester >/dev/null || groupadd tester | |
| id tester || useradd -m -s /bin/bash -g tester tester | |
| mkdir -p /home/tester | |
| chown -R tester:tester /home/tester | |
| ' | |
| # ---------- Build and test userver service ---------- | |
| - name: Build and test userver service | |
| run: | | |
| docker exec --user tester gentoo-test bash -lc ' | |
| set -e | |
| cd /home/tester | |
| userver-create-service myservice | |
| cd myservice | |
| echo ">>> Build and run tests" | |
| make build-debug | |
| #make test-debug | |
| echo ">>> Start service for smoke test" | |
| make start-debug & | |
| PID=$! | |
| sleep 30 | |
| echo ">>> Smoke test: check HTTP endpoint" | |
| RESPONSE=$(curl -fs http://127.0.0.1:8080/hello?name=userver) | |
| echo "Response: $RESPONSE" | |
| if [ "$RESPONSE" != "Hello, userver!" ]; then | |
| echo "ERROR: unexpected response" | |
| exit 1 | |
| fi | |
| kill $PID || true | |
| wait $PID || true | |
| ' | |
| # ---------- Debug info ---------- | |
| - name: Debug info | |
| if: always() | |
| run: | | |
| docker exec gentoo-test bash -lc 'emerge -pv dev-cpp/userver' |