Compare commits
8
Commits
v1.3
...
d051d9deb7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d051d9deb7 | ||
|
|
267d9e52e0 | ||
|
|
4753d80891 | ||
|
|
36611ef30b | ||
|
|
5272796d71 | ||
|
|
157a0f7830 | ||
|
|
13379a3419 | ||
|
|
fedbe1e227 |
@@ -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
|
||||
@@ -1,2 +1,4 @@
|
||||
/adguard/*.log
|
||||
/tmp/
|
||||
__pycache__/
|
||||
.pytest_cache/
|
||||
|
||||
+8
-1
@@ -1,4 +1,4 @@
|
||||
FROM python:3.11-alpine
|
||||
FROM python:3.13-alpine AS base
|
||||
|
||||
ENV TZ=Europe/Paris
|
||||
|
||||
@@ -11,4 +11,11 @@ WORKDIR /app
|
||||
|
||||
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"]
|
||||
|
||||
@@ -1,16 +1,11 @@
|
||||
<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.
|
||||
|
||||
> [!NOTE]
|
||||
>_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
|
||||
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
[pytest]
|
||||
pythonpath = .
|
||||
@@ -0,0 +1,4 @@
|
||||
requests
|
||||
pyyaml
|
||||
schedule
|
||||
pytest
|
||||
@@ -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()
|
||||
Reference in New Issue
Block a user