Skip to content

Commit 4bee921

Browse files
committed
Enable codecov reporting and checking
1 parent 66ee464 commit 4bee921

File tree

4 files changed

+51
-17
lines changed

4 files changed

+51
-17
lines changed

.github/workflows/tox.yml

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ jobs:
3434
3535
tox:
3636
name: ${{ matrix.name }} / python ${{ matrix.python_version }}
37+
environment: test
3738
runs-on: ubuntu-20.04
3839
needs: pre
3940
strategy:
@@ -63,11 +64,47 @@ jobs:
6364
continue-on-error: ${{ matrix.devel || false }}
6465
run: python3 -m tox -e ${{ matrix.passed_name }}
6566

67+
- name: Archive logs
68+
uses: actions/upload-artifact@v4
69+
with:
70+
name: logs-${{ matrix.name }}.zip
71+
path: .tox/**/log/
72+
73+
- name: Upload coverage data
74+
if: ${{ startsWith(matrix.name, 'py') }}
75+
uses: codecov/codecov-action@v4
76+
with:
77+
name: ${{ matrix.name }}
78+
token: ${{ secrets.CODECOV_TOKEN }}
79+
verbose: true
80+
fail_ci_if_error: true
81+
82+
- name: Report failure if git reports dirty status
83+
run: |
84+
if [[ -n $(git status -s) ]]; then
85+
# shellcheck disable=SC2016
86+
echo -n '::error file=git-status::'
87+
printf '### Failed as git reported modified and/or untracked files\n```\n%s\n```\n' "$(git status -s)" | tee -a "$GITHUB_STEP_SUMMARY"
88+
exit 99
89+
fi
90+
# https://github.com/actions/toolkit/issues/193
6691
tox_passed:
92+
if: always()
93+
6794
needs: tox
6895
runs-on: ubuntu-latest
6996
steps:
70-
- run: >-
71-
python -c "assert set([
72-
'${{ needs.tox.result }}',
73-
]) == {'success'}"
97+
- name: Merge logs into a single archive
98+
uses: actions/upload-artifact/merge@v4
99+
with:
100+
name: logs.zip
101+
pattern: logs*.zip
102+
delete-merged: true
103+
104+
- name: Check codecov.io status
105+
uses: coactions/codecov-status@main
106+
107+
- name: Decide whether the needed jobs succeeded or failed
108+
uses: re-actors/alls-green@release/v1
109+
with:
110+
jobs: ${{ toJSON(needs) }}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ ansible-dev-tools 0.2.0a0
4444
ansible-lint 24.2.0
4545
ansible-navigator 24.2.0
4646
ansible-sign 0.1.1
47-
molecule 6.0.3
47+
molecule 24.2.0
4848
pytest-ansible 24.1.2
4949
tox-ansible 24.2.0
5050
```

codecov.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
comment: false
2+
coverage:
3+
status:
4+
patch: true # we want github annotations

tox.ini

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ set_env =
3232
PRE_COMMIT_COLOR = always
3333
TERM = xterm-256color
3434
commands =
35-
coverage run --debug=trace -m pytest {posargs}
36-
sh -c "coverage combine -q .tox/.coverage.* && coverage xml || true && coverage report"
35+
coverage run -m pytest {posargs}
36+
coverage xml
37+
coverage report
3738
git diff --exit-code
3839
allowlist_externals =
3940
bash
@@ -76,11 +77,13 @@ skip_install = true
7677
set_env =
7778
NO_COLOR = 1
7879
TERM = dump
80+
PIP_CONSTRAINT = {toxinidir}/.config/constraints.txt
7981
commands =
8082
bash -c "SETUPTOOLS_SCM_PRETEND_VERSION=$(git describe --tags --abbrev=0) pip install -q -e '.[docs]'"
8183
adt --version
8284
python3 tools/update-readme.py
8385
mkdocs {posargs:build --strict --site-dir=_readthedocs/html/}
86+
git diff --exit-code
8487

8588
[testenv:deps]
8689
description = Bump all test dependencies
@@ -106,13 +109,3 @@ deps =
106109
extras =
107110
commands =
108111
coverage erase
109-
110-
[testenv:report]
111-
description = Produce coverage report
112-
skip_install = true
113-
deps =
114-
coverage[toml]
115-
extras =
116-
commands =
117-
coverage report
118-
cat .tox/.tmp/.mypy/index.txt

0 commit comments

Comments
 (0)