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 env: REPO_TOKEN: ${{ secrets.REPO_TOKEN }} run: make setup-quality - name: Lint all run: | . .venv/bin/activate export PATH="$HOME/.local/bin:$PATH" make lint-all - name: Unit tests with 100% coverage run: | . .venv/bin/activate make pytest-cov - name: Check unit test speed env: PYTHONPATH: src run: | . .venv/bin/activate python3 -m devx.tools.check_test_speed --max-seconds 4 --max-single-seconds 0.5 - name: Dependency security scan run: | . .venv/bin/activate # Install pip in venv if missing (needed by pip-audit) .venv/bin/python -m ensurepip 2>/dev/null || true PIPAPI_PYTHON_LOCATION=$PWD/.venv/bin/python \ pip-audit --desc --skip-editable 2>&1 || true - name: Workflow dry-run validation run: | . .venv/bin/activate export PATH="$HOME/.local/bin:$PATH" # Best-effort: only runs if act_runner is installed if command -v act_runner >/dev/null 2>&1; then make workflow-dryrun else echo "act_runner not found — skipping workflow dry-run (static lint still passed)" fi 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 env: REPO_TOKEN: ${{ secrets.REPO_TOKEN }} run: make setup-release - name: Release dry-run validation env: PYTHONPATH: src DEVX_VERSION_FILE: src/gitea_runner_manager/__init__.py DEVX_TASK_PREFIX: GRM run: | . .venv/bin/activate export PATH="$HOME/.local/bin:$PATH" python3 -m devx.ci.release --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 env: REPO_TOKEN: ${{ secrets.REPO_TOKEN }} run: make setup-ci - name: Detect changed paths id: detect env: PYTHONPATH: src DEVX_TASK_PREFIX: GRM run: | . .venv/bin/activate python3 -m devx.ci.classify_changes \ --base "origin/master" \ --head "${{ github.event.pull_request.head.sha || github.sha }}" \ --github-output 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 env: REPO_TOKEN: ${{ secrets.REPO_TOKEN }} run: make setup-ci - name: Discover available runners id: discover env: REPO_TOKEN: ${{ secrets.REPO_TOKEN }} MOLECULE_RUNNERS: ${{ vars.MOLECULE_RUNNERS }} PYTHONPATH: src run: | . .venv/bin/activate python3 -m devx.molecule.discover_runners \ --owner "${{ github.repository_owner }}" \ --repo "${{ github.event.repository.name }}" \ --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 env: REPO_TOKEN: ${{ secrets.REPO_TOKEN }} run: make setup-molecule - name: Discover assigned test pairs env: RUNNER_INDEX: ${{ matrix.runner-index }} MAX_RUNNERS: ${{ needs.discover-runners.outputs.runner-count }} PYTHONPATH: src run: | . .venv/bin/activate python3 -m devx.molecule.distribute_molecule \ --runner-index "$RUNNER_INDEX" \ --max-runners "$MAX_RUNNERS" \ --github-env --skip-if-excess - name: Run molecule tests if: env.SKIP != 'true' run: | . .venv/bin/activate if [ -z "$TEST_PAIRS" ]; then exit 0; fi # shellcheck disable=SC2086 # intentional word splitting for argument expansion python3 -m devx.molecule.molecule_ci_guard $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 }} PYTHONPATH: src pr-review: if: github.event_name == 'pull_request' runs-on: docker timeout-minutes: 10 steps: - uses: actions/checkout@v4 - name: Install dependencies run: | . .env 2>/dev/null || true python3 -m pip install --break-system-packages --target=src "devx==0.10.2" --extra-index-url "https://emil:${{ secrets.REPO_TOKEN }}@git.oblachno.oblachno.fyi/api/packages/oblachno-oss/pypi/simple/" python3 -m pip install --break-system-packages --target=src "devx==0.10.2" --extra-index-url "https://emil:${{ secrets.REPO_TOKEN }}@git.oblachno.oblachno.fyi/api/packages/oblachno-oss/pypi/simple/" python3 -m pip install --break-system-packages --target=src "devx==0.10.2" --extra-index-url "https://emil:${{ secrets.REPO_TOKEN }}@git.oblachno.oblachno.fyi/api/packages/oblachno-oss/pypi/simple/" - name: Run automated PR review env: REPO_TOKEN: ${{ secrets.REPO_TOKEN }} PYTHONPATH: src run: | set -euo pipefail python3 -m devx.ci.pr_review \ "${{ github.event.number }}" \ "${{ github.repository }}" auto-merge: # Auto-merge runs after all CI checks pass. It reads the task ID # from the branch name (falling back to .taskid file), validates # the PR title, and squash-merges. # Uses always() so it evaluates even when molecule-tests is skipped # (Gitea Actions skips dependent jobs of skipped jobs by default). needs: [quality, detect-changes, pr-review, molecule-tests] if: >- always() && github.event_name == 'pull_request' && needs.quality.result == 'success' && needs.pr-review.result == 'success' && (needs.molecule-tests.result == 'success' || needs.molecule-tests.result == 'skipped') runs-on: docker timeout-minutes: 10 steps: - uses: actions/checkout@v4 with: fetch-depth: 0 token: ${{ secrets.REPO_TOKEN }} - name: Install dependencies run: | . .env 2>/dev/null || true python3 -m pip install --break-system-packages --target=src "devx==0.10.2" --extra-index-url "https://emil:${{ secrets.REPO_TOKEN }}@git.oblachno.oblachno.fyi/api/packages/oblachno-oss/pypi/simple/" python3 -m pip install --break-system-packages --target=src "devx==0.10.2" --extra-index-url "https://emil:${{ secrets.REPO_TOKEN }}@git.oblachno.oblachno.fyi/api/packages/oblachno-oss/pypi/simple/" python3 -m pip install --break-system-packages --target=src "devx==0.10.2" --extra-index-url "https://emil:${{ secrets.REPO_TOKEN }}@git.oblachno.oblachno.fyi/api/packages/oblachno-oss/pypi/simple/" - name: Squash merge with task ID env: REPO_TOKEN: ${{ secrets.REPO_TOKEN }} VIKUNJA_TOKEN: ${{ secrets.VIKUNJA_TOKEN }} PYTHONPATH: src DEVX_TASK_PREFIX: GRM DEVX_VIKUNJA_PROJECT_ID: 6 HEAD_REF: ${{ github.head_ref }} PR_TITLE: ${{ github.event.pull_request.title }} REPOSITORY: ${{ github.repository }} PR_NUMBER: ${{ github.event.number }} run: | python3 -m devx.ci.auto_merge \ "$HEAD_REF" \ "$PR_TITLE" \ "$REPOSITORY" \ "$PR_NUMBER"