--- name: all_green concurrency: group: ${{ github.head_ref || github.ref }} cancel-in-progress: true on: # yamllint disable-line rule:truthy pull_request: types: - opened - reopened - synchronize branches: - main - stable-* push: branches: - main - stable-* jobs: linters: if: github.event_name == 'pull_request' uses: ./.github/workflows/linters.yml ansible-test: uses: ./.github/workflows/ansible-test.yml coverage: name: Unit test coverage runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 with: python-version: "3.14" - name: Install tox run: python -m pip install --upgrade pip tox - name: Run unit tests with coverage (tox) run: tox -e ansible2.20-py314-with_constraints - name: Rewrite coverage paths to be repo-relative run: | COVERAGE_FILE=$(find .tox -name coverage.xml -type f 2>/dev/null | head -1) if [[ -z "$COVERAGE_FILE" ]]; then echo "::error::coverage.xml not found under .tox" exit 1 fi # Coverage XML uses absolute paths; use absolute prefix so the replacement matches COVERAGE_FILE=$(realpath "$COVERAGE_FILE") # Ensure path stays within workspace (avoid symlink escape) case "$COVERAGE_FILE" in "$GITHUB_WORKSPACE"/*) ;; *) echo "::error::coverage.xml path outside workspace"; exit 1 ;; esac export COLLECTION_PATH=$(dirname "$COVERAGE_FILE") export COVERAGE_FILE echo "COVERAGE_FILE=$COVERAGE_FILE" >> $GITHUB_ENV - name: Upload coverage artifact uses: actions/upload-artifact@v4 with: name: coverage path: ${{ env.COVERAGE_FILE }} all_green: if: ${{ always() }} needs: - linters - ansible-test - coverage runs-on: ubuntu-latest steps: - run: | python -c " required = ['ansible-test', 'coverage'] if '${{ github.event_name }}' == 'pull_request': required = ['linters', 'ansible-test', 'coverage'] results = {'linters': '${{ needs.linters.result }}', 'ansible-test': '${{ needs.ansible-test.result }}', 'coverage': '${{ needs.coverage.result }}'} ok = all(results[j] == 'success' for j in required) skipped_ok = all(results[j] in ('success', 'skipped') for j in results) assert ok and skipped_ok, f'required={required} results={results}' "