Skip to content

Commit

Permalink
Measure coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
perseoGI committed Dec 18, 2024
1 parent 1c148d7 commit 5f07cf9
Show file tree
Hide file tree
Showing 4 changed files with 170 additions and 80 deletions.
71 changes: 48 additions & 23 deletions .github/workflows/linux-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ concurrency:
cancel-in-progress: true

jobs:

##############################################################################
# LINUX ENVIRONMENT #
##############################################################################
#
build_container:
runs-on: ubuntu-latest
outputs:
Expand Down Expand Up @@ -44,17 +49,19 @@ jobs:
docker build -t ghcr.io/${{ github.repository_owner }}/conan-tests:${{ steps.dockerfile_hash.outputs.tag }} -f ./.ci/docker/conan-tests .
docker push ghcr.io/${{ github.repository_owner }}/conan-tests:${{ steps.dockerfile_hash.outputs.tag }}
linux_test_suite:
linux_tests:
needs: build_container
runs-on: ubuntu-latest
container:
image: ghcr.io/${{ github.repository_owner }}/conan-tests:${{ needs.build_container.outputs.image_tag }}
image: ghcr.io/${{ github.repository_owner }}/conan-tests:${{ needs.linux_setup.outputs.image_tag }}
options: --user conan
strategy:
matrix:
python-version: ['3.12.3', '3.9.2', '3.8.6', '3.6.15']
test-type: ['unittests', 'integration', 'functional']
name: Conan ${{ matrix.test-type }} (${{ matrix.python-version }})
# python-version: [3.12.3, 3.9.2, 3.8.6, 3.6.15]
# test-type: [unittests, integration, functional]
python-version: [3.13]
test-type: [unittests]
name: Linux - Conan ${{ matrix.test-type }} (${{ matrix.python-version }})
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -64,13 +71,13 @@ jobs:
pyenv global ${{ matrix.python-version }}
python --version
- name: Cache pip
- name: Restore pip cache
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/requirements*.txt') }}

- name: Install dependencies
- name: Install Python dependencies
run: |
pip install --upgrade pip
pip install -r conans/requirements.txt
Expand All @@ -81,31 +88,38 @@ jobs:
- name: Run tests
shell: bash
run: |
if [ "${{ matrix.test-type }}" == "unittests" ]; then
pytest test/unittests --durations=20 -n 4
elif [ "${{ matrix.test-type }}" == "integration" ]; then
pytest test/integration --durations=20 -n 4
elif [ "${{ matrix.test-type }}" == "functional" ]; then
pytest test/functional --durations=20 -n 4
fi
pytest test/${{ matrix.test-type }} --durations=20 -n 4 --cov=conan
linux_docker_tests:
- name: Rename coverage file (Linux/MacOS)
if: runner.os != 'Windows'
run: mv .coverage .coverage.${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.test-type }}

- name: Upload coverage artifact
uses: actions/upload-artifact@v4
with:
name: .coverage.${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.test-type }}
path: .coverage
include-hidden-files: true


linux_tests_docker:
needs: build_container
runs-on: ubuntu-latest
name: Docker Runner Tests
name: Linux - Docker Runner Tests
strategy:
matrix:
python-version: [3.12, 3.9]
# python-version: [3.12, 3.9]
python-version: [3.12]
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Checkout code
uses: actions/checkout@v4

- name: Install dependencies
- name: Install Python dependencies
run: |
pip install --upgrade pip
pip install -r conans/requirements.txt
Expand All @@ -116,10 +130,21 @@ jobs:
- name: Run tests
shell: bash
run: |
pytest -m docker_runner --durations=20 -rs
pytest -m docker_runner --durations=20 -rs --cov=conan
- name: Rename coverage file (Linux/MacOS)
if: runner.os != 'Windows'
run: mv .coverage .coverage.${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.test-type }}

- name: Upload coverage artifact
uses: actions/upload-artifact@v4
with:
name: .coverage.${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.test-type }}
path: .coverage.${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.test-type }}
include-hidden-files: true

deploy_to_pypi_test:
needs: [build_container, linux_test_suite, linux_docker_tests]
needs: [build_container, linux_tests, linux_tests_docker]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/develop2'
name: Deploy to TestPyPI
Expand Down
56 changes: 33 additions & 23 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,39 @@
name: Main Workflow

