-
-
Notifications
You must be signed in to change notification settings - Fork 381
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
Add conditional coverage flags for accurate platform coverage #1260
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,25 +29,25 @@ jobs: | |
uses: beeware/.github/.github/workflows/towncrier-run.yml@main | ||
|
||
package: | ||
name: Python Package | ||
name: Python package | ||
uses: beeware/.github/.github/workflows/python-package-create.yml@main | ||
|
||
unit-tests: | ||
name: Unit tests | ||
needs: [pre-commit, towncrier, package] | ||
needs: [ pre-commit, towncrier, package ] | ||
runs-on: ${{ matrix.platform }}-latest | ||
continue-on-error: ${{ matrix.experimental }} | ||
strategy: | ||
matrix: | ||
platform: [ "macos", "ubuntu", "windows" ] | ||
platform: [ "macOS", "Ubuntu", "Windows" ] | ||
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12-dev" ] | ||
include: | ||
- experimental: false | ||
# Allow dev Python to fail without failing entire job | ||
- python-version: "3.12-dev" | ||
experimental: true | ||
# Run tests against the latest Windows Store Python | ||
- platform: "windows" | ||
- platform: "Windows" | ||
python-version: "winstore" | ||
experimental: false | ||
steps: | ||
|
@@ -57,52 +57,130 @@ jobs: | |
fetch-depth: 0 | ||
|
||
- name: Set up Python | ||
if: matrix.python-version != 'winstore' | ||
if: startswith(matrix.python-version, '3') | ||
uses: actions/[email protected] | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install Windows Store Python | ||
if: matrix.python-version == 'winstore' | ||
uses: beeware/.github/.github/actions/install-win-store-python@main | ||
with: | ||
python-version: "3.11" | ||
|
||
- name: Get packages | ||
- name: Get Packages | ||
uses: actions/[email protected] | ||
with: | ||
name: ${{ needs.package.outputs.artifact-name }} | ||
path: dist | ||
|
||
- name: Install dev dependencies | ||
- name: Install dev Dependencies | ||
run: | | ||
# pip 23.1 has an issue with --user installs. | ||
# See https://github.com/pypa/pip/issues/11982 for details | ||
python -m pip install --upgrade "pip!=23.1" | ||
python -m pip install --upgrade pip | ||
python -m pip install --upgrade setuptools | ||
# We don't actually want to install briefcase; we just | ||
# want the dev extras so we have a known version of tox. | ||
python -m pip install $(ls dist/briefcase-*.whl)[dev] | ||
|
||
- name: Test | ||
id: test | ||
env: | ||
COVERAGE_FILE: ".coverage.${{ matrix.platform }}.${{ matrix.python-version }}" | ||
run: tox -e py --installpkg dist/briefcase-*.whl | ||
|
||
- name: Store coverage data | ||
- name: Store Coverage Data | ||
if: always() && (steps.test.outcome == 'failure' || steps.test.outcome == 'success') | ||
uses: actions/[email protected] | ||
with: | ||
name: coverage-data | ||
path: ".coverage.*" | ||
if-no-files-found: ignore | ||
|
||
- name: Report platform coverage | ||
run: tox -e coverage | ||
coverage-platform: | ||
name: Platform coverage - ${{ matrix.platform }} | ||
runs-on: ${{ matrix.platform }}-latest | ||
needs: unit-tests | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
platform: [ "macOS", "Ubuntu", "Windows" ] | ||
steps: | ||
- name: Checkout | ||
uses: actions/[email protected] | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup Python | ||
uses: actions/[email protected] | ||
with: | ||
python-version: | | ||
3.12-dev | ||
3.11 | ||
3.10 | ||
3.9 | ||
3.8 | ||
|
||
- name: Install dev Dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install --upgrade setuptools | ||
# We don't actually want to install briefcase; we just | ||
# want the dev extras so we have a known version of tox. | ||
python -m pip install -e .[dev] | ||
|
||
- name: Retrieve Coverage Data | ||
uses: actions/[email protected] | ||
with: | ||
name: coverage-data | ||
|
||
coverage: | ||
name: Combine & check coverage. | ||
- name: ${{ matrix.platform }} Coverage Report | ||
env: | ||
COVERAGE_FILE: ".coverage.${{ matrix.platform }}" | ||
run: tox -qe coverage-platform-html-keep | ||
|
||
- name: Python 3.12 on ${{ matrix.platform }} Coverage Report | ||
if: success() || failure() | ||
continue-on-error: true | ||
env: | ||
COVERAGE_FILE: ".coverage.${{ matrix.platform }}.3.12-dev" | ||
run: tox -qe coverage312-html-keep | ||
|
||
- name: Python 3.11 on ${{ matrix.platform }} Coverage Report | ||
if: success() || failure() | ||
env: | ||
COVERAGE_FILE: ".coverage.${{ matrix.platform }}.3.11" | ||
run: tox -qe coverage311-html-keep | ||
|
||
- name: Python 3.10 on ${{ matrix.platform }} Coverage Report | ||
if: success() || failure() | ||
env: | ||
COVERAGE_FILE: ".coverage.${{ matrix.platform }}.3.10" | ||
run: tox -qe coverage310-html-keep | ||
|
||
- name: Python 3.9 on ${{ matrix.platform }} Coverage Report | ||
if: success() || failure() | ||
env: | ||
COVERAGE_FILE: ".coverage.${{ matrix.platform }}.3.9" | ||
run: tox -qe coverage39-html-keep | ||
|
||
- name: Python 3.8 on ${{ matrix.platform }} Coverage Report | ||
if: success() || failure() | ||
env: | ||
COVERAGE_FILE: ".coverage.${{ matrix.platform }}.3.8" | ||
run: tox -qe coverage38-html-keep | ||
|
||
- name: Upload HTML Coverage Report | ||
if: failure() | ||
uses: actions/[email protected] | ||
with: | ||
name: html-platform-coverage-report-${{ matrix.platform }} | ||
path: htmlcov | ||
|
||
coverage-project: | ||
name: Project coverage | ||
runs-on: ubuntu-latest | ||
needs: unit-tests | ||
steps: | ||
- uses: actions/[email protected] | ||
- name: Checkout | ||
uses: actions/[email protected] | ||
with: | ||
fetch-depth: 0 | ||
|
||
|
@@ -113,33 +191,32 @@ jobs: | |
# https://github.com/nedbat/coveragepy/issues/1572#issuecomment-1522546425 | ||
python-version: "3.8" | ||
|
||
- name: Install dev dependencies | ||
- name: Install dev Dependencies | ||
run: | | ||
# pip 23.1 has an issue with --user installs. | ||
# See https://github.com/pypa/pip/issues/11982 for details | ||
python -m pip install --upgrade "pip!=23.1" | ||
python -m pip install --upgrade pip | ||
python -m pip install --upgrade setuptools | ||
# We don't actually want to install briefcase; we just | ||
# want the dev extras so we have a known version of tox. | ||
python -m pip install -e .[dev] | ||
|
||
- name: Retrieve coverage data | ||
- name: Retrieve Coverage Data | ||
uses: actions/[email protected] | ||
with: | ||
name: coverage-data | ||
|
||
- name: Generate coverage report | ||
run: tox -e coverage-html-fail | ||
- name: Project Coverage Report | ||
id: coverage | ||
run: tox -qe coverage-project-html | ||
|
||
- name: Upload HTML report if check failed. | ||
if: ${{ failure() }} | ||
- name: Upload HTML Coverage Report | ||
if: always() && steps.coverage.outcome == 'failure' | ||
uses: actions/[email protected] | ||
with: | ||
name: html-coverage-report | ||
name: html-project-coverage-report | ||
path: htmlcov | ||
|
||
verify-apps: | ||
name: Build App | ||
name: Build app | ||
needs: unit-tests | ||
uses: beeware/.github/.github/workflows/app-build-verify.yml@main | ||
with: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Coverage reporting for a specific versions of Python or a specific platform is now supported. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If what we're generating is a "platform and python version" specific coverage report, and it will pass with 100% on every platform/python combination... is there any reason to not tag this to the end of the testing pass for a platform and python, rather than doing it as a separate step with it's own matrix fanout?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair point. Organic evolution of this PR has definitely influenced this....however, I did want to ensure that incomplete coverage for a single platform/version doesn't abort all of CI. I think the better experience for contributors is the complete picture of coverage when tests are passing.
Thinking about it briefly, failing coverage in the same job as tests will probably require allowing all tests to complete even if tests on one platform fail in order to allow all coverage for all platforms to be available even if only one platform/version fails.
So, some trade-offs involved, I suppose. I will say that checking coverage after the fact definitely increases how long CI runs....(at least until we can prevent having to install all
dev
dependencies just to runcoverage
).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to wanting to provide a full analysis of coverage before failing, the only way to assess coverage across Python versions for a particular platform is to coalesce the coverage files at the end.
But this must be done using the OS for that platform. So, we end up with at least the 3 "Platform coverage" jobs alongside "Project coverage" after the tests.
At that point, if those 3 additional coverage jobs are necessary, the benefit of performing specific Python version coverage there becomes more palatable to 1) allow their failure to fail all of CI but not fail testing and 2) provide better consolidation of the coverage analysis in CI.
P.S.
This is necessary in order for the new conditional coverage rules to work. They operate on
sys.platform
to know when to require/ignore certain code blocks. We could consider spoofing this, though, to potentially allow coverage analysis of a platform while not on that platform. I can at least experiment with that.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This turned out to be a fruitful experiment; I was able to incorporate python version-specific and platform-specific coverage reporting in-line with the existing job matrices.
Although, this has two larger status-quo changes:
Unit tests no longer fast fail
The Verify App Build tests will not run now until unit tests and python version-specific coverage is passing.
Conditional Coverage Reporting with Platform Spoofing #1262