Pipeline GitLab CI : lint, tests, build, déploiement

Intermédiaire LinuxGitLab CI25 min50 XP

Écrivez ~/app/.gitlab-ci.yml :

  • stages : lint, test, build, deploy
  • lint (image python:3.12) : pip install ruff puis ruff check .
  • test (image python:3.12) : pip install -r requirements.txt pytest puis pytest -q ; rapport JUnit en artefact (artifacts: reports: junit: report.xml, avec pytest -q --junitxml=report.xml)
  • build : docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA . puis docker push …
  • deploy-prod (stage deploy) : uniquement sur la branche main et manuel : rules: - if: $CI_COMMIT_BRANCH == "main" avec when: manual, environment: production

Validez avec glab ci lint (depuis ~/app).

Contenu Premium

Ce contenu est inclus dans l'offre Premium. Le titre et le résumé restent visibles pour vous aider à choisir.

Tâches

  1. Étapes et jobs
  2. Déploiement contrôlé
  3. Pipeline validé