Skip to content

Commit 1e1737e

Browse files
committed
fix(ci): isolate coverage artifacts from source audits
1 parent b0f8c7e commit 1e1737e

3 files changed

Lines changed: 32 additions & 27 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ jobs:
7272
working-directory: mailbox-app
7373
env:
7474
DJANGO_SETTINGS_MODULE: config.settings.test
75+
COVERAGE_FILE: ${{ runner.temp }}/mailstack-standalone.coverage
7576
run: pytest --cov=apps --cov-report=term-missing --cov-fail-under=85
7677

7778
- name: Contact service tests

docs/FORENSIC_FILE_INVENTORY.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@
7272
},
7373
{
7474
"kind": "text",
75-
"lines": 100,
75+
"lines": 101,
7676
"path": ".github/workflows/ci.yml",
77-
"sha256": "618cb17f101353d97d8e8d05879e7ff3a366f02c8ee7068355db219f734b5769",
78-
"size_bytes": 2946
77+
"sha256": "888c162494f787a0c0bc2b5b55c2aa66da13be41460a8e5bf9f2eee17c0b9ebe",
78+
"size_bytes": 3020
7979
},
8080
{
8181
"kind": "text",
@@ -4299,7 +4299,7 @@
42994299
},
43004300
{
43014301
"kind": "text",
4302-
"lines": 314,
4302+
"lines": 318,
43034303
"path": "scripts/forensic_audit.py",
43044304
"python": {
43054305
"classes": [],
@@ -4324,8 +4324,8 @@
43244324
],
43254325
"methods": []
43264326
},
4327-
"sha256": "9526c75f22a9ec7121bd14a28805beb884f9672dc66e638c27cb1e3f475752fa",
4328-
"size_bytes": 10819
4327+
"sha256": "53233de834b74e2d6ad7c0422361c7ada8b9087074c66104c40b4a4c617dcfd7",
4328+
"size_bytes": 11137
43294329
},
43304330
{
43314331
"kind": "text",
@@ -4519,7 +4519,7 @@
45194519
"shell_files": 13,
45204520
"shell_functions": 30,
45214521
"text_files": 347,
4522-
"total_bytes": 874720,
4523-
"total_text_lines": 20793
4522+
"total_bytes": 875112,
4523+
"total_text_lines": 20798
45244524
}
45254525
}

scripts/forensic_audit.py

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import re
1212
import subprocess
1313
import sys
14+
import tempfile
1415
from pathlib import Path
1516

1617
REQUIRED = {
@@ -221,7 +222,6 @@ def main() -> int:
221222
# Ensure the public-site template renders without leaving placeholder tokens.
222223
template_dir = root / "public-site/site-template"
223224
if template_dir.is_dir():
224-
import tempfile
225225
with tempfile.TemporaryDirectory(prefix="vibmail-public-render-") as temporary:
226226
destination = Path(temporary) / "site"
227227
code, output = run(
@@ -275,24 +275,28 @@ def main() -> int:
275275

276276
if args.full:
277277
app = root / "mailbox-app"
278-
commands = [
279-
([sys.executable, "-m", "pytest", "--cov=apps", "--cov-report=term-missing", "--cov-fail-under=85"], app, "PYTEST_COVERAGE", True),
280-
([sys.executable, "-m", "ruff", "check", "."], app, "RUFF", True),
281-
([sys.executable, "-m", "bandit", "-c", ".bandit", "-q", "-r", "apps", "config"], app, "BANDIT", True),
282-
([sys.executable, "manage.py", "makemigrations", "--check", "--dry-run", "--settings=config.settings.test"], app, "MIGRATION_DRIFT", True),
283-
([sys.executable, "manage.py", "check", "--settings=config.settings.test"], app, "DJANGO_CHECK", True),
284-
([sys.executable, "test_contact_app.py"], root / "public-site/contact_service", "CONTACT_TESTS", False),
285-
([sys.executable, "-m", "pip", "check"], root, "PIP_CHECK", False),
286-
]
287-
for command, cwd, label, django_environment in commands:
288-
env = os.environ.copy()
289-
if django_environment:
290-
env["DJANGO_SETTINGS_MODULE"] = "config.settings.test"
291-
else:
292-
env.pop("DJANGO_SETTINGS_MODULE", None)
293-
completed = subprocess.run(command, cwd=cwd, env=env, text=True, capture_output=True)
294-
if completed.returncode:
295-
findings.append(f"{label}:{(completed.stdout + completed.stderr).strip()}")
278+
with tempfile.TemporaryDirectory(prefix="mailstack-full-audit-") as temporary:
279+
coverage_file = Path(temporary) / ".coverage"
280+
commands = [
281+
([sys.executable, "-m", "pytest", "--cov=apps", "--cov-report=term-missing", "--cov-fail-under=85"], app, "PYTEST_COVERAGE", True),
282+
([sys.executable, "-m", "ruff", "check", "."], app, "RUFF", True),
283+
([sys.executable, "-m", "bandit", "-c", ".bandit", "-q", "-r", "apps", "config"], app, "BANDIT", True),
284+
([sys.executable, "manage.py", "makemigrations", "--check", "--dry-run", "--settings=config.settings.test"], app, "MIGRATION_DRIFT", True),
285+
([sys.executable, "manage.py", "check", "--settings=config.settings.test"], app, "DJANGO_CHECK", True),
286+
([sys.executable, "test_contact_app.py"], root / "public-site/contact_service", "CONTACT_TESTS", False),
287+
([sys.executable, "-m", "pip", "check"], root, "PIP_CHECK", False),
288+
]
289+
for command, cwd, label, django_environment in commands:
290+
env = os.environ.copy()
291+
if django_environment:
292+
env["DJANGO_SETTINGS_MODULE"] = "config.settings.test"
293+
else:
294+
env.pop("DJANGO_SETTINGS_MODULE", None)
295+
if label == "PYTEST_COVERAGE":
296+
env["COVERAGE_FILE"] = str(coverage_file)
297+
completed = subprocess.run(command, cwd=cwd, env=env, text=True, capture_output=True)
298+
if completed.returncode:
299+
findings.append(f"{label}:{(completed.stdout + completed.stderr).strip()}")
296300

297301
print("=== MAILSTACK FORENSIC SOURCE AUDIT ===")
298302
print(f"ROOT={root}")

0 commit comments

Comments
 (0)