diff --git a/.github/workflows/all_green_check.yml b/.github/workflows/all_green_check.yml index 463c0cc..785baa4 100644 --- a/.github/workflows/all_green_check.yml +++ b/.github/workflows/all_green_check.yml @@ -35,6 +35,16 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 + with: + # ansible-test requires cwd under .../ansible_collections/{namespace}/{name}/ + path: ansible_collections/amazon/cloud + + - name: Checkout amazon.aws dependency + uses: ansible-network/github_actions/.github/actions/checkout_dependency@47822b51aee957080e811cc434443c4e3bb9569a + with: + repository: ansible-collections/amazon.aws + path: ansible_collections/amazon/aws + ref: main - name: Set up Python uses: actions/setup-python@v5 @@ -47,22 +57,33 @@ jobs: python -m pip install "https://github.com/ansible/ansible/archive/${ANSIBLE_CORE_REF}.tar.gz" - name: Run unit tests with coverage + working-directory: ansible_collections/amazon/cloud run: ansible-test units --venv --coverage --python 3.10 --requirements - name: Combine and emit coverage XML + working-directory: ansible_collections/amazon/cloud run: | ansible-test coverage combine --venv --python 3.10 --requirements ansible-test coverage xml --venv --python 3.10 --requirements - name: Prepare coverage.xml for SonarCloud + env: + COLLECTION_DIR: ${{ github.workspace }}/ansible_collections/amazon/cloud run: | set -euo pipefail - mkdir -p "${GITHUB_WORKSPACE}" - xml=$(find tests/output/reports -maxdepth 1 -name '*.xml' ! -name '*powershell*' | head -1) - test -n "${xml}" + xml=$(find "${COLLECTION_DIR}/tests/output/reports" -maxdepth 1 -name '*.xml' ! -name '*powershell*' | head -1) + if [[ -z "${xml}" ]]; then + echo "::error::coverage XML not found under tests/output/reports" + exit 1 + fi 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" + sed -i 's#ansible_collections/amazon/cloud/##g' "${GITHUB_WORKSPACE}/coverage.xml" + if ! grep -q '