CI¶
The pipeline is defined in .gitlab-ci.yml, which only lists the stages and includes the files of ci/. It runs on GitLab CI, in the garulf/garulf-bot project.
When does a pipeline run?¶
ci/workflow.yml only allows two sources, everything else (pushes, merge requests) creates no pipeline:
| Source | Use | Jobs |
|---|---|---|
Run pipeline (web) on any branch |
Check a branch: image, docs, format, tests, security, quality | everything except the release jobs |
Release tag vX.Y.Z |
Publish a version and deploy it | everything, release jobs included |
The release jobs extend .release-rules (ci/deploy.yml): they only run on a tag matching vX.Y.Z.
Overview¶
flowchart LR
subgraph containers
ci_container[ci-container]
end
subgraph documentation
docs_build[docs:build]
end
subgraph format
black
pylint
mypy
end
subgraph test
t_domain[test:domain]
t_shared[test:shared]
t_discord[test:discord_api]
t_bot[test:bot]
t_integ[test:integration]
end
subgraph security
cve_scan
sbom
sbom_upload[sbom:upload]
end
subgraph quality
vulture[vulture-check]
sonar[sonarcloud-check]
end
subgraph deploy["deploy (release tags only)"]
pkg_build[package:build]
pkg_publish[package:publish]
image_bot[image:bot]
deploy_bot[deploy:bot]
docs_image[docs:image]
deploy_docs[deploy:docs]
end
containers --> documentation --> format --> test --> security --> quality --> deploy
sbom --> sbom_upload
pkg_build --> pkg_publish --> image_bot --> deploy_bot
pkg_build --> image_bot
docs_build --> docs_image --> deploy_docs
deploy_bot -. trigger APP=garulf-bot .-> garulf[(garulf/garulf<br/>deploy-app)]
deploy_docs -. trigger DOCS=1 .-> garulf_docs[(garulf/garulf<br/>docs:image, docs:deploy)]
Stages run in order; inside a stage the jobs run in parallel. Arrows inside the deploy stage are needs: a job starts as soon as the ones it needs are done.
Stages¶
| Stage | Jobs | File | What it does |
|---|---|---|---|
| containers | ci-container |
ci/containers.yml |
Builds the tools image (containers/ci.Dockerfile), tagged with a hash of its inputs and only rebuilt when they change. Every pipeline then gets its own alias $DOCKER_IMAGE (commit SHA), the default image of the other jobs |
| documentation | docs:build |
ci/docs.yml |
zensical build of this documentation (artifact public/) |
| format | black, pylint, mypy |
ci/format.yml |
Style and typing, allowed to fail. pylint and mypy reports feed SonarCloud |
| test | test:domain, test:shared, test:discord_api, test:bot, test:integration |
ci/tests.yml |
pytest per package, with coverage (Cobertura XML) and JUnit reports |
| security | cve_scan, sbom, sbom:upload |
ci/security.yml |
pip-audit (converted for SonarCloud), CycloneDX SBOM, pushed to Dependency-Track when DTRACK_URL and DTRACK_API_KEY are set |
| quality | vulture-check, sonarcloud-check |
ci/quality.yml |
Dead code, SonarCloud analysis (reads the reports above) |
| deploy | see below | ci/deploy.yml, ci/docs.yml |
Release tags only |
Release¶
A release is a git tag vX.Y.Z that matches the version of pyproject.toml.
sequenceDiagram
participant Dev as Maintainer
participant Bot as garulf-bot pipeline
participant Reg as Registries (PyPI, images)
participant Chap as garulf/garulf pipeline
participant VPS
Dev->>Bot: push tag vX.Y.Z
Bot->>Bot: package:build (tag == pyproject version?)
Bot->>Reg: package:publish (wheel, GitLab PyPI)
Bot->>Reg: image:bot (garulf-bot:X.Y.Z, :sha, :latest)
Bot->>Chap: deploy:bot (APP=garulf-bot, APP_IMAGE=...:X.Y.Z)
Chap->>VPS: deploy-app (app.yml)
Bot->>Reg: docs:image (docs:X.Y.Z, docs:latest)
Bot->>Chap: deploy:docs (DOCS=1)
Chap->>VPS: docs:image + docs:deploy (garulf-technical-doc)
| Job | Needs | What it does |
|---|---|---|
package:build |
Checks that the tag matches the pyproject.toml version, then python -m build (artifact dist/) |
|
package:publish |
package:build |
Uploads the wheel to the project's PyPI registry with the job token |
image:bot |
package:build, package:publish |
Builds containers/bot.Dockerfile from dist/, pushes garulf-bot:X.Y.Z, :<sha> and :latest. Hands BOT_IMAGE_TAG=X.Y.Z over through a dotenv report |
deploy:bot |
image:bot |
Trigger job: runs the pipeline of the private deployment project garulf/garulf with APP=garulf-bot and APP_IMAGE, and waits for it (strategy: depend) |
docs:image |
docs:build |
Packs public/ in an image holding /site/ (containers/docs.Dockerfile), pushes docs:X.Y.Z and docs:latest |
deploy:docs |
docs:image |
Trigger job: asks garulf/garulf to rebuild the documentation site with DOCS=1 |
The trigger jobs send nothing else (inherit: variables: false). The bot's secrets, such as DISCORD_TOKEN, are CI/CD variables of garulf/garulf, not of this project.
The documentation published under https://garulf-dev.hwlann.fr/bot/ is therefore always the one of the last release (docs:latest).
Variables¶
| Variable | Where | Used by |
|---|---|---|
DOCKER_IMAGE, BOT_IMAGE, DOCS_IMAGE, PACKAGE_REGISTRY_URL |
ci/variables.yml |
image names and registry URL |
SONAR_TOKEN, SONAR_HOST_URL |
project CI/CD variables | sonarcloud-check |
DTRACK_URL, DTRACK_API_KEY |
project CI/CD variables (optional) | sbom:upload |
Job token permissions: this project must allow garulf/garulf (Settings → CI/CD → Job token permissions), whose deployment jobs pull garulf-bot and docs from this registry.