mirror of
https://github.com/kevinveenbirkenbach/homepage.veen.world.git
synced 2026-04-07 05:12:19 +00:00
feat: migrate to pyproject.toml, add test suites, split CI workflows
- Replace requirements.txt with pyproject.toml for modern Python packaging - Add unit, integration, lint and security test suites under tests/ - Add utils/export_runtime_requirements.py and utils/check_hadolint_sarif.py - Split monolithic CI into reusable lint.yml, security.yml and tests.yml - Refactor ci.yml to orchestrate reusable workflows; publish on semver tag only - Modernize Dockerfile: pin python:3.12-slim, install via pyproject.toml - Expand Makefile with lint, security, test and CI targets - Add test-e2e via act with portfolio container stop/start around run - Fix navbar_logo_visibility.spec.js: win.fullscreen() → win.enterFullscreen() - Set use_reloader=False in app.run() to prevent double-start in CI - Add app/core.* and build artifacts to .gitignore - Fix apt-get → sudo apt-get in tests.yml e2e job - Fix pip install --ignore-installed to handle stale act cache Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1
tests/integration/__init__.py
Normal file
1
tests/integration/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
54
tests/integration/test_python_packaging.py
Normal file
54
tests/integration/test_python_packaging.py
Normal file
@@ -0,0 +1,54 @@
|
||||
import tomllib
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
class TestPythonPackaging(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
self.repo_root = Path(__file__).resolve().parents[2]
|
||||
self.pyproject_path = self.repo_root / "pyproject.toml"
|
||||
|
||||
with self.pyproject_path.open("rb") as handle:
|
||||
self.pyproject = tomllib.load(handle)
|
||||
|
||||
def test_pyproject_defines_build_system_and_runtime_dependencies(self):
|
||||
build_system = self.pyproject["build-system"]
|
||||
project = self.pyproject["project"]
|
||||
|
||||
self.assertEqual(build_system["build-backend"], "setuptools.build_meta")
|
||||
self.assertIn("setuptools>=69", build_system["requires"])
|
||||
self.assertGreaterEqual(
|
||||
set(project["dependencies"]),
|
||||
{"flask", "pyyaml", "requests"},
|
||||
)
|
||||
self.assertEqual(project["requires-python"], ">=3.12")
|
||||
|
||||
def test_pyproject_defines_dev_dependencies_and_package_contents(self):
|
||||
project = self.pyproject["project"]
|
||||
setuptools_config = self.pyproject["tool"]["setuptools"]
|
||||
package_find = setuptools_config["packages"]["find"]
|
||||
package_data = setuptools_config["package-data"]["app"]
|
||||
|
||||
self.assertGreaterEqual(
|
||||
set(project["optional-dependencies"]["dev"]),
|
||||
{"bandit", "pip-audit", "ruff"},
|
||||
)
|
||||
self.assertEqual(setuptools_config["py-modules"], ["main"])
|
||||
self.assertEqual(package_find["include"], ["app", "app.*"])
|
||||
self.assertIn("config.sample.yaml", package_data)
|
||||
self.assertIn("templates/**/*.j2", package_data)
|
||||
self.assertIn("static/css/*.css", package_data)
|
||||
self.assertIn("static/js/*.js", package_data)
|
||||
|
||||
def test_legacy_requirements_files_are_removed(self):
|
||||
self.assertFalse((self.repo_root / "requirements.txt").exists())
|
||||
self.assertFalse((self.repo_root / "requirements-dev.txt").exists())
|
||||
self.assertFalse((self.repo_root / "app" / "requirements.txt").exists())
|
||||
|
||||
def test_package_init_files_exist(self):
|
||||
self.assertTrue((self.repo_root / "app" / "__init__.py").is_file())
|
||||
self.assertTrue((self.repo_root / "app" / "utils" / "__init__.py").is_file())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
43
tests/integration/test_yaml_syntax.py
Normal file
43
tests/integration/test_yaml_syntax.py
Normal file
@@ -0,0 +1,43 @@
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
import yaml
|
||||
|
||||
SKIP_DIR_NAMES = {".git", ".ruff_cache", "__pycache__", "node_modules"}
|
||||
SKIP_FILES = {"app/config.yaml"}
|
||||
YAML_SUFFIXES = {".yml", ".yaml"}
|
||||
|
||||
|
||||
class TestYamlSyntax(unittest.TestCase):
|
||||
def test_all_repository_yaml_files_are_valid(self):
|
||||
repo_root = Path(__file__).resolve().parents[2]
|
||||
invalid_files = []
|
||||
|
||||
for path in repo_root.rglob("*"):
|
||||
if not path.is_file() or path.suffix not in YAML_SUFFIXES:
|
||||
continue
|
||||
|
||||
relative_path = path.relative_to(repo_root).as_posix()
|
||||
if relative_path in SKIP_FILES:
|
||||
continue
|
||||
|
||||
if any(part in SKIP_DIR_NAMES for part in path.parts):
|
||||
continue
|
||||
|
||||
try:
|
||||
with path.open("r", encoding="utf-8") as handle:
|
||||
yaml.safe_load(handle)
|
||||
except yaml.YAMLError as error:
|
||||
invalid_files.append((relative_path, str(error).splitlines()[0]))
|
||||
except Exception as error:
|
||||
invalid_files.append((relative_path, f"Unexpected error: {error}"))
|
||||
|
||||
self.assertFalse(
|
||||
invalid_files,
|
||||
"Found invalid YAML files:\n"
|
||||
+ "\n".join(f"- {path}: {error}" for path, error in invalid_files),
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user