mirror of
https://github.com/pi-hole/pi-hole.git
synced 2025-12-19 18:08:26 +00:00
Alpine Linux tests
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>
This commit is contained in:
committed by
Michael Ziminsky (Z)
parent
0db48383ae
commit
d75dae788d
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@@ -73,6 +73,8 @@ jobs:
|
||||
fedora_40,
|
||||
fedora_41,
|
||||
fedora_42,
|
||||
alpine_3_21,
|
||||
alpine_3_22,
|
||||
]
|
||||
env:
|
||||
DISTRO: ${{matrix.distro}}
|
||||
|
||||
18
test/_alpine_3_21.Dockerfile
Normal file
18
test/_alpine_3_21.Dockerfile
Normal file
@@ -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 && \
|
||||
18
test/_alpine_3_22.Dockerfile
Normal file
18
test/_alpine_3_22.Dockerfile
Normal file
@@ -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 && \
|
||||
@@ -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
|
||||
|
||||
10
test/tox.alpine_3_21.ini
Normal file
10
test/tox.alpine_3_21.ini
Normal file
@@ -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
|
||||
10
test/tox.alpine_3_22.ini
Normal file
10
test/tox.alpine_3_22.ini
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user