diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e480043330..9aab19650f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,6 +10,8 @@ on: - main pull_request: types: [opened, synchronize, reopened, edited] + release: + types: [published] jobs: @@ -118,7 +120,8 @@ jobs: python-version: '3.9' - os: ubuntu-22.04 gcc: gcc-11 - python-version: '3.11' + python-version: '3.12' + upload-app: true # Test minimum and maximum Python version on Windows. - os: windows-2019 @@ -127,14 +130,24 @@ jobs: - os: windows-2019 gcc: gcc python-version: '3.12' + upload-app: true # Test minimum and maximum Python version on Mac OS. - os: macos-12 gcc: gcc - python-version: '3.8' - - os: macos-12 + python-version: '3.12' + upload-app: true + - os: macos-13 + gcc: gcc + python-version: '3.12' + upload-app: true + - os: macos-14 + gcc: gcc + python-version: '3.9' + - os: macos-14 gcc: gcc-13 python-version: '3.12' + upload-app: true steps: - uses: actions/checkout@v4 @@ -145,8 +158,8 @@ jobs: case "${{ matrix.os }}/${{ matrix.gcc }}/${{ matrix.python-version }}" in ubuntu-22.04/gcc-11/3.11) USE_COVERAGE=true ;; windows-2019/gcc-8/3.12) USE_COVERAGE=true ;; - macos-12/gcc-13/3.12) USE_COVERAGE=true ;; - macos-12/gcc/3.8) USE_COVERAGE=true ;; + macos-14/gcc/3.9) USE_COVERAGE=true ;; + macos-14/gcc-13/3.12) USE_COVERAGE=true ;; *) USE_COVERAGE=false ;; esac echo "USE_COVERAGE=$USE_COVERAGE" >> $GITHUB_ENV @@ -261,6 +274,12 @@ jobs: run: | nox --non-interactive --session bundle_app if: ${{ ! startsWith(matrix.python-version,'pypy') }} + - name: Upload app bundle artifacts + if: ${{ matrix.upload-app == true }} + uses: actions/upload-artifact@v4 + with: + name: app-${{ matrix.os }} + path: artifacts/gcovr* - name: Build wheel run: | nox --non-interactive --session build_wheel @@ -351,3 +370,23 @@ jobs: - name: Check wheel (in container) run: | python3 -m nox --non-interactive --session "docker_run_compiler(${{ matrix.gcc }})" -- --session check_wheel + + upload-release-artifacts: + name: Upload standalone applications as release artifacts + runs-on: ubuntu-22.04 + if: github.event_name == 'release' + permissions: + contents: write + needs: [build, run-docker] + steps: + - name: Download App Artifacts + uses: actions/download-artifact@v4 + with: + path: app + pattern: app-* + merge-multiple: true + + - name: Upload Release Artifacts + uses: softprops/action-gh-release@v2 + with: + files: app/* diff --git a/.gitignore b/.gitignore index b0e46753d5..e9c06d6fa9 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,6 @@ __pycache__ # MacOS .DS_Store + +# CI standalone app folder +/artifacts diff --git a/CHANGELOG.rst b/CHANGELOG.rst index be62aab541..0d38ff5b61 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -17,6 +17,7 @@ New features and notable changes: - In Azure pipelines or GitHub actions errors and warnings are printed in an additional format captured by the CI. (:issue:`904`) - Detect suspicious counter values in ``gcov`` output. (:issue:`903`) - Add :option:`--html-single-page` to create a single page report (static or with Javascript). (:issue:`916`) +- Upload standalone applications as release artifacts. (:issue:`941`) Bug fixes and small improvements: diff --git a/noxfile.py b/noxfile.py index e1b284077b..ea6099954b 100644 --- a/noxfile.py +++ b/noxfile.py @@ -24,6 +24,7 @@ import re import socket import sys +from pathlib import Path from time import sleep from typing import Tuple import requests @@ -85,6 +86,8 @@ "txt", ] +CI_RUN = "GITHUB_ACTION" in os.environ + nox.options.sessions = ["qa"] @@ -215,7 +218,7 @@ def doc(session: nox.Session) -> None: if not GCOVR_ISOLATED_TEST and not ( # Github actions on MacOs can't use Docker platform.system() == "Darwin" - and "GITHUB_ACTION" in os.environ + and CI_RUN ): docker_build_compiler(session, "gcc-8") session._runner.posargs = ["-s", "tests", "--", "-k", "test_example"] @@ -276,16 +279,15 @@ def tests(session: nox.Session) -> None: if "--" not in args: args += ["--"] + DEFAULT_TEST_DIRECTORIES - running_locally = os.environ.get("GITHUB_ACTIONS") is None session.run( "python", *args, - success_codes=[0, 1] if running_locally and coverage_args else [0], + success_codes=[0, 1] if not CI_RUN and coverage_args else [0], ) if os.environ.get("USE_COVERAGE") == "true": session.run("coverage", "xml") - if running_locally: + if not CI_RUN: session.run("coverage", "html") @@ -373,6 +375,21 @@ def check_bundled_app(session: nox.Session) -> None: f"./gcovr --{format} $TMPDIR/out.{format}", external=True, ) + if CI_RUN: + executable = list(Path().glob("build/gcovr*"))[0] + if platform.system() == "Windows": + platform_suffix = "win" + elif platform.system() == "Darwin": + platform_suffix = "macos" + else: + platform_suffix = "linux" + dest_path = ( + Path() + / "artifacts" + / f"{executable.stem}-{platform_suffix}-{platform.machine()}{executable.suffix}" + ) + dest_path.parent.mkdir(parents=True, exist_ok=True) + executable.rename(dest_path) @nox.session() @@ -537,7 +554,7 @@ def docker_build_compiler(session: nox.Session, version: str) -> None: set_environment(session, version) container_id = docker_container_id(session, version) cache_options = [] - if "GITHUB_ACTIONS" in os.environ: + if CI_RUN: session.log( "Create a builder because the default on doesn't support the gha cache" )