+18
-14
@@ -13,43 +13,47 @@ jobs:
|
|||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
# Install required system dependencies
|
# Install system dependencies required for CI
|
||||||
# Includes Ansible, Docker (for molecule and compose), and Python tooling
|
- name: Install system dependencies
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
run: |
|
||||||
apt-get update
|
apt-get update
|
||||||
apt-get install -y python3 python3-pip ansible docker.io
|
apt-get install -y python3 python3-venv ansible docker.io
|
||||||
pip3 install ansible-lint molecule molecule-plugins[docker]
|
|
||||||
|
|
||||||
# Basic Python syntax validation to catch immediate errors
|
# Create isolated Python environment and install tools
|
||||||
# This avoids introducing runtime failures due to syntax issues
|
# This avoids breaking system Python (PEP 668 compliant)
|
||||||
|
- name: Setup Python virtual environment
|
||||||
|
run: |
|
||||||
|
python3 -m venv .venv
|
||||||
|
. .venv/bin/activate
|
||||||
|
pip install --upgrade pip
|
||||||
|
pip install ansible-lint molecule molecule-plugins[docker]
|
||||||
|
|
||||||
|
# Basic Python syntax validation
|
||||||
- name: Python syntax check
|
- name: Python syntax check
|
||||||
run: |
|
run: |
|
||||||
find migration-validation-framework -name "*.py" -exec python3 -m py_compile {} \;
|
find migration-validation-framework -name "*.py" -exec python3 -m py_compile {} \;
|
||||||
|
|
||||||
# Run Ansible lint to enforce best practices and detect potential issues
|
# Run Ansible lint using virtual environment
|
||||||
# Uses ansible.cfg from the project directory
|
|
||||||
- name: Ansible lint
|
- name: Ansible lint
|
||||||
run: |
|
run: |
|
||||||
|
. .venv/bin/activate
|
||||||
cd enterprise-infra-simulator
|
cd enterprise-infra-simulator
|
||||||
ansible-lint
|
ansible-lint
|
||||||
|
|
||||||
# Perform syntax validation of all playbooks
|
# Validate Ansible playbook syntax
|
||||||
# Ensures playbooks are structurally correct before execution
|
|
||||||
- name: Ansible syntax check
|
- name: Ansible syntax check
|
||||||
run: |
|
run: |
|
||||||
cd enterprise-infra-simulator
|
cd enterprise-infra-simulator
|
||||||
ansible-playbook --syntax-check playbooks/*.yml
|
ansible-playbook --syntax-check playbooks/*.yml
|
||||||
|
|
||||||
# Validate Docker Compose configuration
|
# Validate Docker Compose configuration
|
||||||
# Ensures compose file is valid and can be parsed correctly
|
|
||||||
- name: Docker Compose validation
|
- name: Docker Compose validation
|
||||||
run: |
|
run: |
|
||||||
docker compose -f observability-stack/docker-compose.yml config
|
docker compose -f observability-stack/docker-compose.yml config
|
||||||
|
|
||||||
# Execute Molecule tests for Ansible roles
|
# Run Molecule tests using virtual environment
|
||||||
# This validates role behavior in an isolated container environment
|
|
||||||
- name: Molecule test
|
- name: Molecule test
|
||||||
run: |
|
run: |
|
||||||
|
. .venv/bin/activate
|
||||||
cd enterprise-infra-simulator
|
cd enterprise-infra-simulator
|
||||||
molecule test
|
molecule test
|
||||||
|
|||||||
Reference in New Issue
Block a user