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:
98
Makefile
98
Makefile
@@ -7,6 +7,8 @@ endif
|
||||
|
||||
# Default port (can be overridden with PORT env var)
|
||||
PORT ?= 5000
|
||||
PYTHON ?= python3
|
||||
ACT ?= act
|
||||
|
||||
# Default port (can be overridden with PORT env var)
|
||||
.PHONY: build
|
||||
@@ -14,10 +16,15 @@ build:
|
||||
# Build the Docker image.
|
||||
docker build -t application-portfolio .
|
||||
|
||||
.PHONY: build-no-cache
|
||||
build-no-cache:
|
||||
# Build the Docker image without cache.
|
||||
docker build --no-cache -t application-portfolio .
|
||||
|
||||
.PHONY: up
|
||||
up:
|
||||
# Start the application using docker-compose with build.
|
||||
docker-compose up -d --build
|
||||
docker-compose up -d --build --force-recreate
|
||||
|
||||
.PHONY: down
|
||||
down:
|
||||
@@ -75,8 +82,93 @@ browse:
|
||||
# Open the application in the browser at http://localhost:$(PORT)
|
||||
chromium http://localhost:$(PORT)
|
||||
|
||||
.PHONY: install
|
||||
install:
|
||||
# Install runtime Python dependencies from pyproject.toml.
|
||||
$(PYTHON) -m pip install -e .
|
||||
|
||||
.PHONY: install-dev
|
||||
install-dev:
|
||||
# Install runtime and developer dependencies from pyproject.toml.
|
||||
$(PYTHON) -m pip install -e ".[dev]"
|
||||
|
||||
.PHONY: npm-install
|
||||
npm-install:
|
||||
# Install Node.js dependencies for browser tests.
|
||||
cd app && npm install
|
||||
|
||||
test: npm-install
|
||||
cd app && npx cypress run --spec "cypress/e2e/**/*.spec.js"
|
||||
.PHONY: lint-actions
|
||||
lint-actions:
|
||||
# Lint GitHub Actions workflows.
|
||||
docker run --rm -v "$$PWD:/repo" -w /repo rhysd/actionlint:latest
|
||||
|
||||
.PHONY: lint-python
|
||||
lint-python: install-dev
|
||||
# Run Python lint and format checks.
|
||||
$(PYTHON) -m ruff check .
|
||||
$(PYTHON) -m ruff format --check .
|
||||
|
||||
.PHONY: lint-docker
|
||||
lint-docker:
|
||||
# Lint the Dockerfile.
|
||||
docker run --rm -i hadolint/hadolint < Dockerfile
|
||||
|
||||
.PHONY: test-lint
|
||||
test-lint:
|
||||
# Run lint guardrail tests.
|
||||
$(PYTHON) -m unittest discover -s tests/lint -t .
|
||||
|
||||
.PHONY: test-integration
|
||||
test-integration: install
|
||||
# Run repository integration tests.
|
||||
$(PYTHON) -m unittest discover -s tests/integration -t .
|
||||
|
||||
.PHONY: test-unit
|
||||
test-unit: install
|
||||
# Run repository unit tests.
|
||||
$(PYTHON) -m unittest discover -s tests/unit -t .
|
||||
|
||||
.PHONY: test-security
|
||||
test-security: install
|
||||
# Run repository security guardrail tests.
|
||||
$(PYTHON) -m unittest discover -s tests/security -t .
|
||||
|
||||
.PHONY: lint
|
||||
lint: lint-actions lint-python lint-docker test-lint
|
||||
# Run the full lint suite.
|
||||
|
||||
.PHONY: security
|
||||
security: install-dev test-security
|
||||
# Run security checks.
|
||||
$(PYTHON) -m bandit -q -ll -ii -r app main.py
|
||||
$(PYTHON) utils/export_runtime_requirements.py > /tmp/portfolio-runtime-requirements.txt
|
||||
$(PYTHON) -m pip_audit -r /tmp/portfolio-runtime-requirements.txt
|
||||
|
||||
.PHONY: test-e2e
|
||||
test-e2e:
|
||||
# Run Cypress end-to-end tests via act (stop portfolio container to free port first).
|
||||
-docker stop portfolio 2>/dev/null || true
|
||||
$(ACT) workflow_dispatch -W .github/workflows/tests.yml -j e2e
|
||||
-docker start portfolio 2>/dev/null || true
|
||||
|
||||
.PHONY: test-workflow
|
||||
test-workflow:
|
||||
# Run the GitHub test workflow locally via act.
|
||||
$(ACT) workflow_dispatch -W .github/workflows/tests.yml
|
||||
|
||||
.PHONY: lint-workflow
|
||||
lint-workflow:
|
||||
# Run the GitHub lint workflow locally via act.
|
||||
$(ACT) workflow_dispatch -W .github/workflows/lint.yml
|
||||
|
||||
.PHONY: quality
|
||||
quality: lint-workflow test-workflow
|
||||
# Run the GitHub lint and test workflows locally via act.
|
||||
|
||||
.PHONY: ci
|
||||
ci: lint security test-unit test-integration test-e2e
|
||||
# Run the local CI suite.
|
||||
|
||||
.PHONY: test
|
||||
test: ci
|
||||
# Run the full validation suite.
|
||||
|
||||
Reference in New Issue
Block a user