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

View File

@@ -17,26 +17,99 @@ pipeline {
}
}
stage('Install Dependencies') {
// Стадия 1: Lint проверка
stage('🔍 Lint Check') {
steps {
sh '''
echo "🔍 Проверка синтаксиса ролей..."
pip install --upgrade pip
pip install molecule[docker] ansible-lint
pip install ansible ansible-lint
ansible-galaxy collection install -r requirements.yml
make role lint
'''
}
}
stage('Lint') {
steps {
sh 'ansible-lint molecule/universal/'
post {
always {
archiveArtifacts artifacts: '.ansible-lint', allowEmptyArchive: true
}
}
}
stage('Test') {
// Стадия 2: Тестирование
stage('🧪 Role Testing') {
parallel {
stage('Test Minimal') {
steps {
sh '''
echo "🧪 Тестирование с preset: minimal"
sudo apt-get update
sudo apt-get install -y docker.io make
sudo systemctl start docker
sudo usermod -aG docker $USER
make docker setup-builder
make docker build
make role test minimal
'''
}
}
stage('Test Default') {
steps {
sh '''
echo "🧪 Тестирование с preset: default"
sudo apt-get update
sudo apt-get install -y docker.io make
sudo systemctl start docker
sudo usermod -aG docker $USER
make docker setup-builder
make docker build
make role test default
'''
}
}
stage('Test Performance') {
steps {
sh '''
echo "🧪 Тестирование с preset: performance"
sudo apt-get update
sudo apt-get install -y docker.io make
sudo systemctl start docker
sudo usermod -aG docker $USER
make docker setup-builder
make docker build
make role test performance
'''
}
}
}
}
// Стадия 3: Деплой (только для main ветки)
stage('🚀 Deploy Check') {
when {
branch 'main'
}
steps {
dir('molecule/universal') {
sh 'molecule test -s universal'
sh '''
echo "🚀 Проверка развертывания (dry-run)..."
pip install --upgrade pip
pip install ansible ansible-lint
ansible-galaxy collection install -r requirements.yml
mkdir -p inventory
cat > inventory/hosts.ini << EOF
[test_servers]
localhost ansible_connection=local
[all:vars]
ansible_python_interpreter=python3
EOF
make role deploy
'''
}
post {
always {
archiveArtifacts artifacts: 'deployment.log', allowEmptyArchive: true
}
}
}
@@ -44,16 +117,22 @@ pipeline {
post {
always {
archiveArtifacts artifacts: 'molecule/universal/.molecule/**/*', allowEmptyArchive: true
publishTestResults testResultsPattern: 'molecule/universal/.molecule/reports/junit.xml'
archiveArtifacts artifacts: 'molecule/default/.molecule/**/*', allowEmptyArchive: true
publishTestResults testResultsPattern: 'molecule/default/.molecule/reports/junit.xml'
}
success {
echo 'Pipeline completed successfully!'
echo 'Все проверки пройдены успешно!'
echo '🔍 Lint: Success'
echo '🧪 Test: Success'
echo '🚀 Deploy: Success'
}
failure {
echo 'Pipeline failed!'
echo '❌ Проверки не пройдены!'
echo '🔍 Lint: Failed'
echo '🧪 Test: Failed'
echo '🚀 Deploy: Failed'
}
}
}