feat: Add Docker support and CI/CD workflows documentation; include setup instructions for Docker-based deployment
Some checks failed
Build and Push Docker Image / build-and-push (push) Failing after 1m35s
Deploy to Server / deploy (push) Failing after 3s
Run Tests / test (push) Failing after 6m2s

This commit is contained in:
2025-10-23 17:25:26 +02:00
parent 119bbcc7a8
commit f228eac61f
4 changed files with 101 additions and 14 deletions

View File

@@ -20,9 +20,12 @@ CalMiner uses a combination of unit, integration, and end-to-end tests to ensure
### CI/CD
- Use GitHub Actions for CI.
- Run tests on pull requests.
- Code coverage target: 80% (using pytest-cov).
- Use Gitea Actions for CI/CD; workflows live under `.gitea/workflows/`.
- `test.yml` runs on every push with cached Python dependencies via `actions/cache@v3`.
- `build-and-push.yml` builds the Docker image with `docker/build-push-action@v2`, reusing GitHub Actions cache-backed layers, and pushes to the Gitea registry.
- `deploy.yml` connects to the target host (via `appleboy/ssh-action`) to pull the freshly pushed image and restart the container.
- Mandatory secrets: `GITEA_USERNAME`, `GITEA_PASSWORD`, `GITEA_REGISTRY`, `SSH_HOST`, `SSH_USERNAME`, `SSH_PRIVATE_KEY`.
- Run tests on pull requests to shared branches; enforce coverage target ≥80% (pytest-cov).
### Running Tests
@@ -34,7 +37,7 @@ CalMiner uses a combination of unit, integration, and end-to-end tests to ensure
Organize tests under the `tests/` directory mirroring the application structure:
```text
````text
tests/
unit/
test_<module>.py
@@ -71,7 +74,7 @@ To run the Playwright tests:
```bash
pytest tests/e2e/
```
````
To run headed mode:
@@ -93,9 +96,22 @@ pytest tests/e2e/ --headed
### CI Integration
- Configure GitHub Actions workflow in `.github/workflows/ci.yml` to:
- Install dependencies, including Playwright browsers (`playwright install`).
- Run `pytest` with coverage for unit tests.
- Run `pytest tests/e2e/` for E2E tests.
- Fail on coverage <80%.
- Upload coverage artifacts under `reports/coverage/`.
`test.yml` encapsulates the steps below:
- Check out the repository and set up Python 3.10.
- Restore the pip cache (keyed by `requirements.txt`).
- Install project dependencies and Playwright browsers (if needed for E2E).
- Run `pytest` (extend with `--cov` flags when enforcing coverage).
`build-and-push.yml` adds:
- Registry login using repository secrets.
- Docker image build/push with GHA cache storage (`cache-from/cache-to` set to `type=gha`).
`deploy.yml` handles:
- SSH into the deployment host.
- Pull the tagged image from the registry.
- Stop, remove, and relaunch the `calminer` container exposing port 8000.
When adding new workflows, mirror this structure to ensure secrets, caching, and deployment steps remain aligned with the production environment.