Skip to content

Commit 1465ca1

Browse files
authored
Single coverage upload (#159)
* Single coverage upload * rm test file * Update fail value * Revise check order * Correct fail under * Revise check * The covergae file has been combined * Wrong coverage file * Delete at end * rm checkout * no cache
1 parent 21f196d commit 1465ca1

File tree

4 files changed

+55
-24
lines changed

4 files changed

+55
-24
lines changed

.config/dictionary.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ fqcn
1616
levelname
1717
levelno
1818
netcommon
19+
oidc
1920
purelib
2021
reqs
2122
setenv

.github/workflows/tox.yml

Lines changed: 51 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ jobs:
4040
build:
4141
name: ${{ matrix.name }}
4242
runs-on: ${{ matrix.os || 'ubuntu-22.04' }}
43-
permissions:
44-
id-token: write
4543
needs:
4644
- prepare
4745
defaults:
@@ -88,20 +86,13 @@ jobs:
8886
- name: tox -e ${{ matrix.passed_name }}
8987
run: python3 -m tox -e ${{ matrix.passed_name }}
9088

91-
- name: Upload coverage data
92-
if: ${{ startsWith(matrix.passed_name, 'py') }}
93-
uses: codecov/codecov-action@v4
94-
with:
95-
name: ${{ matrix.passed_name }}
96-
fail_ci_if_error: true
97-
verbose: true # optional (default = false)
98-
use_oidc: true # cspell:ignore oidc
99-
100-
- name: Archive logs
89+
- name: Archive logs and coverage data
10190
uses: actions/upload-artifact@v4
10291
with:
10392
name: logs-${{ matrix.name }}.zip
104-
path: .tox/**/log/
93+
path: |
94+
.tox/**/log/
95+
.tox/**/coverage.xml
10596
10697
- name: Report failure if git reports dirty status
10798
run: |
@@ -112,26 +103,68 @@ jobs:
112103
exit 99
113104
fi
114105
# https://github.com/actions/toolkit/issues/193
115-
check: # This job does nothing and is only used for the branch protection
106+
107+
check:
116108
if: always()
117109
permissions:
118110
pull-requests: write # allow codenotify to comment on pull-request
111+
id-token: write
112+
checks: read
119113

120114
needs:
121115
- build
122-
123116
runs-on: ubuntu-latest
124117

125118
steps:
119+
- name: Set up Python
120+
uses: actions/setup-python@v5
121+
with:
122+
python-version: "3.12"
123+
124+
- run: pip3 install 'coverage>=7.5.1'
125+
126+
- name: Merge logs into a single archive
127+
uses: actions/upload-artifact/merge@v4
128+
with:
129+
name: logs.zip
130+
pattern: logs-*.zip
131+
separate-directories: true
132+
133+
- name: Download artifacts
134+
uses: actions/download-artifact@v4
135+
with:
136+
name: logs.zip
137+
138+
- name: Check for expected number of coverage.xml reports
139+
run: |
140+
JOBS_PRODUCING_COVERAGE=5
141+
if [ "$(find . -name coverage.xml | wc -l | bc)" -ne "${JOBS_PRODUCING_COVERAGE}" ]; then
142+
echo "::error::Number of coverage.xml files was not the expected one (${JOBS_PRODUCING_COVERAGE}): $(find . -name coverage.xml |xargs echo)"
143+
exit 1
144+
fi
145+
146+
- name: Upload coverage data
147+
uses: codecov/codecov-action@v4
148+
with:
149+
name: ${{ matrix.passed_name }}
150+
fail_ci_if_error: true
151+
use_oidc: true
152+
153+
- name: Check codecov.io status
154+
if: github.event_name == 'pull_request'
155+
uses: coactions/codecov-status@main
156+
126157
- name: Decide whether the needed jobs succeeded or failed
127158
uses: re-actors/alls-green@release/v1
128159
with:
129160
jobs: ${{ toJSON(needs) }}
130161

131-
- name: Check out src from Git
132-
uses: actions/checkout@v4
162+
- name: Delete Merged Artifacts
163+
uses: actions/upload-artifact/merge@v4
164+
with:
165+
delete-merged: true
133166

134-
- name: Notify repository owners about lint change affecting them
167+
- name: Notify repository owners about changes affecting them
135168
uses: sourcegraph/codenotify@v0.6.4
136169
env:
137170
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

pyproject.toml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,11 @@ repository = "https://github.com/ansible/ansible-dev-environment"
4242

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

5451
[tool.coverage.run]
5552
source_pkgs = ["ansible_dev_environment"]

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ commands =
4040
coverage combine -q --data-file={envdir}/.coverage {envdir}/.coverage.* && \
4141
coverage xml --data-file={envdir}/.coverage -o {envdir}/coverage.xml --ignore-errors --fail-under=0 && \
4242
COVERAGE_FILE={envdir}/.coverage coverage lcov --fail-under=0 --ignore-errors -q && \
43-
COVERAGE_FILE={envdir}/.coverage coverage report --fail-under=0 --ignore-errors \
43+
COVERAGE_FILE={envdir}/.coverage coverage report --ignore-errors \
4444
"
4545
allowlist_externals =
4646
git

0 commit comments

Comments
 (0)