From 7fd1f0ae312956ef545904a64b66adf29ace17ef Mon Sep 17 00:00:00 2001 From: downtownallday Date: Mon, 23 Aug 2021 11:40:22 -0400 Subject: [PATCH 01/14] Initial commit --- .github/workflows/run-tests.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/workflows/run-tests.yml diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 00000000..8c9a94cd --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,17 @@ +name: commit-tests +on: [push] +jobs: + # MiaB-LDAP connected to a remote Nextcloud + remote-nextcloud-docker: + runs-on: ubuntu-18.04 + container: + env: + - PRIMARY_HOSTNAME: box1.abc.com + - FEATURE_MUNIN: false + steps: + - uses: actions/checkout@v2 + - name: setup + run: tests/system-setup/remote-nextcloud-docker.sh upgrade basic + - name: test-runner + run: tests/runner.sh -dumpoutput -no-smtp-remote default remote-nextcloud upgrade-basic + From c855133c412e556a9f7134feecec1581a0062083 Mon Sep 17 00:00:00 2001 From: downtownallday Date: Mon, 23 Aug 2021 12:03:22 -0400 Subject: [PATCH 02/14] fix formatting --- .github/workflows/run-tests.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 8c9a94cd..4d240d62 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -4,10 +4,9 @@ jobs: # MiaB-LDAP connected to a remote Nextcloud remote-nextcloud-docker: runs-on: ubuntu-18.04 - container: - env: - - PRIMARY_HOSTNAME: box1.abc.com - - FEATURE_MUNIN: false + env: + PRIMARY_HOSTNAME: box1.abc.com + FEATURE_MUNIN: false steps: - uses: actions/checkout@v2 - name: setup From 5911f05f89801a34690c4cf471fdbb1afdc40d31 Mon Sep 17 00:00:00 2001 From: downtownallday Date: Mon, 23 Aug 2021 12:11:27 -0400 Subject: [PATCH 03/14] use sudo --- .github/workflows/run-tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 4d240d62..08837938 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -10,7 +10,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: setup - run: tests/system-setup/remote-nextcloud-docker.sh upgrade basic + run: sudo -E tests/system-setup/remote-nextcloud-docker.sh upgrade basic - name: test-runner - run: tests/runner.sh -dumpoutput -no-smtp-remote default remote-nextcloud upgrade-basic + run: sudo -E tests/runner.sh -dumpoutput -no-smtp-remote default remote-nextcloud upgrade-basic From d8c52fedc58584febdf54f8e86ebb6b6749e170d Mon Sep 17 00:00:00 2001 From: downtownallday Date: Mon, 23 Aug 2021 12:58:42 -0400 Subject: [PATCH 04/14] Try using nanasess/setup-php action to resolve issue where setup/webmail.sh, which runs the roundcubemail/bin/updatedb.sh script, fails with "Unsupported PHP version. Required PHP >= 5.4 and < 8.0" indicating that PHP >= 8.0 is actually installed! --- .github/workflows/run-tests.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 08837938..d283790a 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -9,6 +9,10 @@ jobs: FEATURE_MUNIN: false steps: - uses: actions/checkout@v2 + # without nanasess/setup-pup setup/webmail.sh returns "Unsupported PHP version. Required PHP >= 5.4 and < 8.0", which is generated by roundcubemail/program/include/iniset.php indicating that PHP >= 8.0 + - uses: nanasess/setup-php@master + with: + php-version: '7.2' - name: setup run: sudo -E tests/system-setup/remote-nextcloud-docker.sh upgrade basic - name: test-runner From bad57e8688b97f01011978be124ca1a9b15eec82 Mon Sep 17 00:00:00 2001 From: downtownallday Date: Mon, 23 Aug 2021 13:25:32 -0400 Subject: [PATCH 05/14] Try running update-alternatives for php 7.2 as before system-setup --- .github/workflows/run-tests.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index d283790a..46f941f6 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -10,9 +10,12 @@ jobs: steps: - uses: actions/checkout@v2 # without nanasess/setup-pup setup/webmail.sh returns "Unsupported PHP version. Required PHP >= 5.4 and < 8.0", which is generated by roundcubemail/program/include/iniset.php indicating that PHP >= 8.0 - - uses: nanasess/setup-php@master - with: - php-version: '7.2' + # However, setup/zpush.sh then fails to install package "php-xsl" with "E: Package 'php-xsl' has no installation candidate" + # - uses: nanasess/setup-php@master + # with: + # php-version: '7.2' + - name: update-system-php + run: sudo update-alternatives --set php /usr/bin/php7.2 - name: setup run: sudo -E tests/system-setup/remote-nextcloud-docker.sh upgrade basic - name: test-runner From 71d3b79965e123c50cc8fd4f50fcc7799496ff51 Mon Sep 17 00:00:00 2001 From: downtownallday Date: Mon, 23 Aug 2021 13:45:25 -0400 Subject: [PATCH 06/14] avoid installing php-xsl, which is a virtual package provided by php-xml on github images --- .github/workflows/run-tests.yml | 13 ++++++------- setup/zpush.sh | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 46f941f6..c56eedc2 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -7,15 +7,14 @@ jobs: env: PRIMARY_HOSTNAME: box1.abc.com FEATURE_MUNIN: false + # github specific: php-xsl is a virtual package provided by php-xml + PHP_XSL_PACKAGE: php-xml steps: - uses: actions/checkout@v2 - # without nanasess/setup-pup setup/webmail.sh returns "Unsupported PHP version. Required PHP >= 5.4 and < 8.0", which is generated by roundcubemail/program/include/iniset.php indicating that PHP >= 8.0 - # However, setup/zpush.sh then fails to install package "php-xsl" with "E: Package 'php-xsl' has no installation candidate" - # - uses: nanasess/setup-php@master - # with: - # php-version: '7.2' - - name: update-system-php - run: sudo update-alternatives --set php /usr/bin/php7.2 + # the github image comes preinstalled with multiple php versions + # and it sets the system php to the latest version. MIAB requires + # php 7.2 (the default on a new ubuntu 18 install) + - run: sudo update-alternatives --set php /usr/bin/php7.2 - name: setup run: sudo -E tests/system-setup/remote-nextcloud-docker.sh upgrade basic - name: test-runner diff --git a/setup/zpush.sh b/setup/zpush.sh index c1c00f2a..96b18d72 100755 --- a/setup/zpush.sh +++ b/setup/zpush.sh @@ -17,7 +17,7 @@ source /etc/mailinabox.conf # load global vars echo "Installing Z-Push (Exchange/ActiveSync server)..." apt_install \ - php-soap php-imap libawl-php php-xsl + php-soap php-imap libawl-php ${PHP_XSL_PACKAGE:-php-xsl} phpenmod -v php imap From f8a679b9c27f654e250d04cb4c63ca7080dc586d Mon Sep 17 00:00:00 2001 From: downtownallday Date: Mon, 23 Aug 2021 14:15:18 -0400 Subject: [PATCH 07/14] ensure system hostname is resolvable locally --- tests/lib/system.sh | 3 +++ tests/system-setup/setup-funcs.sh | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/lib/system.sh b/tests/lib/system.sh index 1b8cb147..10059f25 100644 --- a/tests/lib/system.sh +++ b/tests/lib/system.sh @@ -62,6 +62,9 @@ set_system_hostname() { local fqdn="${1:-$PRIMARY_HOSTNAME}" local host="$(awk -F. '{print $1}' <<< "$fqdn")" sed -i 's/^127\.0\.1\.1[ \t].*/127.0.1.1 '"$fqdn $host ip4-loopback/" /etc/hosts || return 1 + if ! /usr/bin/getent hosts "$fqdn" >/dev/null; then + return 2 + fi #hostname "$host" || return 1 #echo "$host" > /etc/hostname return 0 diff --git a/tests/system-setup/setup-funcs.sh b/tests/system-setup/setup-funcs.sh index 226c0f6a..28d35c90 100755 --- a/tests/system-setup/setup-funcs.sh +++ b/tests/system-setup/setup-funcs.sh @@ -69,7 +69,10 @@ dump_conf_files() { # init_test_system() { H2 "Update /etc/hosts" - set_system_hostname || die "Could not set hostname" + if ! set_system_hostname; then + dump_file "/etc/hosts" + die "Could not set hostname" + fi # update system time H2 "Set system time" From c29eb2fb23d54a8d4dd254cb0a7ce15620e8ee31 Mon Sep 17 00:00:00 2001 From: downtownallday Date: Mon, 23 Aug 2021 14:31:31 -0400 Subject: [PATCH 08/14] add 127.0.1.1 if it does not exist --- tests/lib/system.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/lib/system.sh b/tests/lib/system.sh index 10059f25..552ab86a 100644 --- a/tests/lib/system.sh +++ b/tests/lib/system.sh @@ -61,7 +61,14 @@ set_system_hostname() { # PRIMARY_HOSTNAME if no FQDN was given local fqdn="${1:-$PRIMARY_HOSTNAME}" local host="$(awk -F. '{print $1}' <<< "$fqdn")" - sed -i 's/^127\.0\.1\.1[ \t].*/127.0.1.1 '"$fqdn $host ip4-loopback/" /etc/hosts || return 1 + if ! grep '^127.0.1.1' /etc/hosts >/dev/null; then + # add it + echo "127.0.1.1 $fqdn $host" >> /etc/hosts || return 1 + else + # set it + sed -i 's/^127\.0\.1\.1[ \t].*/127.0.1.1 '"$fqdn $host ip4-loopback/" /etc/hosts || return 1 + fi + # ensure name is resolvable if ! /usr/bin/getent hosts "$fqdn" >/dev/null; then return 2 fi From 2a9fcd7101c8f9d286b3ba1ca4442c08dff8a698 Mon Sep 17 00:00:00 2001 From: downtownallday Date: Mon, 23 Aug 2021 15:00:31 -0400 Subject: [PATCH 09/14] add upgrade-from-upstream job --- .../{run-tests.yml => commit-tests.yml} | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) rename .github/workflows/{run-tests.yml => commit-tests.yml} (59%) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/commit-tests.yml similarity index 59% rename from .github/workflows/run-tests.yml rename to .github/workflows/commit-tests.yml index c56eedc2..04918b9e 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/commit-tests.yml @@ -20,3 +20,20 @@ jobs: - name: test-runner run: sudo -E tests/runner.sh -dumpoutput -no-smtp-remote default remote-nextcloud upgrade-basic + + # Upgrade from upstream install + upgrade-from-upstream: + runs-on: ubuntu-18.04 + env: + PRIMARY_HOSTNAME: box2.abc.com + UPSTREAM_TAG: main + PHP_XSL_PACKAGE: php-xml + steps: + - uses: actions/checkout@v2 + - run: sudo update-alternatives --set php /usr/bin/php7.2 + - run: sudo apt-get install -y php-xml + - name: setup + run: sudo -E tests/system-setup/upgrade-from-upstream.sh basic totpuser + - name: test-runner + run: sudo -E tests/runner.sh -dumpoutput -no-smtp-remote upgrade-basic upgrade-totpuser default + From 0c2c76a6dcc7d71c1b6a7528383bcb36370c094d Mon Sep 17 00:00:00 2001 From: downtownallday Date: Mon, 23 Aug 2021 15:17:33 -0400 Subject: [PATCH 10/14] Patch upstream to install php-xml instead of php-xsl --- .github/workflows/commit-tests.yml | 1 - tests/system-setup/upgrade-from-upstream.sh | 10 ++++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/commit-tests.yml b/.github/workflows/commit-tests.yml index 04918b9e..02cb8209 100644 --- a/.github/workflows/commit-tests.yml +++ b/.github/workflows/commit-tests.yml @@ -31,7 +31,6 @@ jobs: steps: - uses: actions/checkout@v2 - run: sudo update-alternatives --set php /usr/bin/php7.2 - - run: sudo apt-get install -y php-xml - name: setup run: sudo -E tests/system-setup/upgrade-from-upstream.sh basic totpuser - name: test-runner diff --git a/tests/system-setup/upgrade-from-upstream.sh b/tests/system-setup/upgrade-from-upstream.sh index 72e6057d..ed4713a0 100755 --- a/tests/system-setup/upgrade-from-upstream.sh +++ b/tests/system-setup/upgrade-from-upstream.sh @@ -78,6 +78,16 @@ upstream_install() { sed -i 's|\(.*include:.*zones\.conf.*\)|cat >> /etc/nsd/nsd.conf < Date: Mon, 23 Aug 2021 16:01:16 -0400 Subject: [PATCH 11/14] non-standard git remotes in github actions --- tests/lib/installed-state.sh | 2 +- tests/system-setup/upgrade-from-upstream.sh | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/lib/installed-state.sh b/tests/lib/installed-state.sh index f783a551..ce26da22 100644 --- a/tests/lib/installed-state.sh +++ b/tests/lib/installed-state.sh @@ -78,7 +78,7 @@ installed_state_compare() { local compare_type="all" source "$s2/info.txt" - if grep "mailinabox-ldap.git" <<<"$GIT_ORIGIN" >/dev/null; then + if [ -z "$GIT_ORIGIN" ] || grep "mailinabox-ldap.git" <<<"$GIT_ORIGIN" >/dev/null; then GIT_ORIGIN="" source "$s1/info.txt" if ! grep "mailinabox-ldap.git" <<<"$GIT_ORIGIN" >/dev/null; then diff --git a/tests/system-setup/upgrade-from-upstream.sh b/tests/system-setup/upgrade-from-upstream.sh index ed4713a0..b528198f 100755 --- a/tests/system-setup/upgrade-from-upstream.sh +++ b/tests/system-setup/upgrade-from-upstream.sh @@ -165,6 +165,8 @@ installed_state_capture "/tmp/state/miab-ldap" # compare states if ! installed_state_compare "/tmp/state/upstream" "/tmp/state/miab-ldap"; then + dump_file "/tmp/state/upstream/info.txt" + dump_file "/tmp/state/miab-ldap/info.txt" die "Upstream and upgraded states are different !" fi From be932af8139d359f9dff9fd461edb4314d309229 Mon Sep 17 00:00:00 2001 From: downtownallday Date: Mon, 23 Aug 2021 16:17:07 -0400 Subject: [PATCH 12/14] git remote url does not contain .git extension in github actions --- tests/lib/installed-state.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/lib/installed-state.sh b/tests/lib/installed-state.sh index ce26da22..8cc2c83b 100644 --- a/tests/lib/installed-state.sh +++ b/tests/lib/installed-state.sh @@ -78,7 +78,7 @@ installed_state_compare() { local compare_type="all" source "$s2/info.txt" - if [ -z "$GIT_ORIGIN" ] || grep "mailinabox-ldap.git" <<<"$GIT_ORIGIN" >/dev/null; then + if grep "mailinabox-ldap" <<<"$GIT_ORIGIN" >/dev/null; then GIT_ORIGIN="" source "$s1/info.txt" if ! grep "mailinabox-ldap.git" <<<"$GIT_ORIGIN" >/dev/null; then From 71526bc2947d13f44a0c58b77773b12ff9096f0c Mon Sep 17 00:00:00 2001 From: downtownallday Date: Mon, 23 Aug 2021 16:39:36 -0400 Subject: [PATCH 13/14] Add badge --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 890ef3e4..1b3578e8 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +![build](https://github.com/downtownallday/mailinabox-ldap/actions/workflows/commit-tests.yml/badge.svg) + # Mail-in-a-Box LDAP This is a version of [Mail-in-a-Box](https://mailinabox.email) with LDAP used as the user account database instead of sqlite. From 4f8697c07dd2e78dbe2de15fc198a9ff7e556429 Mon Sep 17 00:00:00 2001 From: downtownallday Date: Mon, 23 Aug 2021 16:57:40 -0400 Subject: [PATCH 14/14] change badge link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1b3578e8..d1a4c10c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -![build](https://github.com/downtownallday/mailinabox-ldap/actions/workflows/commit-tests.yml/badge.svg) +[![build](https://github.com/downtownallday/mailinabox-ldap/actions/workflows/commit-tests.yml/badge.svg)](https://github.com/downtownallday/mailinabox-ldap/actions) # Mail-in-a-Box LDAP This is a version of [Mail-in-a-Box](https://mailinabox.email) with LDAP used as the user account database instead of sqlite.