Skip to content

Commit

Permalink
✨ Upload standalone applications as release artifacts (gcovr#941)
Browse files Browse the repository at this point in the history
* Add copy step to artifacts folder when  check_bundled_app is run in CI
* Add check with Apple silicon (M1)
* Upload artifacts in test workflow
* Upload release artifacts on release

---------

Co-authored-by: Michael Förderer <[email protected]>
  • Loading branch information
s-weigand and Spacetown authored Aug 9, 2024
1 parent a11f192 commit b45621b
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 10 deletions.
49 changes: 44 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ on:
- main
pull_request:
types: [opened, synchronize, reopened, edited]
release:
types: [published]

jobs:

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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/*
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ __pycache__

# MacOS
.DS_Store

# CI standalone app folder
/artifacts
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
27 changes: 22 additions & 5 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import re
import socket
import sys
from pathlib import Path
from time import sleep
from typing import Tuple
import requests
Expand Down Expand Up @@ -85,6 +86,8 @@
"txt",
]

CI_RUN = "GITHUB_ACTION" in os.environ

nox.options.sessions = ["qa"]


Expand Down Expand Up @@ -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"]
Expand Down Expand Up @@ -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")


Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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"
)
Expand Down

0 comments on commit b45621b

Please sign in to comment.