]> git.feebdaed.xyz Git - 0xmirror/pi-hole.git/commitdiff
Alpine Linux tests
authorRob Gill <rrobgill@protonmail.com>
Tue, 15 Apr 2025 06:18:46 +0000 (16:18 +1000)
committerMichael Ziminsky (Z) <mgziminsky@users.noreply.github.com>
Sat, 16 Aug 2025 21:47:54 +0000 (21:47 +0000)
Add Dockerfile and corresponding tox file to add alpine linux 3.21 & 3.22 to the test suite
Add apk as another package manager in the automated install tests
Use short switches for su command as busybox's su does not accept long switches here
Add Alpine test to github workflow

Signed-off-by: Michael Ziminsky (Z) <mgziminsky@users.noreply.github.com>
.github/workflows/test.yml
test/_alpine_3_21.Dockerfile [new file with mode: 0644]
test/_alpine_3_22.Dockerfile [new file with mode: 0644]
test/test_any_automated_install.py
test/tox.alpine_3_21.ini [new file with mode: 0644]
test/tox.alpine_3_22.ini [new file with mode: 0644]

index ee61c30a196f12a2fd4fad1ef13a8a4ee9efb6ca..492e131b028431d01fa1074b0c5e460120ab2199 100644 (file)
@@ -73,6 +73,8 @@ jobs:
             fedora_40,
             fedora_41,
             fedora_42,
+            alpine_3_21,
+            alpine_3_22,
           ]
     env:
       DISTRO: ${{matrix.distro}}
diff --git a/test/_alpine_3_21.Dockerfile b/test/_alpine_3_21.Dockerfile
new file mode 100644 (file)
index 0000000..d7b88f2
--- /dev/null
@@ -0,0 +1,18 @@
+FROM alpine:3.21
+
+ENV GITDIR=/etc/.pihole
+ENV SCRIPTDIR=/opt/pihole
+RUN sed -i 's/#\(.*\/community\)/\1/' /etc/apk/repositories
+RUN apk --no-cache add bash coreutils curl git jq openrc shadow
+
+RUN mkdir -p $GITDIR $SCRIPTDIR /etc/pihole
+ADD . $GITDIR
+RUN cp $GITDIR/advanced/Scripts/*.sh $GITDIR/gravity.sh $GITDIR/pihole $GITDIR/automated\ install/*.sh $GITDIR/advanced/Scripts/COL_TABLE $SCRIPTDIR/
+ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$SCRIPTDIR
+
+RUN true && \
+    chmod +x $SCRIPTDIR/*
+
+ENV SKIP_INSTALL=true
+
+#sed '/# Start the installer/Q' /opt/pihole/basic-install.sh > /opt/pihole/stub_basic-install.sh && \
diff --git a/test/_alpine_3_22.Dockerfile b/test/_alpine_3_22.Dockerfile
new file mode 100644 (file)
index 0000000..25beb4e
--- /dev/null
@@ -0,0 +1,18 @@
+FROM alpine:3.22
+
+ENV GITDIR=/etc/.pihole
+ENV SCRIPTDIR=/opt/pihole
+RUN sed -i 's/#\(.*\/community\)/\1/' /etc/apk/repositories
+RUN apk --no-cache add bash coreutils curl git jq openrc shadow
+
+RUN mkdir -p $GITDIR $SCRIPTDIR /etc/pihole
+ADD . $GITDIR
+RUN cp $GITDIR/advanced/Scripts/*.sh $GITDIR/gravity.sh $GITDIR/pihole $GITDIR/automated\ install/*.sh $GITDIR/advanced/Scripts/COL_TABLE $SCRIPTDIR/
+ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$SCRIPTDIR
+
+RUN true && \
+    chmod +x $SCRIPTDIR/*
+
+ENV SKIP_INSTALL=true
+
+#sed '/# Start the installer/Q' /opt/pihole/basic-install.sh > /opt/pihole/stub_basic-install.sh && \
index cf4b454d93918ec9212ffea5ce61b9c74737d932..0a561b362c30b48c67dd593e7bf6d83672efca9f 100644 (file)
@@ -22,6 +22,7 @@ def test_supported_package_manager(host):
     # break supported package managers
     host.run("rm -rf /usr/bin/apt-get")
     host.run("rm -rf /usr/bin/rpm")
+    host.run("rm -rf /sbin/apk")
     package_manager_detect = host.run(
         """
     source /opt/pihole/basic-install.sh
@@ -77,10 +78,21 @@ def test_installPihole_fresh_install_readableFiles(host):
         },
         host,
     )
+    mock_command_2(
+        "rc-service",
+        {
+            "rc-service pihole-FTL enable": ("", "0"),
+            "rc-service pihole-FTL restart": ("", "0"),
+            "rc-service pihole-FTL start": ("", "0"),
+            "*": ('echo "rc-service call with $@"', "0"),
+        },
+        host,
+    )
     # try to install man
     host.run("command -v apt-get > /dev/null && apt-get install -qq man")
     host.run("command -v dnf > /dev/null && dnf install -y man")
     host.run("command -v yum > /dev/null && yum install -y man")
+    host.run("command -v apk > /dev/null && apk add mandoc man-pages")
     # Workaround to get FTLv6 installed until it reaches master branch
     host.run('echo "' + FTL_BRANCH + '" > /etc/pihole/ftlbranch')
     install = host.run(
@@ -103,7 +115,7 @@ def test_installPihole_fresh_install_readableFiles(host):
         maninstalled = False
     piholeuser = "pihole"
     exit_status_success = 0
-    test_cmd = 'su --shell /bin/bash --command "test -{0} {1}" -p {2}'
+    test_cmd = 'su -s /bin/bash -c "test -{0} {1}" -p {2}'
     # check files in /etc/pihole for read, write and execute permission
     check_etc = test_cmd.format("r", "/etc/pihole", piholeuser)
     actual_rc = host.run(check_etc).rc
diff --git a/test/tox.alpine_3_21.ini b/test/tox.alpine_3_21.ini
new file mode 100644 (file)
index 0000000..b0465f6
--- /dev/null
@@ -0,0 +1,10 @@
+[tox]
+envlist = py3
+
+[testenv:py3]
+allowlist_externals = docker
+deps = -rrequirements.txt
+setenv =
+    COLUMNS=120
+commands = docker buildx build --load --progress plain -f _alpine_3_21.Dockerfile -t pytest_pihole:test_container ../
+           pytest {posargs:-vv -n auto} ./test_any_automated_install.py ./test_any_utils.py
diff --git a/test/tox.alpine_3_22.ini b/test/tox.alpine_3_22.ini
new file mode 100644 (file)
index 0000000..38f66c4
--- /dev/null
@@ -0,0 +1,10 @@
+[tox]
+envlist = py3
+
+[testenv:py3]
+allowlist_externals = docker
+deps = -rrequirements.txt
+setenv =
+    COLUMNS=120
+commands = docker buildx build --load --progress plain -f _alpine_3_22.Dockerfile -t pytest_pihole:test_container ../
+           pytest {posargs:-vv -n auto} ./test_any_automated_install.py ./test_any_utils.py