]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
CI: run in Docker and add test service containers
authorMatthew Newton <matthew-git@newtoncomputing.co.uk>
Wed, 12 Oct 2022 21:52:15 +0000 (22:52 +0100)
committerMatthew Newton <matthew-git@newtoncomputing.co.uk>
Thu, 13 Oct 2022 21:18:37 +0000 (22:18 +0100)
- mariadb
- postgres
- redis
- 389ds

.github/workflows/ci.yml
scripts/ci/samba-setup.sh

index 7a8d1eccb252c588bb2e9076e3cd820e09b133f1..2247b24a3972d8cc1c76a58b07d197f8f6543f09 100644 (file)
@@ -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
index dd439266693d000a81252aaa5747842f944ab7ae..af5eb94920ed0f9906b8d283b57e4ce92338961c 100755 (executable)
@@ -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