# Generated by ace_generate_ci — do not edit manually.
# Regenerate: ace_generate_ci(target="github_actions")
name: ACE Quality Gate

on:
  push:
    branches: [main, master]
  pull_request:
    branches: [main, master]

jobs:
  quality-gate:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      {% if 'python' in stack %}
      - name: Set up Python {{ python_version }}
        uses: actions/setup-python@v5
        with:
          python-version: "{{ python_version }}"

      - name: Install dependencies
        run: pip install -e ".[dev]" || pip install -r requirements.txt || true

      - name: Run tests with coverage
        run: {{ test_command }} --cov --cov-report=xml:coverage.xml --cov-fail-under={{ coverage_threshold }}

      - name: Upload coverage report
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: coverage-xml
          path: coverage.xml

      {% if run_quality %}
      - name: Code quality (Ruff)
        run: ruff check --output-format github .
      {% endif %}

      {% if run_deps %}
      - name: Dependency audit
        run: pip-audit --format json 2>/dev/null || true
      {% endif %}
      {% endif %}

      {% if 'node' in stack %}
      - name: Set up Node {{ node_version }}
        uses: actions/setup-node@v4
        with:
          node-version: "{{ node_version }}"
          cache: npm

      - name: Install Node dependencies
        run: npm ci

      - name: Run Node tests
        run: npm test
      {% endif %}

      {% if run_security %}
      - name: Security scan (Semgrep)
        uses: semgrep/semgrep-action@v1
        with:
          config: "p/owasp-top-ten"
      {% endif %}

      {% if has_docker %}
      - name: Build Docker image
        run: docker build -t app:ci .
      {% endif %}