on:
push:
branches:
- develop2
- release/*
- '*'
pull_request:
branches:
- '*'
- 'release/*'
workflow_dispatch:

push:
branches:
- develop2
- release/*
- '*'
pull_request:
branches:
- '*'
- 'release/*'
workflow_dispatch:

jobs:
linux-tests:
uses: ./.github/workflows/linux-tests.yml
osx-tests:
uses: ./.github/workflows/osx-tests.yml
windows-tests:
uses: ./.github/workflows/win-tests.yml
linux-tests:
uses: ./.github/workflows/linux-tests.yml
osx-tests:
uses: ./.github/workflows/osx-tests.yml
windows-tests:
uses: ./.github/workflows/win-tests.yml
code_coverage:
runs-on: ubuntu-latest
needs: [linux-tests, osx-tests, windows-tests]
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Download coverage artifacts
uses: actions/download-artifact@v4
with:
merge-multiple: true

final-job:
runs-on: ubuntu-latest
needs: [ linux-tests, osx-tests, windows-tests ]
steps:
- run: echo "All jobs are done. Executing the final job."
- name: Merge coverage reports
run: |
pip install coverage
coverage combine
coverage report
coverage xml -o merged-coverage.xml
coverage html -d coverage-html
65 changes: 42 additions & 23 deletions .github/workflows/osx-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@ concurrency:
cancel-in-progress: true

jobs:
setup-caches:

##############################################################################
# MACOS ENVIRONMENT #
##############################################################################

osx_setup:
name: OSX - Setup and Cache Dependencies
runs-on: macos-14
name: Setup and Cache Dependencies
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down Expand Up @@ -111,28 +116,21 @@ jobs:
chmod +x ${HOME}/Applications/bazel/${version}/bazel
done
testing:
needs: setup-caches
osx_tests:
needs: osx_setup
runs-on: macos-14
strategy:
fail-fast: true
matrix:
python-version: ['3.8', '3.12', '3.13']
test-type: [unittests, integration, functional]

runs-on: macos-14

name: Conan (${{ matrix.test-type }}) (${{ matrix.python-version }})

# python-version: [3.8, 3.12, 3.13]
python-version: [3.13]
test-type: [unittests]
# test-type: [unittests, integration, functional]
name: OSX - Conan ${{ matrix.test-type }} (${{ matrix.python-version }})
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Restore pip cache
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('conans/requirements*.txt') }}

- name: Restore tools cache
uses: actions/cache@v4
with:
Expand All @@ -145,11 +143,21 @@ jobs:
~/Applications/bazel/8.0.0
key: ${{ runner.os }}-conan-tools-cache

- name: Install homebrew dependencies
run: |
brew install xcodegen make libtool zlib autoconf automake ninja
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Restore pip cache
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('conans/requirements*.txt') }}

- name: Install Python Dependencies
run: |
pip install --upgrade pip
Expand All @@ -158,14 +166,25 @@ jobs:
pip install -r conans/requirements_dev.txt
pip install meson
- name: Install homebrew dependencies
run: |
brew install xcodegen make libtool zlib autoconf automake ninja
- name: Run Tests
- name: Run tests
run: |
export PATH=${HOME}/Applications/CMake/3.15.7/bin:$PATH:/usr/local/bin:/opt/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbin
cmake --version
bazel --version
pytest test/${{ matrix.test-type }} --durations=20 -n auto --cov=conan
pwd
python -m pytest test/${{ matrix.test-type }} --durations=20 -n auto
- name: Rename coverage file (Linux/MacOS)
if: runner.os != 'Windows'
run: mv .coverage .coverage.${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.test-type }}

- name: Rename coverage file (Windows)
if: runner.os == 'Windows'
run: powershell Rename-Item .coverage coverage-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.test-type }}.coverage

- name: Upload coverage artifact
uses: actions/upload-artifact@v4
with:
name: .coverage.${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.test-type }}
path: .coverage.${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.test-type }}
include-hidden-files: true
Loading

0 comments on commit 5f07cf9

Please sign in to comment.