Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 26 additions & 5 deletions .github/workflows/all_green_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 '<coverage' "${GITHUB_WORKSPACE}/coverage.xml"; then
echo "::error::coverage.xml does not look like Cobertura XML"
exit 1
fi
test -s "${GITHUB_WORKSPACE}/coverage.xml"

- name: Upload coverage artifact
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -131,4 +152,4 @@ jobs:
&& 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 }}
ANSIBLE_COLLECTIONS_ORG_SONAR_TOKEN_CICD_BOT: ${{ secrets.ANSIBLE_COLLECTIONS_ORG_SONAR_TOKEN_CICD_BOT }}
Loading