Skip to content

Run GCOVR CI

Run GCOVR CI #48

Workflow file for this run

# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Run GCOVR CI
on:
workflow_dispatch: # For manual triggering
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, edited]
jobs:
changelog-check:
runs-on: ubuntu-22.04
env:
PR_BODY: "${{ github.event.pull_request.body }}"
CHANGELOG_ISSUE: ":issue:`${{ github.event.pull_request.number }}`"
steps:
- uses: actions/checkout@v4
- name: Check if PR is mentioned in changelog
if: ${{ always() }}
run: |
if [ -z "${{ github.event.pull_request.number }}" ]; then
echo 'No PR defined'
else
if grep -qE '^\[no changelog\]' <<<"$PR_BODY"; then
echo 'Marker "[no changelog]" found in PR body'
if [ "$(grep -F "$CHANGELOG_ISSUE" CHANGELOG.rst)" != "" ]; then
echo "ERROR: $CHANGELOG_ISSUE found in CHANGELOG.rst."
exit 1
else
echo "OK: $CHANGELOG_ISSUE not found in CHANGELOG.rst"
fi
else
echo 'Marker "[no changelog]" not found in PR body'
if [ "$(grep -F "$CHANGELOG_ISSUE" CHANGELOG.rst)" == "" ]; then
echo "ERROR: $CHANGELOG_ISSUE not found in CHANGELOG.rst."
exit 1
else
echo "OK: $CHANGELOG_ISSUE found in CHANGELOG.rst"
fi
fi
fi
exit 0
spell-check:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Install spellchecker
run: |
npm install -g cspell@latest
- name: Run spellchecker
run: |
cspell --config cspell.json --color --show-suggestions '**'
upload-coverage:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Copy coverage reports
run: |
mkdir -p /tmp/coverage-upload
rm -rf /tmp/coverage-upload/*
cp --target-directory=/tmp/coverage-upload ./tests/excl-line-branch/reference/gcc-5/*.*
cp --target-directory=/tmp/coverage-upload --force ./tests/excl-line-branch/reference/gcc-14/*.*
- name: Upload coverage
uses: actions/upload-artifact@v4
with:
name: "coverage"
path: /tmp/coverage-upload/*.*
host:
needs: [changelog-check, spell-check, upload-coverage]
uses: ./.github/workflows/gcovr-ci-job.yml
with:
os: ${{ matrix.os }}
gcc: ${{ matrix.gcc }}
python-version: ${{ matrix.python-version }}
upload-app: ${{ matrix.upload-app || false }} # Explicit set to false if not set
secrets: inherit
# Testing strategy
# ----------------
#
# We have different axes of the testing matrix:
#
# OS: Linux, Windows
# Compiler: GCC-5 to GCC-14, Clang-10 to CLANG-16
# Python: 3.9 -- 3.13, pypy3
#
# Instead of testing all combinations, we try to achieve full coverage
# across each axis. The main test matrix just represents the Python axis on
# Linux. The OS=Windows and Compiler axis are added manually.
#
# Some cases (Clang compiler) are handled via the Docker-tests.
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04]
gcc: [gcc-11]
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', 'pypy-3.10']
include:
# Test additional compilers with Linux.
# Note that all compiler versions are also handled via Docker.
- os: ubuntu-22.04
gcc: gcc-11
python-version: '3.13'
upload-app: true
# Test minimum and maximum Python version on Windows.
- os: windows-2019
gcc: gcc
python-version: '3.9'
- os: windows-2019
gcc: gcc
python-version: '3.13'
upload-app: true
# Test minimum and maximum Python version on Mac OS.
- os: macos-13
gcc: gcc
python-version: '3.13'
upload-app: true
- os: macos-14
gcc: gcc
python-version: '3.9'
- os: macos-14
gcc: gcc-13
python-version: '3.13'
upload-app: true
- os: macos-15
gcc: gcc
python-version: '3.13'
upload-app: true
docker:
needs: [changelog-check, spell-check, upload-coverage]
uses: ./.github/workflows/gcovr-ci-job.yml
with:
container: true
gcc: ${{ matrix.gcc }}
secrets: inherit
strategy:
fail-fast: false
matrix:
gcc: [gcc-5, gcc-6, gcc-8, gcc-9, gcc-10, gcc-11, gcc-12, gcc-13, gcc-14, clang-10, clang-13, clang-14, clang-15, clang-16]
deployment:
needs: [host, docker]
runs-on: ubuntu-22.04
permissions:
contents: write
env:
FORCE_COLOR: "1"
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 75
fetch-tags: true
- name: Workaround because fetch-tags doesn't work with git 2.48 in the GH actions
run: |
git fetch --tags
- name: Set up Python
uses: "./.github/actions/setup-python"
with:
os: ubuntu-22.04
python-version: 3.12
- name: Set up environment
run: |
if [ -z "$(sed -n '/Next Release/ p' CHANGELOG.rst)" ] ; then
echo "GCOVR_VERSION=$(sed -n 's/^\([1-9][0-9]*\.[0-9][0-9]*\).*/\1/ p' CHANGELOG.rst | head -n 1)" >> $GITHUB_ENV
else
echo "GCOVR_VERSION=" >> $GITHUB_ENV
fi
- name: Create new tag without pushing to get the correct name of the apps
if: ${{ (github.repository == 'gcovr/gcovr') && env.GCOVR_VERSION != '' }}
run: |
# Set git user info
git config --global user.email "[email protected]"
git config --global user.name "gcovr authors"
# Create the tag and print the output.
git tag -a "$GCOVR_VERSION" -m "$GCOVR_VERSION ($(date -I))"
git tag --list -n "$GCOVR_VERSION"
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install nox requests
- name: Build and check the wheel
run: |
nox --non-interactive --session build_wheel
- name: Upload distribution
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/**
- name: Generate documentation
run: |
nox --non-interactive --session doc
- name: Set release notes as job summary
run: |
(
echo '''
# $GcovrVersion
'''
cat doc/build/release_notes.md
) >> $GITHUB_STEP_SUMMARY
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: build
pattern: app-*
merge-multiple: true
- name: List standalone applications
run: |
ls -al build
- name: Push new tag
if: ${{ (github.repository == 'gcovr/gcovr') && (github.event.ref == 'refs/heads/main') && env.GCOVR_VERSION != '' }}
run: |
git push origin "refs/tags/$GCOVR_VERSION"
- name: Create release and upload build artifacts
if: ${{ (github.repository == 'gcovr/gcovr') && (github.event.ref == 'refs/heads/main') && (env.GCOVR_VERSION != '') }}
uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191
with:
tag_name: ${{ env.GCOVR_VERSION }}
body_path: doc/build/release_notes.md
files: build/*
- name: Publish to PyPi
if: ${{ (github.repository == 'gcovr/gcovr') && (github.event.ref == 'refs/heads/main') && (env.GCOVR_VERSION != '') }}
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
nox --session upload_wheel