Skip to content

Single coverage upload #159

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .config/dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ fqcn
levelname
levelno
netcommon
oidc
purelib
reqs
setenv
Expand Down
69 changes: 51 additions & 18 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ jobs:
build:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os || 'ubuntu-22.04' }}
permissions:
id-token: write
needs:
- prepare
defaults:
Expand Down Expand Up @@ -88,20 +86,13 @@ jobs:
- name: tox -e ${{ matrix.passed_name }}
run: python3 -m tox -e ${{ matrix.passed_name }}

- name: Upload coverage data
if: ${{ startsWith(matrix.passed_name, 'py') }}
uses: codecov/codecov-action@v4
with:
name: ${{ matrix.passed_name }}
fail_ci_if_error: true
verbose: true # optional (default = false)
use_oidc: true # cspell:ignore oidc

- name: Archive logs
- name: Archive logs and coverage data
uses: actions/upload-artifact@v4
with:
name: logs-${{ matrix.name }}.zip
path: .tox/**/log/
path: |
.tox/**/log/
.tox/**/coverage.xml

- name: Report failure if git reports dirty status
run: |
Expand All @@ -112,26 +103,68 @@ jobs:
exit 99
fi
# https://github.com/actions/toolkit/issues/193
check: # This job does nothing and is only used for the branch protection

check:
if: always()
permissions:
pull-requests: write # allow codenotify to comment on pull-request
id-token: write
checks: read

needs:
- build

runs-on: ubuntu-latest

steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- run: pip3 install 'coverage>=7.5.1'

- name: Merge logs into a single archive
uses: actions/upload-artifact/merge@v4
with:
name: logs.zip
pattern: logs-*.zip
separate-directories: true

- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: logs.zip

- name: Check for expected number of coverage.xml reports
run: |
JOBS_PRODUCING_COVERAGE=5
if [ "$(find . -name coverage.xml | wc -l | bc)" -ne "${JOBS_PRODUCING_COVERAGE}" ]; then
echo "::error::Number of coverage.xml files was not the expected one (${JOBS_PRODUCING_COVERAGE}): $(find . -name coverage.xml |xargs echo)"
exit 1
fi

- name: Upload coverage data
uses: codecov/codecov-action@v4
with:
name: ${{ matrix.passed_name }}
fail_ci_if_error: true
use_oidc: true

- name: Check codecov.io status
if: github.event_name == 'pull_request'
uses: coactions/codecov-status@main

- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}

- name: Check out src from Git
uses: actions/checkout@v4
- name: Delete Merged Artifacts
uses: actions/upload-artifact/merge@v4
with:
delete-merged: true

- name: Notify repository owners about lint change affecting them
- name: Notify repository owners about changes affecting them
uses: sourcegraph/codenotify@v0.6.4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
7 changes: 2 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,11 @@ repository = "https://github.com/ansible/ansible-dev-environment"

[tool.coverage.report]
exclude_lines = ["if TYPE_CHECKING:", "pragma: no cover"]
# Increase it just so it would pass on any single-python run
fail_under = 42
# During development we might remove code (files) with coverage data, and we dont want to fail:
ignore_errors = true
omit = ["tests/*"]
fail_under = 72
show_missing = true
skip_covered = true
skip_empty = true
sort = "Cover"

[tool.coverage.run]
source_pkgs = ["ansible_dev_environment"]
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ commands =
coverage combine -q --data-file={envdir}/.coverage {envdir}/.coverage.* && \
coverage xml --data-file={envdir}/.coverage -o {envdir}/coverage.xml --ignore-errors --fail-under=0 && \
COVERAGE_FILE={envdir}/.coverage coverage lcov --fail-under=0 --ignore-errors -q && \
COVERAGE_FILE={envdir}/.coverage coverage report --fail-under=0 --ignore-errors \
COVERAGE_FILE={envdir}/.coverage coverage report --ignore-errors \
"
allowlist_externals =
git
Expand Down
Loading