From: Matthew Newton Date: Wed, 12 Oct 2022 21:52:15 +0000 (+0100) Subject: CI: run in Docker and add test service containers X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=077acfcf49ed841cba40f6b80e051b5c8da4d24c;p=thirdparty%2Ffreeradius-server.git CI: run in Docker and add test service containers - mariadb - postgres - redis - 389ds --- diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7a8d1eccb25..2247b24a397 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,6 +44,16 @@ jobs: runs-on: ${{ matrix.os.runs_on }} + container: + image: ${{ matrix.os.docker }} + # "privileged" is needed for Samba install + # "memory-swap -1" enables full use of host swap and may help + # with containers randomly quitting with "The operation was + # canceled" + options: >- + --privileged + --memory-swap -1 + strategy: fail-fast: false matrix: @@ -76,6 +86,57 @@ jobs: # changes. name: "master-${{ matrix.os.name }}-${{ matrix.env.NAME}}" + # The standard GitHub environment contains PostgreSQL and + # MySQL already. However when running on hosted GitHub runners + # we need to run separate database containers to provide these. + services: + mariadb: + image: mariadb + env: + MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: yes + ports: + - 3306:3306 + options: >- + --health-cmd="mysqladmin ping" + --health-interval 10s + --health-timeout 5s + --health-retries 10 + + postgres: + image: postgres + env: + POSTGRES_HOST_AUTH_METHOD: trust + ports: + - 5432:5432 + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + redis: + image: redis + ports: + - 6379:6379 + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + threeds: + image: 389ds/dirsrv + ports: + - 3389 + - 3636 + options: >- + -e DS_SUFFIX_NAME=dc=example,dc=com + -e DS_DM_PASSWORD=secret123 + --health-cmd "dsctl localhost healthcheck --check backends:localhost:search" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + steps: # Checkout, but defer pulling LFS objects until we've restored the cache diff --git a/scripts/ci/samba-setup.sh b/scripts/ci/samba-setup.sh index dd439266693..af5eb94920e 100755 --- a/scripts/ci/samba-setup.sh +++ b/scripts/ci/samba-setup.sh @@ -1,21 +1,23 @@ #!/bin/sh -# Remove previous samba config and stop all services -sudo systemctl stop smbd -sudo systemctl disable smbd -sudo systemctl mask smbd - -sudo systemctl stop nmbd -sudo systemctl disable nmbd -sudo systemctl mask nmbd +if [ "$USE_DOCKER" != "true" ]; then + # Remove previous samba config and stop all services + sudo systemctl stop smbd + sudo systemctl disable smbd + sudo systemctl mask smbd + + sudo systemctl stop nmbd + sudo systemctl disable nmbd + sudo systemctl mask nmbd + + # Enable the AD-DC samba service + sudo systemctl unmask samba-ad-dc + sudo systemctl enable samba-ad-dc + sudo systemctl stop samba-ad-dc +fi sudo rm /etc/samba/smb.conf -# Enable the AD-DC samba service -sudo systemctl unmask samba-ad-dc -sudo systemctl enable samba-ad-dc -sudo systemctl stop samba-ad-dc - # Remove other samba data for DIR in $(/usr/sbin/smbd -b | awk '/LOCKDIR|STATEDIR|CACHEDIR|PRIVATE_DIR/{print $2}'); do sudo rm -rf "$DIR"/* @@ -46,4 +48,8 @@ fi sudo sed -i 's/\[global\]/\[global\]\n\tldap server require strong auth = no/' /etc/samba/smb.conf # Start the domain controller -sudo systemctl start samba-ad-dc +if [ "$USE_DOCKER" != "true" ]; then + sudo systemctl start samba-ad-dc +else + /usr/sbin/samba +fi