From 5f07cf926c6dff386e31d9cf9ec58d60711994f9 Mon Sep 17 00:00:00 2001 From: PerseoGI Date: Wed, 18 Dec 2024 14:18:56 +0100 Subject: [PATCH] Measure coverage --- .github/workflows/linux-tests.yml | 71 +++++++++++++++++++++---------- .github/workflows/main.yml | 56 ++++++++++++++---------- .github/workflows/osx-tests.yml | 65 ++++++++++++++++++---------- .github/workflows/win-tests.yml | 58 ++++++++++++++++++++----- 4 files changed, 170 insertions(+), 80 deletions(-) diff --git a/.github/workflows/linux-tests.yml b/.github/workflows/linux-tests.yml index 9e0da08a721..cfdb707f4d4 100644 --- a/.github/workflows/linux-tests.yml +++ b/.github/workflows/linux-tests.yml @@ -8,6 +8,11 @@ concurrency: cancel-in-progress: true jobs: + + ############################################################################## + # LINUX ENVIRONMENT # + ############################################################################## + # build_container: runs-on: ubuntu-latest outputs: @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1486df11d33..a1d012f6c28 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 diff --git a/.github/workflows/osx-tests.yml b/.github/workflows/osx-tests.yml index 4fa75908577..2f76e1ebae6 100644 --- a/.github/workflows/osx-tests.yml +++ b/.github/workflows/osx-tests.yml @@ -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 @@ -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: @@ -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 @@ -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 diff --git a/.github/workflows/win-tests.yml b/.github/workflows/win-tests.yml index d8fa9ff5f8b..3cf18978614 100644 --- a/.github/workflows/win-tests.yml +++ b/.github/workflows/win-tests.yml @@ -8,13 +8,19 @@ concurrency: cancel-in-progress: true jobs: - unit_integration_tests: + + ############################################################################## + # WINDOWS ENVIRONMENT # + ############################################################################## + + windows_tests_unit_integration: runs-on: windows-2022 strategy: matrix: - python-version: ['3.13', '3.8', '3.6'] + # python-version: [3.13, 3.8, 3.6] + python-version: [3.13] - name: Unit & Integration Tests (${{ matrix.python-version }}) + name: Windows - Unit & Integration Tests (${{ matrix.python-version }}) steps: - name: Checkout code uses: actions/checkout@v4 @@ -37,7 +43,6 @@ jobs: shell: pwsh run: echo "PIP_CACHE_DIR=$(pip cache dir)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - - name: Cache pip packages uses: actions/cache@v4 with: @@ -57,15 +62,32 @@ jobs: shell: pwsh run: | git config --global core.autocrlf false - pytest test/unittests test/integration --durations=100 -n=auto + pytest test/unittests test/integration --durations=100 -n=auto --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: 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 - functional_tests: + + windows_tests_functional: runs-on: windows-2022 strategy: matrix: - python-version: ['3.13', '3.8', '3.6'] + # python-version: [3.13, 3.8, 3.6] + python-version: [3.13] - name: Functional Tests (${{ matrix.python-version }}) + name: Windows - Functional Tests (${{ matrix.python-version }}) steps: - name: Checkout code uses: actions/checkout@v4 @@ -104,7 +126,6 @@ jobs: shell: pwsh run: echo "PIP_CACHE_DIR=$(pip cache dir)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - - name: Cache pip packages uses: actions/cache@v4 with: @@ -121,7 +142,7 @@ jobs: pip install -r conans/requirements_dev.txt pip install meson - - name: "Set choco cache" + - name: Set choco cache run: choco config set cacheLocation C:\choco-cache - uses: actions/cache@v4 @@ -252,4 +273,19 @@ jobs: [System.Environment]::SetEnvironmentVariable('MSYS2_PATH', $msys2Path, [System.EnvironmentVariableTarget]::Process) Write-Host "Added MSYS2_PATH environment variable: $msys2Path" - pytest test/functional -n=auto --durations=100 + pytest test/functional -n=auto --durations=100 --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: 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