Merge pull request #1915 from pi-hole/development

Development -> master
This commit is contained in:
Adam Warner
2025-10-25 11:15:21 +01:00
committed by GitHub
25 changed files with 274 additions and 251 deletions

20
.editorconfig Normal file
View File

@@ -0,0 +1,20 @@
# EditorConfig is awesome: https://editorconfig.org/
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = tab
tab_width = 4
charset = utf-8
trim_trailing_whitespace = true
[*.yml]
tab_width = 2
[*.md]
tab_width = 2

View File

@@ -12,7 +12,7 @@ on:
env: env:
dockerhub: ${{ secrets.DOCKERHUB_NAMESPACE }}/pihole dockerhub: ${{ secrets.DOCKERHUB_NAMESPACE }}/pihole
ghcr: ghcr.io/${{ github.repository_owner }}/pihole ghcr: ghcr.io/${{ github.repository_owner }}/pihole
components_branch: ${{ github.event_name == 'schedule' && 'development' || 'master' }} components_branch: ${{ github.event_name == 'release' && 'master' || 'development' }}
jobs: jobs:
build: build:
@@ -40,19 +40,22 @@ jobs:
platform=${{ matrix.platform }} platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
- name: Checkout Repo - &checkout-repo
name: Checkout Repo
if: github.event_name != 'schedule' if: github.event_name != 'schedule'
uses: actions/checkout@v4 uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #v5.0.0
- name: Checkout dev branch if scheduled - &checkout-dev
name: Checkout dev branch if scheduled
if: github.event_name == 'schedule' if: github.event_name == 'schedule'
uses: actions/checkout@v4 uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #v5.0.0
with: with:
ref: development ref: development
- name: Docker meta - &docker-meta
name: Docker meta
id: meta id: meta
uses: docker/metadata-action@v5 uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f #v5.8.0
with: with:
github-token: ${{ secrets.GITHUB_TOKEN }} github-token: ${{ secrets.GITHUB_TOKEN }}
images: | images: |
@@ -62,35 +65,37 @@ jobs:
latest=${{ startsWith(github.ref, 'refs/tags/') }} latest=${{ startsWith(github.ref, 'refs/tags/') }}
tags: | tags: |
type=schedule,pattern=nightly type=schedule,pattern=nightly
type=ref,event=branch,enable=${{ github.event_name != 'schedule' }} type=raw,value=nightly,enable=${{ github.event_name == 'push' }}
type=ref,event=tag type=ref,event=tag
- - &login-dockerhub
name: Login to Docker Hub name: Login to Docker Hub
uses: docker/login-action@v3 uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef #v3.6.0
with: with:
registry: docker.io registry: docker.io
username: ${{ secrets.DOCKERHUB_USER }} username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_PASS }} password: ${{ secrets.DOCKERHUB_PASS }}
-
- &login-ghcr
name: Login to GitHub Container Registry name: Login to GitHub Container Registry
uses: docker/login-action@v3 uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef #v3.6.0
with: with:
registry: ghcr.io registry: ghcr.io
username: ${{ github.repository_owner }} username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }} password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 #v3.6.0
with: with:
platforms: ${{ matrix.platform}} platforms: ${{ matrix.platform}}
- name: Set up Docker Buildx - &setup-buildx
uses: docker/setup-buildx-action@v3 name: Set up Docker Buildx
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 #v3.11.1
- name: Build container and push by digest - name: Build container and push by digest
id: build id: build
uses: docker/build-push-action@v6 uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 #v6.18.0
with: with:
context: ./src/ context: ./src/
platforms: ${{ matrix.platform }} platforms: ${{ matrix.platform }}
@@ -111,7 +116,7 @@ jobs:
touch "/tmp/digests/${digest_docker#sha256:}" touch "/tmp/digests/${digest_docker#sha256:}"
- name: Upload digest - name: Upload digest
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 #v5.0.0
with: with:
name: digests-${{ env.PLATFORM_PAIR }} name: digests-${{ env.PLATFORM_PAIR }}
path: /tmp/digests/* path: /tmp/digests/*
@@ -126,55 +131,20 @@ jobs:
needs: needs:
- build - build
steps: steps:
- name: Checkout Repo - *checkout-repo
if: github.event_name != 'schedule' - *checkout-dev
uses: actions/checkout@v4
- name: Checkout dev branch if scheduled
if: github.event_name == 'schedule'
uses: actions/checkout@v4
with:
ref: development
- name: Download digests - name: Download digests
uses: actions/download-artifact@v4 uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 #v6.0.0
with: with:
path: /tmp/digests path: /tmp/digests
pattern: digests-* pattern: digests-*
merge-multiple: true merge-multiple: true
- name: Set up Docker Buildx - *setup-buildx
uses: docker/setup-buildx-action@v3 - *docker-meta
- *login-dockerhub
- name: Docker meta - *login-ghcr
id: meta
uses: docker/metadata-action@v5
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
images: |
${{ env.dockerhub }}
${{ env.ghcr }}
flavor: |
latest=${{ startsWith(github.ref, 'refs/tags/') }}
tags: |
type=schedule,pattern=nightly
type=ref,event=branch,enable=${{ github.event_name != 'schedule' }}
type=ref,event=tag
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_PASS }}
-
name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create manifest list and push (DockerHub and GitHub Container Registry) - name: Create manifest list and push (DockerHub and GitHub Container Registry)
working-directory: /tmp/digests working-directory: /tmp/digests

View File

@@ -25,13 +25,13 @@ jobs:
CI_ARCH: ${{ matrix.platform }} CI_ARCH: ${{ matrix.platform }}
steps: steps:
- name: Checkout Repo - name: Checkout Repo
uses: actions/checkout@v4 uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #v5.0.0
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 #v3.6.0
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v5.6.0 uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c #v6.0.0
with: with:
python-version: "3.13" python-version: "3.13"

View File

@@ -10,9 +10,9 @@ jobs:
steps: steps:
- -
name: Checkout repository name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #v5.0.0
- -
name: Spell-Checking name: Spell-Checking
uses: codespell-project/actions-codespell@master uses: codespell-project/actions-codespell@406322ec52dd7b488e48c1c4b82e2a8b3a1bf630 #v2.1
with: with:
ignore_words_file: .codespellignore ignore_words_file: .codespellignore

18
.github/workflows/editorconfig.yml vendored Normal file
View File

@@ -0,0 +1,18 @@
name: Editorconfig-Checker
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
jobs:
editorconfig-checker:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #v5.0.0
- name: Get editorconfig-checker
uses: editorconfig-checker/action-editorconfig-checker@4b6cd6190d435e7e084fb35e36a096e98506f7b9 # tag v2. is really out of date
- name: Run editorconfig-checker
run: editorconfig-checker

View File

@@ -1,6 +1,8 @@
name: housekeeping name: Remove untagged images from registry
on: on:
workflow_dispatch: workflow_dispatch:
schedule:
- cron: "0 0 * * *"
jobs: jobs:
housekeeping: housekeeping:
@@ -8,7 +10,7 @@ jobs:
steps: steps:
- -
name: Delete all containers from repository without tags name: Delete all containers from repository without tags
uses: Chizkiyahu/delete-untagged-ghcr-action@v6 uses: Chizkiyahu/delete-untagged-ghcr-action@68758dd8caf1d9dbaed1fe9cc1a1f8fcea1c4cf0 #v6.1.0
with: with:
token: ${{ secrets.PAT_TOKEN }} token: ${{ secrets.PAT_TOKEN }}
repository_owner: ${{ github.repository_owner }} repository_owner: ${{ github.repository_owner }}

View File

@@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Check if PRs are have merge conflicts - name: Check if PRs are have merge conflicts
uses: eps1lon/actions-label-merge-conflict@v3.0.3 uses: eps1lon/actions-label-merge-conflict@1df065ebe6e3310545d4f4c4e862e43bdca146f0 #v3.0.3
with: with:
dirtyLabel: "Merge Conflict" dirtyLabel: "Merge Conflict"
repoToken: "${{ secrets.GITHUB_TOKEN }}" repoToken: "${{ secrets.GITHUB_TOKEN }}"

View File

@@ -17,7 +17,7 @@ jobs:
issues: write issues: write
steps: steps:
- uses: actions/stale@v9.1.0 - uses: actions/stale@5f858e3efba33a5ca4407a664cc011ad407f2008 #v10.1.0
with: with:
repo-token: ${{ secrets.GITHUB_TOKEN }} repo-token: ${{ secrets.GITHUB_TOKEN }}
days-before-stale: 30 days-before-stale: 30
@@ -41,7 +41,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #v5.0.0
- name: Remove 'stale' label - name: Remove 'stale' label
run: gh issue edit ${{ github.event.issue.number }} --remove-label ${{ env.stale_label }} run: gh issue edit ${{ github.event.issue.number }} --remove-label ${{ env.stale_label }}
env: env:

View File

@@ -17,7 +17,7 @@ jobs:
pull-requests: write pull-requests: write
steps: steps:
- uses: actions/stale@v9.1.0 - uses: actions/stale@5f858e3efba33a5ca4407a664cc011ad407f2008 #v10.1.0
with: with:
repo-token: ${{ secrets.GITHUB_TOKEN }} repo-token: ${{ secrets.GITHUB_TOKEN }}
# Do not automatically mark PR/issue as stale # Do not automatically mark PR/issue as stale

View File

@@ -11,7 +11,7 @@ jobs:
name: Syncing branches name: Syncing branches
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #v5.0.0
- name: Opening pull request - name: Opening pull request
run: gh pr create -B development -H master --title 'Sync master back into development' --body 'Created by Github action' --label 'internal' run: gh pr create -B development -H master --title 'Sync master back into development' --body 'Created by Github action' --label 'internal'
env: env:

2
.gitignore vendored
View File

@@ -13,6 +13,8 @@ docker-compose.yml
etc-dnsmasq.d/ etc-dnsmasq.d/
etc-pihole/ etc-pihole/
var-log/ var-log/
.vscode/
.pytest_cache/
# WIP/test stuff # WIP/test stuff
doco.yml doco.yml

View File

@@ -1,5 +0,0 @@
{
"github-actions.workflows.pinned.workflows": [
".github/workflows/v6-alpine-play.yml"
]
}

View File

@@ -200,12 +200,11 @@ Release notes will always contain full details of changes in the container, incl
| tag | description | tag | description
|---------------------|--------------------------------------------------------------------------------------------------------------------------------------------| |---------------------|--------------------------------------------------------------------------------------------------------------------------------------------|
| `latest` | Always latest release | | `latest` | Always the latest release |
| `2022.04.0` | Date-based release | | `2022.04.0` | Date-based release |
| `2022.04.1` | Second release in a given month | | `2022.04.1` | Second release in a given month |
| `development` | Similar to `latest`, but for the development branch (pushed occasionally) |
| `*beta` | Early beta releases of upcoming versions - here be dragons | | `*beta` | Early beta releases of upcoming versions - here be dragons |
| `nightly` | Like `development` but pushed every night and pulls from the latest `development` branches of the core Pi-hole components (Pi-hole, web, FTL) | | `nightly` | Built and pushed whenever there are changes on the `development` branch and additionally produced by the scheduled nightly job. These are the most experimental development images and may change frequently |
## Upgrading, Persistence, and Customizations ## Upgrading, Persistence, and Customizations

View File

@@ -90,7 +90,8 @@ RUN cd /etc/.pihole && \
install -Dm755 -d /var/log/pihole && \ install -Dm755 -d /var/log/pihole && \
install -Dm755 -d /var/lib/logrotate && \ install -Dm755 -d /var/lib/logrotate && \
install -Dm755 -t /usr/local/bin pihole && \ install -Dm755 -t /usr/local/bin pihole && \
install -Dm644 ./advanced/bash-completion/pihole /etc/bash_completion.d/pihole && \ install -Dm644 ./advanced/bash-completion/pihole.bash /etc/bash_completion.d/pihole && \
install -Dm644 ./advanced/bash-completion/pihole-ftl.bash /etc/bash_completion.d/pihole-FTL && \
install -T -m 0755 ./advanced/Templates/pihole-FTL-prestart.sh /opt/pihole/pihole-FTL-prestart.sh && \ install -T -m 0755 ./advanced/Templates/pihole-FTL-prestart.sh /opt/pihole/pihole-FTL-prestart.sh && \
install -T -m 0755 ./advanced/Templates/pihole-FTL-poststop.sh /opt/pihole/pihole-FTL-poststop.sh && \ install -T -m 0755 ./advanced/Templates/pihole-FTL-poststop.sh /opt/pihole/pihole-FTL-poststop.sh && \
addgroup -S pihole -g ${PIHOLE_GID} && adduser -S pihole -G pihole -u ${PIHOLE_UID} && \ addgroup -S pihole -g ${PIHOLE_GID} && adduser -S pihole -G pihole -u ${PIHOLE_UID} && \

View File

@@ -104,12 +104,10 @@ migrate_gravity() {
echo " [i] Gravity migration checks" echo " [i] Gravity migration checks"
gravityDBfile=$(getFTLConfigValue files.gravity) gravityDBfile=$(getFTLConfigValue files.gravity)
if [[ -z "${PYTEST}" ]]; then
if [[ ! -f /etc/pihole/adlists.list ]]; then if [[ ! -f /etc/pihole/adlists.list ]]; then
echo " [i] No adlist file found, creating one with a default blocklist" echo " [i] No adlist file found, creating one with a default blocklist"
echo "https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts" >/etc/pihole/adlists.list echo "https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts" >/etc/pihole/adlists.list
fi fi
fi
if [ ! -f "${gravityDBfile}" ]; then if [ ! -f "${gravityDBfile}" ]; then
echo " [i] ${gravityDBfile} does not exist (Likely due to a fresh volume). This is a required file for Pi-hole to operate." echo " [i] ${gravityDBfile} does not exist (Likely due to a fresh volume). This is a required file for Pi-hole to operate."

View File

@@ -75,10 +75,13 @@ start() {
sleep 0.5 sleep 0.5
done done
# Wait until the FTL log contains the "FTL started" message before continuing # Wait until the FTL log contains the "FTL started" message before continuing, timeout after 10 seconds
while ! grep -q '########## FTL started' /var/log/pihole/FTL.log; do # exit if we do not find it
sleep 0.5 pihole-FTL wait-for '########## FTL started' /var/log/pihole/FTL.log 10 0 > /dev/null
done if [ $? -ne 0 ]; then
echo " [✗] FTL did not start - stopping container"
exit 1
fi
pihole updatechecker pihole updatechecker
local versionsOutput local versionsOutput
@@ -143,12 +146,6 @@ stop() {
echo " https://docs.docker.com/engine/containers/start-containers-automatically/#use-a-restart-policy" echo " https://docs.docker.com/engine/containers/start-containers-automatically/#use-a-restart-policy"
echo "" echo ""
# If we are running pytest, keep the container alive for a little longer
# to allow the tests to complete
if [[ ${PYTEST} ]]; then
sleep 10
fi
exit "${FTL_EXIT_CODE}" exit "${FTL_EXIT_CODE}"
} }

View File

@@ -1,6 +1,6 @@
pytest == 8.4.1 pytest == 8.4.2
pytest-testinfra == 10.2.2 pytest-testinfra == 10.2.2
pytest-clarity == 1.0.1 pytest-clarity == 1.0.1
tox == 4.28.4 tox == 4.32.0
# Not adding pytest-xdist as using pytest with n > 1 cores # Not adding pytest-xdist as using pytest with n > 1 cores
# causes random issues with the emulated architectures # causes random issues with the emulated architectures

View File

@@ -45,10 +45,6 @@ def docker(request):
for env_var in env_vars: for env_var in env_vars:
cmd.extend(["-e", env_var]) cmd.extend(["-e", env_var])
# ensure PYTEST=1 is set
if not any("PYTEST=1" in arg for arg in cmd):
cmd.extend(["-e", "PYTEST=1"])
# add default TZ if not already set # add default TZ if not already set
if not any("TZ=" in arg for arg in cmd): if not any("TZ=" in arg for arg in cmd):
cmd.extend(["-e", 'TZ="Europe/London"']) cmd.extend(["-e", 'TZ="Europe/London"'])

View File

@@ -49,19 +49,44 @@ def test_pihole_ftl_architecture(docker):
assert platform in func.stdout assert platform in func.stdout
# Wait 5 seconds for startup, then kill the start.sh script # Wait for FTL to start up, then stop the container gracefully
# Finally, grep the FTL log to see if it has been shut down cleanly # Finally, check the container logs to see if FTL was shut down cleanly
def test_pihole_ftl_clean_shutdown(docker): def test_pihole_ftl_starts_and_shuts_down_cleanly(docker):
func = docker.run( import subprocess
""" import time
sleep 5
killall --signal 15 start.sh # Get the container ID from the docker fixture
sleep 5 container_id = docker.backend.name
grep 'terminated' /var/log/pihole/FTL.log
""" # Wait for FTL to fully start up by checking logs
max_wait_time = 60 # Maximum wait time in seconds
start_time = time.time()
ftl_started = False
while time.time() - start_time < max_wait_time:
result = subprocess.run(
["docker", "logs", container_id], capture_output=True, text=True
) )
assert "INFO: ########## FTL terminated after" in func.stdout
assert "(code 0)" in func.stdout if "########## FTL started" in result.stdout:
ftl_started = True
break
time.sleep(1) # Check every second
assert ftl_started, f"FTL did not start within {max_wait_time} seconds"
# Stop the container gracefully (sends SIGTERM)
subprocess.run(["docker", "stop", container_id], check=True)
# Get the container logs
result = subprocess.run(
["docker", "logs", container_id], capture_output=True, text=True
)
# Check for clean shutdown messages in the logs
assert "INFO: ########## FTL terminated after" in result.stdout
assert "(code 0)" in result.stdout
def test_cronfile_valid(docker): def test_cronfile_valid(docker):