Automations¶
This project uses GitHub Actions to automate builds, code analysis, security scanning, testing, and documentation deployment. Apart from image publishing, which runs on every version tag, all workflows are started manually from the repository's Actions tab (workflow_dispatch).
| Workflow | Repository | Trigger | Purpose |
|---|---|---|---|
| Build and Push Search API Docker Image | code | Push of a v* tag |
Build and publish the Docker image |
| Vulnerability Scan (On-Demand) | code | Manual | Trivy scan of the repository configuration and a published image |
| CodeQL Scan (On-Demand) | code | Manual | Static code analysis |
| Code Metrics (On-Demand) | code | Manual | Radon complexity and maintainability report |
| Test Scenario (On-Demand) | code | Manual | API tests against the deployed service |
| Deploy Docs (On-Demand) | docs | Manual | Publish this documentation site |
| Deploy to Dev (On-Demand) | deployment (dev) | Manual | Apply the Kubernetes manifests to the development cluster (see Deployment) |
| Deploy to Prod (On-Demand) | deployment (prod) | Manual | Apply the Kubernetes manifests to the production cluster (see Deployment) |
Dockerfile¶
The production container image is built by the Dockerfile in the root of the code repository, in two stages:
- Stage 1 (Builder): Installs CPU-only PyTorch and the API's Python dependencies, and pre-downloads the models the service needs at runtime: the FastEmbed
Qdrant/bm25model and theBAAI/bge-m3tokenizer. - Stage 2 (Final): Copies only the installed packages, the model cache and the application code onto a clean
python:3.12-slimbase. It creates a non-rootappuser, defines aHEALTHCHECK, and starts thegunicornserver.
See Deployment for details.
Docker Image Publishing¶
Workflow: .github/workflows/docker-publish.yml
This workflow builds the service's Docker image and publishes it to the GitHub Container Registry (ghcr.io).
- Trigger: Runs automatically whenever a Git tag matching
v*(e.g.v1.17.2) is pushed. - Process:
- Logs into the GitHub Container Registry using the workflow's
GITHUB_TOKEN. - Uses
docker/metadata-actionto derive the image tag from the Git tag. The image gets exactly that tag; nolatesttag is published. - Builds the image with Docker Buildx, reusing layers from the GitHub Actions cache to speed up builds.
- Pushes the image to
ghcr.io/datagems-eosc/cross-dataset-discovery-api.
- Logs into the GitHub Container Registry using the workflow's
Vulnerability Scanning¶
Workflow: .github/workflows/vulnerability-scan-on-demand.yml
This workflow scans the project's configuration and a published Docker image using the Trivy security scanner.
- Trigger: Manual. It requires an
image_taginput naming the published image to scan. - Process:
- Configuration Scan: Scans the
Dockerfileand other configuration files of the default branch for security misconfigurations. - Image Scan: Pulls
ghcr.io/datagems-eosc/cross-dataset-discovery-api:<image_tag>and scans its operating system packages and Python libraries for known vulnerabilities (CVEs) ofCRITICALorHIGHseverity. - Artifacts: The JSON reports of both scans are uploaded as build artifacts (
vulnerability-config-scanandvulnerability-image-scan).
- Configuration Scan: Scans the
Static Code Analysis¶
Workflow: .github/workflows/code-scan-on-demand.yml
This workflow runs GitHub CodeQL to find potential bugs, security vulnerabilities, and quality issues.
- Trigger: Manual.
- Process:
- Runs two analysis jobs: one for the Python code and one for the GitHub Actions workflow files.
- Uses the
security-extendedandsecurity-and-qualityquery suites. - Uploads the results to the repository's Security tab, under Code scanning alerts.
Code Metrics¶
Workflow: .github/workflows/code-metrics-on-demand.yml
This workflow reports on the complexity and maintainability of the API code using Radon.
- Trigger: Manual.
- Process:
- Installs the
radonPython package. - Analyzes the
cross_dataset_discovery/darelabdb/api_datagems_cross_dataset_discovery/appdirectory:- Maintainability Index (MI): A score from 0 to 100 indicating how easy the code is to maintain.
- Cyclomatic Complexity (CC): The number of independent paths through each function, indicating its complexity.
- Raw Lines of Code (LOC): Basic code size metrics.
- Uploads the report as a build artifact named
code-metrics-report.
- Installs the
API Tests¶
Workflow: .github/workflows/test-on-demand.yml
This workflow runs the Postman test collection against the deployed service with Newman. It takes a tag input (default main) that selects which version of the test collection to run. See Quality Assurance for details.
Documentation¶
Workflow: .github/workflows/deploy-docs-on-demand.yml (in the documentation repository)
This documentation site is built and published by this workflow.
- Trigger: Manual, with a version number (e.g.
1.0.0) as input. - Process:
- Installs
mkdocs,mkdocs-material,mike, and the other required plugins. - Builds the static site from the Markdown files in
docs/. - Uses
miketo commit the built site to thegh-pagesbranch, under the given version. - Points the
latestalias at this version and makeslatestthe default, so visitors see the most recent documentation.
- Installs