name: CI on: pull_request: types: [opened, synchronize] workflow_dispatch: jobs: quality: runs-on: docker timeout-minutes: 10 steps: - uses: actions/checkout@v4 - name: Set up environment run: make setup - name: Lint all run: | . .venv/bin/activate make lint-all - name: Unit tests with 100% coverage run: | . .venv/bin/activate make pytest-cov - name: Check unit test speed run: | . .venv/bin/activate python3 scripts/check_test_speed.py --max-seconds 10 - name: Documentation coverage check run: | . .venv/bin/activate PYTHONPATH=src python3 scripts/ci/doc_coverage.py release-dry-run: needs: [quality, detect-changes] if: needs.detect-changes.outputs.user-facing-changed == 'true' runs-on: docker timeout-minutes: 10 steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up environment run: make setup - name: Install git-cliff run: | set -euo pipefail GIT_CLIFF_VERSION="2.13.0" URL="https://github.com/orhun/git-cliff/releases/download/v${GIT_CLIFF_VERSION}/git-cliff-${GIT_CLIFF_VERSION}-x86_64-unknown-linux-gnu.tar.gz" TMPDIR="$(mktemp -d)" curl -sL "$URL" | tar xz -C "$TMPDIR" mkdir -p "$HOME/.local/bin" mv "$TMPDIR/git-cliff-${GIT_CLIFF_VERSION}/git-cliff" "$HOME/.local/bin/git-cliff" chmod +x "$HOME/.local/bin/git-cliff" echo "$HOME/.local/bin" >> "$GITHUB_PATH" - name: Release dry-run validation run: | set -euo pipefail . .venv/bin/activate PYTHONPATH=. python3 scripts/ci/release.py --dry-run || true detect-changes: runs-on: docker timeout-minutes: 10 outputs: ansible-changed: ${{ steps.detect.outputs.ansible-changed }} user-facing-changed: ${{ steps.detect.outputs.user-facing-changed }} steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up environment run: make setup - name: Detect changed paths id: detect env: PYTHONPATH: src run: | set -euo pipefail . .venv/bin/activate BASE="origin/master" HEAD="${{ github.event.pull_request.head.sha || github.sha }}" # Use classify_changes.py for consistent file classification ANSIBLE_RESULT=$(python3 scripts/ci/classify_changes.py --base "$BASE" --head "$HEAD" --check ansible --quiet) if [ "$ANSIBLE_RESULT" = "true" ]; then echo "ansible-changed=true" >> "$GITHUB_OUTPUT" echo "Ansible files changed — molecule tests will run." else echo "ansible-changed=false" >> "$GITHUB_OUTPUT" echo "No Ansible files changed — skipping molecule tests." fi USER_FACING_RESULT=$(python3 scripts/ci/classify_changes.py --base "$BASE" --head "$HEAD" --check user-facing --quiet) if [ "$USER_FACING_RESULT" = "true" ]; then echo "user-facing-changed=true" >> "$GITHUB_OUTPUT" echo "User-facing files changed — release dry-run will run." else echo "user-facing-changed=false" >> "$GITHUB_OUTPUT" echo "No user-facing files changed — skipping release dry-run." fi discover-runners: needs: [detect-changes] if: needs.detect-changes.outputs.ansible-changed == 'true' runs-on: docker timeout-minutes: 10 outputs: runner-count: ${{ steps.discover.outputs.runner-count }} runner-indices: ${{ steps.discover.outputs.runner-indices }} steps: - uses: actions/checkout@v4 - name: Set up environment run: make setup - name: Discover available runners id: discover env: REPO_TOKEN: ${{ secrets.REPO_TOKEN }} MOLECULE_RUNNERS: ${{ vars.MOLECULE_RUNNERS }} PYTHONPATH: src run: | set -euo pipefail . .venv/bin/activate OUTPUT=$(python3 scripts/ci/discover_runners.py --owner "${{ github.repository_owner }}" --repo "${{ github.event.repository.name }}") echo "$OUTPUT" # Parse outputs RUNNER_COUNT=$(echo "$OUTPUT" | grep '^count=' | cut -d= -f2) RUNNER_INDICES=$(echo "$OUTPUT" | grep '^indices=' | cut -d= -f2) echo "runner-count=$RUNNER_COUNT" >> "$GITHUB_OUTPUT" echo "runner-indices=$RUNNER_INDICES" >> "$GITHUB_OUTPUT" molecule-tests: needs: [quality, detect-changes, discover-runners] if: needs.detect-changes.outputs.ansible-changed == 'true' runs-on: docker timeout-minutes: 10 strategy: matrix: runner-index: [1, 2, 3] steps: - uses: actions/checkout@v4 - name: Set up environment run: make setup - name: Discover assigned test pairs env: RUNNER_INDEX: ${{ matrix.runner-index }} MAX_RUNNERS: ${{ needs.discover-runners.outputs.runner-count }} run: | set -euo pipefail . .venv/bin/activate echo "Runner index: $RUNNER_INDEX" echo "Max runners: $MAX_RUNNERS" # Skip if runner index exceeds available runners if [ "$RUNNER_INDEX" -gt "$MAX_RUNNERS" ]; then echo "Skipping — runner index $RUNNER_INDEX > max runners $MAX_RUNNERS" echo "TEST_PAIRS=" >> $GITHUB_ENV echo "SKIP=true" >> $GITHUB_ENV exit 0 fi PAIRS=$(python3 scripts/ci/distribute_molecule.py --runner-index "$RUNNER_INDEX" --max-runners "$MAX_RUNNERS") echo "Assigned pairs: $PAIRS" echo "TEST_PAIRS=$PAIRS" >> $GITHUB_ENV echo "SKIP=false" >> $GITHUB_ENV - name: Run molecule tests if: env.SKIP != 'true' run: | set -euo pipefail . .venv/bin/activate if [ -z "$TEST_PAIRS" ]; then echo "No test pairs assigned — skipping" exit 0 fi python3 scripts/ci/molecule_ci_guard.py $TEST_PAIRS env: GITEA_URL: ${{ github.server_url }} REPO_TOKEN: ${{ secrets.REPO_TOKEN }} RUN_ID: ${{ github.run_id }} JOB_NAME: ${{ github.job }} MATRIX_INDEX: ${{ matrix.runner-index }} GITEA_REPOSITORY: ${{ github.repository }} pr-review: if: github.event_name == 'pull_request' runs-on: docker timeout-minutes: 10 steps: - uses: actions/checkout@v4 - name: Set up environment run: make setup - name: Run automated PR review env: REPO_TOKEN: ${{ secrets.REPO_TOKEN }} PYTHONPATH: src run: | set -euo pipefail . .venv/bin/activate python3 scripts/ci/pr_review.py \ "${{ github.event.number }}" \ "${{ github.repository }}"