feat: Добавлены 3 стадии в CI/CD пайплайны (lint, test, deploy)

- GitHub Actions: добавлены стадии lint, test, deploy с зависимостями
- Azure DevOps: добавлены стадии lint, test, deploy с зависимостями
- Jenkins: добавлены стадии lint, test, deploy с зависимостями
- GitLab CI: создан новый .gitlab-ci.yml с 3 стадиями

Особенности:
- Деплой происходит только после успешного прохождения lint и test
- Деплой выполняется только для main ветки
- Добавлены уведомления о результатах
- Используются make команды для консистентности
- Параллельное тестирование с разными preset'ами
This commit is contained in:
Сергей Антропов
2025-10-25 19:33:37 +03:00
parent bfed0d1ea8
commit 787ab06e25
4 changed files with 514 additions and 66 deletions

153
cicd/gitlab/.gitlab-ci.yml Normal file
View File

@@ -0,0 +1,153 @@
# GitLab CI Pipeline для AnsibleLab
# Автор: Сергей Антропов
# Сайт: https://devops.org.ru
stages:
- lint
- test
- deploy
variables:
ANSIBLE_FORCE_COLOR: "true"
DOCKER_TLS_CERTDIR: ""
# Стадия 1: Lint проверка
lint:
stage: lint
image: python:3.11
before_script:
- pip install --upgrade pip
- pip install ansible ansible-lint
- ansible-galaxy collection install -r requirements.yml
script:
- echo "🔍 Проверка синтаксиса ролей..."
- make role lint
artifacts:
reports:
junit: .ansible-lint
paths:
- .ansible-lint
expire_in: 1 week
# Стадия 2: Тестирование
test_minimal:
stage: test
image: docker:latest
services:
- docker:dind
variables:
DOCKER_TLS_CERTDIR: ""
before_script:
- apk add --no-cache make python3 py3-pip
- pip install --upgrade pip
- pip install ansible ansible-lint
- ansible-galaxy collection install -r requirements.yml
- make docker setup-builder
- make docker build
script:
- echo "🧪 Тестирование с preset: minimal"
- make role test minimal
artifacts:
reports:
junit: molecule/default/.molecule/reports/junit.xml
paths:
- molecule/default/.molecule/
expire_in: 1 week
test_default:
stage: test
image: docker:latest
services:
- docker:dind
variables:
DOCKER_TLS_CERTDIR: ""
before_script:
- apk add --no-cache make python3 py3-pip
- pip install --upgrade pip
- pip install ansible ansible-lint
- ansible-galaxy collection install -r requirements.yml
- make docker setup-builder
- make docker build
script:
- echo "🧪 Тестирование с preset: default"
- make role test default
artifacts:
reports:
junit: molecule/default/.molecule/reports/junit.xml
paths:
- molecule/default/.molecule/
expire_in: 1 week
test_performance:
stage: test
image: docker:latest
services:
- docker:dind
variables:
DOCKER_TLS_CERTDIR: ""
before_script:
- apk add --no-cache make python3 py3-pip
- pip install --upgrade pip
- pip install ansible ansible-lint
- ansible-galaxy collection install -r requirements.yml
- make docker setup-builder
- make docker build
script:
- echo "🧪 Тестирование с preset: performance"
- make role test performance
artifacts:
reports:
junit: molecule/default/.molecule/reports/junit.xml
paths:
- molecule/default/.molecule/
expire_in: 1 week
# Стадия 3: Деплой (только для main ветки)
deploy:
stage: deploy
image: python:3.11
only:
- main
before_script:
- pip install --upgrade pip
- pip install ansible ansible-lint
- ansible-galaxy collection install -r requirements.yml
script:
- echo "🚀 Проверка развертывания (dry-run)..."
- mkdir -p inventory
- |
cat > inventory/hosts.ini << EOF
[test_servers]
localhost ansible_connection=local
[all:vars]
ansible_python_interpreter=python3
EOF
- make role deploy
artifacts:
paths:
- deployment.log
expire_in: 1 week
# Уведомления
notify_success:
stage: deploy
image: python:3.11
only:
- main
when: on_success
script:
- echo "✅ Все проверки пройдены успешно!"
- echo "🔍 Lint: Success"
- echo "🧪 Test: Success"
- echo "🚀 Deploy: Success"
notify_failure:
stage: deploy
image: python:3.11
when: on_failure
script:
- echo "❌ Проверки не пройдены!"
- echo "🔍 Lint: Failed"
- echo "🧪 Test: Failed"
- echo "🚀 Deploy: Failed"