From 6be805e5b18936eddf4f780240db7cbbdbb5d86b Mon Sep 17 00:00:00 2001 From: Emil Simeonov Date: Sun, 9 Aug 2026 02:19:08 +0200 Subject: [PATCH] =?UTF-8?q?refactor:=20remove=20molecule=5Fci=5Fguard=20?= =?UTF-8?q?=E2=80=94=20adds=20complexity,=20no=20value?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The cross-runner cancellation guard was killing healthy molecule slots when unhealthy slots failed, defeating fail-fast: false. Replace with direct molecule test execution. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- .gitea/workflows/ci.yml | 43 ++++++++++++++++++++++++++++------- AGENTS.md | 6 ++--- docs/tech/ci-cd-workflow.md | 6 ++--- docs/tech/testing-strategy.md | 2 +- 4 files changed, 42 insertions(+), 15 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 6a125c6..ed1168f 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -201,15 +201,10 @@ jobs: - name: Run molecule tests if: env.SKIP != 'true' && steps.prune.outputs.should-run != 'false' env: - GITEA_URL: ${{ github.server_url }} CI_GITEA_API_TOKEN: ${{ secrets.CI_GITEA_API_TOKEN }} CI_GITEA_USERNAME: ${{ vars.CI_GITEA_USERNAME }} - RUN_ID: ${{ github.run_id }} - ANSIBLE_INJECT_INVOCATION: "1" - JOB_NAME: ${{ github.job }} - MATRIX_INDEX: ${{ matrix.runner-index }} - GITEA_REPOSITORY: ${{ github.repository }} DOCKER_HOST: unix:///var/run/docker.sock + ANSIBLE_INJECT_INVOCATION: "1" run: | . .venv/bin/activate 2>/dev/null || true if [ -z "$TEST_PAIRS" ]; then exit 0; fi @@ -220,8 +215,40 @@ jobs: _TOKEN="$CI_GITEA_API_TOKEN"; [ -z "$_TOKEN" ] && _TOKEN="$CI_GITEA_TOKEN" [ -z "$_TOKEN" ] && { echo "Gitea API token not set — skipping Docker login"; exit 0; } echo "$_TOKEN" | docker login git.oblachno.oblachno.fyi -u "$CI_GITEA_USERNAME" --password-stdin - # shellcheck disable=SC2086 # intentional word splitting for argument expansion - python3 -m devx.molecule.molecule_ci_guard $TEST_PAIRS + # Run each molecule test pair sequentially. + # Pairs are 4-part: scenario|platform_name|platform_image|platform_command + # Spaces in platform_command are encoded as __SPACE__. + role_dir="ansible/roles/gitea_runner" + # shellcheck disable=SC2086 # intentional word splitting for pair list + for pair in $TEST_PAIRS; do + IFS='|' read -r scenario platform_name platform_image platform_command <<< "$pair" + platform_command="${platform_command//__SPACE__/ }" + export MOLECULE_PLATFORM_NAME="$platform_name" + export MOLECULE_PLATFORM_IMAGE="$platform_image" + if [ -n "$platform_command" ]; then + export MOLECULE_PLATFORM_COMMAND="$platform_command" + else + unset MOLECULE_PLATFORM_COMMAND + fi + export ANSIBLE_ALLOW_BROKEN_CONDITIONALS=true + echo "--- Running: $scenario on $platform_name ---" + if [ "$scenario" = "default" ]; then + molecule test --cwd "$role_dir" || { + echo "FAILED: $pair — running molecule destroy" + molecule destroy --cwd "$role_dir" 2>/dev/null || true + exit 1 + } + else + molecule test -s "$scenario" --cwd "$role_dir" || { + echo "FAILED: $pair — running molecule destroy" + molecule destroy -s "$scenario" --cwd "$role_dir" 2>/dev/null || true + exit 1 + } + fi + echo "PASSED: $pair" + docker system prune -af --volumes 2>/dev/null || true + done + echo "All molecule tests passed." auto-merge: # Auto-merge runs after validate + molecule-tests pass (or molecule is skipped). diff --git a/AGENTS.md b/AGENTS.md index 7a1d707..2a84ace 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -278,9 +278,9 @@ via `[tool.devx.classify]` in `pyproject.toml`. - Any new file type not in the allowlist **devx module structure** (installed from git, not in this repo): -- `devx.ci.*` — CI/CD automation (run by workflows): release, publish, auto_merge, classify_changes, detect_release_commit, push_badges, doc_coverage, sync_wiki, distribute_molecule, molecule_ci_guard, discover_runners, notify_failure, post_merge, pr_review, validate_commit_msg +- `devx.ci.*` — CI/CD automation (run by workflows): release, publish, auto_merge, classify_changes, detect_release_commit, push_badges, doc_coverage, sync_wiki, distribute_molecule, discover_runners, notify_failure, post_merge, pr_review, validate_commit_msg - `devx.tools.*` — Dev tools (run locally): check_test_speed, configure_repo, install_checkmake, install_tools, setup, generate_badges, create_task, create_pr, pr_status, pr_logs, pr_label, rebase, pr_rebase -- `devx.molecule.*` — Molecule helpers: molecule_all, platforms, discover_runners, distribute_molecule, molecule_ci_guard +- `devx.molecule.*` — Molecule helpers: molecule_all, platforms, discover_runners, distribute_molecule - `devx.gitea_cli` — Tea CLI wrapper - `devx.i18n` — i18n translation system - `devx.config` — Shared configuration (DEVX_* env vars) @@ -348,7 +348,7 @@ Since devx is installed as a package (via `pip install` from git), it is importa | PYTHONPATH | When to use | Example modules | |------------|-------------|-----------------| | `src` | Module imports from `grm` | `devx.ci.auto_merge`, `devx.ci.pr_review`, `devx.ci.pr_review`, `devx.ci.sync_wiki`, `devx.ci.post_merge`, `devx.ci.classify_changes`, `devx.molecule.discover_runners`, `devx.ci.doc_coverage` | -| (none) | Module has no GRM imports | `devx.ci.detect_release_commit`, `devx.molecule.distribute_molecule`, `devx.molecule.molecule_ci_guard`, `devx.ci.push_badges`, `devx.ci.validate_commit_msg` | +| (none) | Module has no GRM imports | `devx.ci.detect_release_commit`, `devx.molecule.distribute_molecule`, `devx.ci.push_badges`, `devx.ci.validate_commit_msg` | **In workflows**, always use `env:` blocks (not inline `PYTHONPATH=value`): ```yaml diff --git a/docs/tech/ci-cd-workflow.md b/docs/tech/ci-cd-workflow.md index 3e15107..96c39cf 100644 --- a/docs/tech/ci-cd-workflow.md +++ b/docs/tech/ci-cd-workflow.md @@ -259,9 +259,9 @@ OS platform matrix (defined in `devx.molecule.platforms`), then splits the resulting test pairs evenly across the requested number of runners. Each pair is encoded as `scenario|platform_name|platform_image|platform_command`. -`devx.molecule.molecule_ci_guard` runs the actual molecule test for a -given test pair, with CI context (Gitea URL, token, run ID) for -reporting results back to the commit status API. +The CI workflow runs each test pair sequentially via a shell loop that +sets the appropriate `MOLECULE_PLATFORM_*` environment variables and +invokes `molecule test` directly. ### Commit Message Validation diff --git a/docs/tech/testing-strategy.md b/docs/tech/testing-strategy.md index e0132a8..3a9e9d7 100644 --- a/docs/tech/testing-strategy.md +++ b/docs/tech/testing-strategy.md @@ -91,7 +91,7 @@ The `molecule-tests` job uses `fromJSON()` to consume the dynamic matrix, and pa `devx.molecule.distribute_molecule` discovers all molecule scenarios under `ansible/roles/*/molecule/` and crosses them with the supported OS platform matrix, then splits the resulting test pairs evenly across the requested number of runners. Each pair is encoded as `scenario|platform_name|platform_image|platform_command`. -`devx.molecule.molecule_ci_guard` runs the actual molecule test for a given test pair, with CI context (Gitea URL, token, run ID) for reporting results back to the commit status API. +The CI workflow runs each test pair sequentially via a shell loop that sets the appropriate `MOLECULE_PLATFORM_*` environment variables and invokes `molecule test` directly. ### Path-based CI filtering