Skip to content

Revert "fix: remove bash -c wrapper and fix variable expansion in ans… #33

Revert "fix: remove bash -c wrapper and fix variable expansion in ans…

Revert "fix: remove bash -c wrapper and fix variable expansion in ans… #33

Workflow file for this run

name: Code Quality & Coverage
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
jobs:
# Python code quality
python-quality:
name: Python Code Quality
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
cache: 'pip'
- name: Install quality tools
run: |
pip install ruff pylint black isort pytest pytest-cov
- name: Check code formatting with black
run: black --check cli/ tests/ || true
- name: Check import sorting with isort
run: isort --check-only cli/ tests/ || true
- name: Lint with Ruff
run: |
ruff check cli/ tests/ || true
- name: Lint with pylint
run: |
pylint cli/ tests/ --max-line-length=100 || true
- name: Run pytest with coverage
run: |
pytest tests/ \
--cov=cli \
--cov-report=xml \
--cov-report=html \
--cov-report=term-missing \
--junitxml=junit.xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: ./coverage.xml
flags: unittests
name: codecov-umbrella
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: python-test-results
path: |
junit.xml
htmlcov/
if-no-files-found: ignore
# Bash script quality
bash-quality:
name: Bash Script Quality
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install shellcheck
run: apt-get update && apt-get install -y shellcheck
- name: Run shellcheck with strict options
run: |
shellcheck \
--severity=style \
--format=gcc \
bootstrap.sh \
bootstrap-ansible.sh \
verify-setup.sh \
update.sh \
cli/config.sh
- name: Run shfmt (shell formatting check)
run: |
apt-get install -y shfmt
shfmt -d bootstrap.sh bootstrap-ansible.sh verify-setup.sh update.sh cli/config.sh || true
# YAML quality
yaml-quality:
name: YAML Quality
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
cache: 'pip'
- name: Install yamllint
run: pip install yamllint
- name: Lint YAML files
run: |
yamllint -d relaxed \
setup.yml \
inventory.yml \
.github/workflows/*.yml \
ansible/group_vars/ \
ansible/roles/*/
# Complexity analysis
complexity:
name: Code Complexity Analysis
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
cache: 'pip'
- name: Install radon
run: pip install radon
- name: Cyclomatic complexity check
run: |
radon cc cli/ -a -s || true
- name: Maintainability index
run: |
radon mi cli/ -s || true
# Performance benchmarks
performance:
name: Performance Benchmarks
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
cache: 'pip'
- name: Install pytest-benchmark
run: pip install pytest-benchmark
- name: Run performance tests
run: |
pytest tests/ -v --benchmark-only || true
# Mutation Testing
mutation-testing:
name: Mutation Testing (Test Quality)
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
cache: 'pip'
- name: Install dependencies
run: |
pip install pytest pytest-cov
- name: Run mutation testing
run: |
python cli/mutation_test.py
- name: Check mutation score
run: |
python -c "
import json
with open('.mutation_test/report.json') as f:
report = json.load(f)
score = report['mutation_score']
print(f'Mutation Score: {score}%')
if score < 70:
print('Mutation score below 70% threshold')
exit(1)
elif score < 80:
print('Mutation score below 80% (target)')
exit(0)
else:
print('Mutation score meets target (80%+)')
exit(0)
"
- name: Upload mutation report
if: always()
uses: actions/upload-artifact@v4
with:
name: mutation-test-report
path: .mutation_test/
# Type Checking with mypy
type-checking:
name: Type Checking (mypy)
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
cache: 'pip'
- name: Install mypy and dependencies
run: |
pip install mypy types-PyYAML types-requests types-setuptools
- name: Run mypy type checking (strict mode)
run: |
mypy cli/ \
--strict \
--no-implicit-optional \
--disallow-untyped-calls \
--disallow-untyped-defs \
--warn-redundant-casts \
--warn-unused-ignores \
--warn-return-any \
--warn-unused-configs \
--pretty \
--show-error-context
# Quality Summary
quality-summary:
name: Quality Summary
needs: [python-quality, bash-quality, yaml-quality, complexity, performance, mutation-testing, type-checking]
runs-on: ubuntu-latest
if: always()
steps:
- name: Print quality report
run: |
echo "════════════════════════════════════════════════════"
echo "Code Quality Report"
echo "════════════════════════════════════════════════════"
echo "Python Quality: ${{ needs.python-quality.result }}"
echo "Bash Quality: ${{ needs.bash-quality.result }}"
echo "YAML Quality: ${{ needs.yaml-quality.result }}"
echo "Complexity: ${{ needs.complexity.result }}"
echo "Performance: ${{ needs.performance.result }}"
echo "Mutation Testing: ${{ needs.mutation-testing.result }}"
echo "Type Checking: ${{ needs.type-checking.result }}"
echo "════════════════════════════════════════════════════"