Skip to content
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

Conditional Coverage Reporting with Platform Spoofing #1262

Merged
merged 17 commits into from
May 13, 2023
Merged
Show file tree
Hide file tree
Changes from 14 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
77 changes: 47 additions & 30 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,18 @@ on:
description: "Name of the uploaded artifact; use for artifact retrieval."
value: ${{ jobs.package.outputs.artifact-name }}

defaults:
run:
shell: bash # https://github.com/beeware/briefcase/pull/912

# Cancel active CI runs for a PR before starting another run
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

defaults:
run:
shell: bash # https://github.com/beeware/briefcase/pull/912

env:
FORCE_COLOR: "1"

jobs:
pre-commit:
name: Pre-commit checks
Expand All @@ -29,15 +32,16 @@ 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:
fail-fast: false
matrix:
platform: [ "macos", "ubuntu", "windows" ]
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12-dev" ]
Expand All @@ -48,7 +52,7 @@ jobs:
experimental: true
# Run tests against the latest Windows Store Python
- platform: "windows"
python-version: "winstore"
python-version: "winstore3.11"
experimental: false
steps:
- name: Checkout
Expand All @@ -57,52 +61,59 @@ jobs:
fetch-depth: 0

- name: Set up Python
if: matrix.python-version != 'winstore'
if: startswith(matrix.python-version, '3')
uses: actions/setup-python@v4.6.0
with:
python-version: ${{ matrix.python-version }}

- name: Install Windows Store Python
if: matrix.python-version == 'winstore'
if: startswith(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/download-artifact@v3.0.2
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() && contains('success,failure', steps.test.outcome)
uses: actions/upload-artifact@v3.1.2
with:
name: coverage-data
path: ".coverage.*"
if-no-files-found: ignore

- name: Report platform coverage
run: tox -e coverage
- name: Report Platform Coverage
id: coverage
if: always() && contains('success,failure', steps.test.outcome)
# coverage reporting must use the same Python version used to produce coverage
run: tox -qe coverage$(echo '${{ matrix.python-version }}' | tr -dc '0-9')

coverage:
name: Combine & check coverage.
name: Project coverage
runs-on: ubuntu-latest
needs: unit-tests
if: always() && contains('success,failure', needs.unit-tests.result)
steps:
- uses: actions/checkout@v3.5.2
- name: Checkout
uses: actions/checkout@v3.5.2
with:
fetch-depth: 0

Expand All @@ -113,33 +124,39 @@ 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/download-artifact@v3.0.2
with:
name: coverage-data

- name: Generate coverage report
run: tox -e coverage-html-fail
- name: Platform Coverage Reports
id: platform-coverage
run: >
tox p --parallel-no-spinner -qe
coverage-ci-platform-linux,coverage-ci-platform-macos,coverage-ci-platform-windows

- name: Project Coverage Report
id: project-coverage
if: always() || contains('success,failure', needs.platform-coverage.result)
run: tox -qe coverage-ci-project-html

- name: Upload HTML report if check failed.
if: ${{ failure() }}
- name: Upload Project Coverage HTML Report
if: always() && steps.project-coverage.outcome == 'failure'
uses: actions/upload-artifact@v3.1.2
with:
name: html-coverage-report
name: html-coverage-report-project
path: htmlcov

verify-apps:
name: Build App
name: Build app
needs: unit-tests
uses: beeware/.github/.github/workflows/app-build-verify.yml@main
with:
Expand Down
1 change: 1 addition & 0 deletions changes/1262.misc.rst
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.
Loading