[manual backport stable-6] Fix CI Test Collision (#1162) (#1167)

* Fix CI Test Collision (#1162)

* Fix CI concurrency issue

* More CI fixes

* Fix coverage job install

* Install correct test dependencies

(cherry picked from commit d211f316ad)

* Restore cancel-in-progress: true
This commit is contained in:
Bianca Henderson
2026-06-30 12:01:51 -04:00
committed by GitHub
parent a523a195cb
commit edee5c994d
6 changed files with 66 additions and 97 deletions

View File

@@ -33,49 +33,37 @@ jobs:
coverage:
name: Unit test coverage
runs-on: ubuntu-latest
needs:
- sanity
- units
env:
# stable-6 is tested against ansible-core stable-2.18 (see integration-tests.yaml).
ANSIBLE_CORE_REF: "stable-2.18"
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
path: ansible_collections/kubernetes/core
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install Ansible (ansible-test)
- name: Run unit tests with coverage
working-directory: ansible_collections/kubernetes/core
env:
PYTHONPATH: ${{ github.workspace }}
run: |
python -m pip install --upgrade pip
python -m pip install "https://github.com/ansible/ansible/archive/${ANSIBLE_CORE_REF}.tar.gz"
- name: Run unit tests with coverage
run: ansible-test units --venv --coverage --python 3.12 --requirements
- name: Combine and emit coverage XML
run: |
ansible-test coverage combine --venv --python 3.12 --requirements
ansible-test coverage xml --venv --python 3.12 --requirements
- name: Prepare coverage.xml for SonarCloud
run: |
set -euo pipefail
mkdir -p "${GITHUB_WORKSPACE}"
xml=$(find tests/output/reports -maxdepth 1 -name '*.xml' ! -name '*powershell*' | head -1)
test -n "${xml}"
cp "${xml}" "${GITHUB_WORKSPACE}/coverage.xml"
# Strip workspace prefix so Sonar sees repo-relative paths (same idea as amazon.aws path rewrite)
sed -i "s#${GITHUB_WORKSPACE}/##g" "${GITHUB_WORKSPACE}/coverage.xml"
python -m pip install ansible-compat
python -m pip install https://github.com/ansible/ansible/archive/stable-2.19.tar.gz
# Same deps as the units matrix (build_install_collection); do not use
# tests/unit/requirements.txt — its kubernetes pin breaks test_core.py.
python -m pip install -r requirements.txt -r test-requirements.txt
python -m coverage run --source=plugins -m pytest tests/unit \
--ansible-host-pattern localhost
python -m coverage xml -o coverage.xml
- name: Upload coverage artifact
uses: actions/upload-artifact@v4
with:
name: coverage
path: ${{ github.workspace }}/coverage.xml
path: ansible_collections/kubernetes/core/coverage.xml
all_green:
if: ${{ always() }}
@@ -125,17 +113,3 @@ jobs:
print('all_green OK', results)
"
sonarcloud:
name: SonarCloud scan
needs:
- all_green
- coverage
if: >-
${{ needs.all_green.result == 'success'
&& (github.event_name == 'push'
|| (github.event_name == 'pull_request'
&& github.event.pull_request.head.repo.full_name == github.repository)) }}
uses: ./.github/workflows/sonarcloud.yml
secrets:
ANSIBLE_COLLECTIONS_ORG_SONAR_TOKEN_CICD_BOT: ${{ secrets.ANSIBLE_COLLECTIONS_ORG_SONAR_TOKEN_CICD_BOT }}