8 Commits
Author SHA1 Message Date
Djeex d051d9deb7 Fix CI unit test step with a dedicated Docker build stage
CI / build-and-scan (push) Successful in 34s
2026-08-22 11:11:41 +02:00
Djeex 267d9e52e0 Add unit tests for backup_first_start and run them in CI
CI / build-and-scan (push) Failing after 40s
2026-08-22 11:09:24 +02:00
Djeex 4753d80891 CI workflow with smoke test
CI / build-and-scan (push) Successful in 48s
2026-08-22 10:52:15 +02:00
Djeex 36611ef30b Add CI workflow
CI / build-and-scan (push) Successful in 17s
2026-08-22 10:00:59 +02:00
Djeex 5272796d71 python 3.13 2025-09-19 22:39:27 +00:00
Djeex 157a0f7830 Removed french discord link 2025-07-07 14:05:24 +00:00
Djeex 13379a3419 Merge branch 'wip-python' 2025-06-06 12:40:32 +00:00
Djeex fedbe1e227 Fixed wrong repo url 2025-06-06 12:39:59 +00:00
7 changed files with 121 additions and 7 deletions
+63
View File
@@ -0,0 +1,63 @@
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
- cron: "0 6 * * 1"
jobs:
build-and-scan:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build Docker image
run: |
docker build -t adguard-cidre:ci . 2>&1 | tee build.log
if grep -q "Building wheel for" build.log; then
echo "::warning::A dependency was built from source — check Python/Alpine compatibility"
fi
- name: Smoke test (syntax check)
run: |
docker run --rm --entrypoint python adguard-cidre:ci -c "
import ast
with open('blocklist_scheduler.py') as f:
source = f.read()
try:
ast.parse(source)
print('OK: syntax is valid')
except SyntaxError as e:
print(f'::error::Syntax error: {e}')
exit(1)
"
- name: Run unit tests
run: |
docker build --target test -t adguard-cidre:test .
docker run --rm adguard-cidre:test pytest -v
- name: Check deprecation warnings
run: |
docker run --rm adguard-cidre:ci python -W error::DeprecationWarning -c "import blocklist_scheduler" 2>&1 | tee deprecation.log || true
if grep -qi "deprecat" deprecation.log; then
echo "::warning::Deprecation warning detected, check logs"
fi
- name: Scan with Trivy (critical - blocking)
run: |
docker run --rm \
-e DOCKER_HOST=tcp://dockerhost:2375 \
--add-host=dockerhost:host-gateway \
aquasec/trivy:0.74.0 image --exit-code 1 --severity CRITICAL adguard-cidre:ci
- name: Scan with Trivy (high - informative)
run: |
docker run --rm \
-e DOCKER_HOST=tcp://dockerhost:2375 \
--add-host=dockerhost:host-gateway \
aquasec/trivy:0.74.0 image --exit-code 0 --severity HIGH adguard-cidre:ci
+2
View File
@@ -1,2 +1,4 @@
/adguard/*.log /adguard/*.log
/tmp/ /tmp/
__pycache__/
.pytest_cache/
+8 -1
View File
@@ -1,4 +1,4 @@
FROM python:3.11-alpine FROM python:3.13-alpine AS base
ENV TZ=Europe/Paris ENV TZ=Europe/Paris
@@ -11,4 +11,11 @@ WORKDIR /app
COPY blocklist_scheduler.py . COPY blocklist_scheduler.py .
FROM base AS test
COPY requirements-dev.txt .
RUN pip install --no-cache-dir -r requirements-dev.txt
COPY tests/ tests/
COPY pytest.ini .
FROM base
ENTRYPOINT ["python3", "blocklist_scheduler.py"] ENTRYPOINT ["python3", "blocklist_scheduler.py"]
+1 -6
View File
@@ -1,16 +1,11 @@
<h1 align="center"> Adguard CIDRE Sync</h1> <h1 align="center"> Adguard CIDRE Sync</h1>
<div align="center">
<a href="https://discord.gg/gxffg3GA96">
<img src="https://img.shields.io/badge/JV%20hardware-rejoindre-green?style=flat-square&logo=discord&logoColor=%23fff" alt="JV Hardware">
</a>
</div>
**Adguard CIDRE Sync** - A bot to synchronize adguard clients disallow list with countries CIDR list of your choices. **Adguard CIDRE Sync** - A bot to synchronize adguard clients disallow list with countries CIDR list of your choices.
> [!NOTE] > [!NOTE]
>_The code was partially written and structured using a generative AI._ >_The code was partially written and structured using a generative AI._
> >
>_Github repo is a mirror of https://git.djeex.fr/Djeex/nvidia-stock-bot. You'll find full package, history and release note there._ >_Github repo is a mirror of https://git.djeex.fr/Djeex/adguard-cidre. You'll find full package, history and release note there._
## Sommaire ## Sommaire
+2
View File
@@ -0,0 +1,2 @@
[pytest]
pythonpath = .
+4
View File
@@ -0,0 +1,4 @@
requests
pyyaml
schedule
pytest
+41
View File
@@ -0,0 +1,41 @@
import pytest
import blocklist_scheduler as bs
def test_backup_first_start_creates_backup_when_missing(tmp_path, monkeypatch):
adguard_yaml = tmp_path / "AdGuardHome.yaml"
adguard_yaml.write_text("original: config\n")
first_backup = tmp_path / "AdGuardHome.yaml.first-start.bak"
monkeypatch.setattr(bs, "ADGUARD_YAML", adguard_yaml)
monkeypatch.setattr(bs, "FIRST_BACKUP", first_backup)
bs.backup_first_start()
assert first_backup.read_text() == "original: config\n"
def test_backup_first_start_does_not_overwrite_existing_backup(tmp_path, monkeypatch):
adguard_yaml = tmp_path / "AdGuardHome.yaml"
adguard_yaml.write_text("new: config\n")
first_backup = tmp_path / "AdGuardHome.yaml.first-start.bak"
first_backup.write_text("pristine: original\n")
monkeypatch.setattr(bs, "ADGUARD_YAML", adguard_yaml)
monkeypatch.setattr(bs, "FIRST_BACKUP", first_backup)
bs.backup_first_start()
assert first_backup.read_text() == "pristine: original\n"
def test_backup_first_start_raises_if_adguard_yaml_missing(tmp_path, monkeypatch):
adguard_yaml = tmp_path / "AdGuardHome.yaml"
first_backup = tmp_path / "AdGuardHome.yaml.first-start.bak"
monkeypatch.setattr(bs, "ADGUARD_YAML", adguard_yaml)
monkeypatch.setattr(bs, "FIRST_BACKUP", first_backup)
with pytest.raises(FileNotFoundError):
bs.backup_first_start()