From c26192a0c4a1ed43b5073c501368d9d000c5334d Mon Sep 17 00:00:00 2001 From: PerseoGI Date: Tue, 17 Dec 2024 12:08:52 +0100 Subject: [PATCH 01/15] Centralize workflow calls and add code coverage Co-authored-by: Carlos Zoido --- .github/actions/code-coverage/action.yml | 31 ++++++ .github/workflows/linux-tests.yml | 97 ++++++------------- .github/workflows/main.yml | 117 +++++++++++++++++++++++ .github/workflows/osx-tests.yml | 43 ++++----- .github/workflows/win-tests.yml | 35 ++++--- .gitignore | 1 + README.md | 4 + conans/requirements_dev.txt | 1 + setup.cfg | 9 ++ 9 files changed, 228 insertions(+), 110 deletions(-) create mode 100644 .github/actions/code-coverage/action.yml create mode 100644 .github/workflows/main.yml diff --git a/.github/actions/code-coverage/action.yml b/.github/actions/code-coverage/action.yml new file mode 100644 index 00000000000..8bc37de57f2 --- /dev/null +++ b/.github/actions/code-coverage/action.yml @@ -0,0 +1,31 @@ +name: 'Code coverage' +description: 'Properly rename and upload coverage artifact for later process' + +inputs: + python-version: + description: 'Python version in which the tests was ran' + required: true + + test-type: + description: 'Tests suite name' + required: true + +runs: + using: "composite" + steps: + - name: Rename coverage file (Linux/MacOS) + if: runner.os != 'Windows' + shell: bash + run: mv .coverage .coverage.${{ runner.os }}-${{ inputs.python-version }}-${{ inputs.test-type }} + + - name: Rename coverage file (Windows) + if: runner.os == 'Windows' + shell: pwsh + run: powershell Rename-Item .coverage coverage-${{ runner.os }}-${{ inputs.python-version }}-${{ inputs.test-type }}.coverage + + - name: Upload coverage artifact + uses: actions/upload-artifact@v4 + with: + name: .coverage.${{ runner.os }}-${{ inputs.python-version }}-${{ inputs.test-type }} + path: .coverage.${{ runner.os }}-${{ inputs.python-version }}-${{ inputs.test-type }} + include-hidden-files: true diff --git a/.github/workflows/linux-tests.yml b/.github/workflows/linux-tests.yml index 558039da0f3..a531d9ee670 100644 --- a/.github/workflows/linux-tests.yml +++ b/.github/workflows/linux-tests.yml @@ -1,23 +1,12 @@ name: Linux tests on: - push: - branches: - - develop2 - - release/* - pull_request: - branches: - - '*' - - 'release/*' - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true + workflow_call: jobs: build_container: runs-on: ubuntu-latest + name: Build Linux container outputs: image_tag: ${{ steps.dockerfile_hash.outputs.tag }} steps: @@ -52,7 +41,7 @@ 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: @@ -60,9 +49,16 @@ jobs: 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] + include: + - test-type: unittests + test-name: Unit + - test-type: integration + test-name: Integration + - test-type: functional + test-name: Functional + name: ${{ matrix.test-name }} Tests (${{ matrix.python-version }}) steps: - name: Checkout code uses: actions/checkout@v4 @@ -86,24 +82,23 @@ jobs: pip install -r conans/requirements_server.txt pip install meson - - name: Run tests - shell: bash + - name: Run Tests 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 auto --cov=conan --cov-report=term-missing:skip-covered + + - name: Code coverage + uses: ./.github/actions/code-coverage + with: + python-version: ${{ matrix.python-version }} + test-type: ${{ matrix.test-type }} linux_docker_tests: needs: build_container runs-on: ubuntu-latest - name: Docker Runner Tests strategy: matrix: python-version: [3.12, 3.9] + name: Docker Runner Tests (${{ matrix.python-version }}) steps: - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 @@ -124,48 +119,10 @@ jobs: - name: Run tests shell: bash run: | - pytest -m docker_runner --durations=20 -rs + pytest -m docker_runner --durations=20 -rs --cov=conan --cov-report=term-missing:skip-covered - deploy_to_pypi_test: - needs: [build_container, linux_test_suite, linux_docker_tests] - runs-on: ubuntu-latest - if: github.ref == 'refs/heads/develop2' - name: Deploy to TestPyPI - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Python - uses: actions/setup-python@v5 + - name: Code coverage + uses: ./.github/actions/code-coverage with: - python-version: '3.9' - - - name: Install dependencies - run: | - pip install --upgrade pip - pip install twine - - - name: Bump Dev Version - run: | - python .ci/bump_dev_version.py - - - name: Build Package - run: | - python setup.py sdist - - - name: Upload to TestPyPI - env: - TWINE_USERNAME: ${{ secrets.TEST_PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.TEST_PYPI_PASSWORD }} - run: | - python -m twine upload --verbose --repository-url https://test.pypi.org/legacy/ dist/* - - - name: Deploy conan-server to TestPyPI - env: - TWINE_USERNAME: ${{ secrets.TEST_PYPI_SERVER_USERNAME }} - TWINE_PASSWORD: ${{ secrets.TEST_PYPI_SERVER_PASSWORD }} - run: | - rm -rf dist/ - mv setup_server.py setup.py - python setup.py sdist - python -m twine upload --verbose --repository-url https://test.pypi.org/legacy/ dist/* + python-version: ${{ matrix.python-version }} + test-type: ${{ matrix.test-type }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000000..efa673a699f --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,117 @@ +name: Main Workflow +on: + push: + branches: + - develop2 + - release/* + - '*' + pull_request: + branches: + - '*' + - 'release/*' + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + linux_suite: + uses: ./.github/workflows/linux-tests.yml + name: Linux test suite + + osx_suite: + uses: ./.github/workflows/osx-tests.yml + name: OSX test suite + + windows_suite: + uses: ./.github/workflows/win-tests.yml + name: Windows test suite + + code_coverage: + runs-on: ubuntu-latest + name: Code coverage + needs: [linux_suite, osx_suite, windows_suite] + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Download coverage artifacts + uses: actions/download-artifact@v4 + with: + merge-multiple: true + + - name: Merge coverage reports + run: | + pip install coverage + coverage combine + coverage report + coverage xml + + - name: Pytest coverage comment + id: coverageComment + uses: MishaKav/pytest-coverage-comment@main + with: + pytest-xml-coverage-path: ./coverage.xml + xml-skip-covered: true # Only display non fully covered files + hide-report: true # Avoids GitHub message length limit issue + + - name: Update coverage badge + uses: schneegans/dynamic-badges-action@v1.7.0 + with: + auth: ${{ secrets.PYTEST_COVERAGE_COMMENT }} + gistID: f305b2c105b15ff2b620a7a728b14934 + filename: conan-coverage.json + label: Coverage Report + message: ${{ steps.coverageComment.outputs.coverage }} + color: ${{ steps.coverageComment.outputs.color }} + namedLogo: python + + - uses: geekyeggo/delete-artifact@v5 + with: + name: | + .coverage.* + + deploy_to_pypi_test: + needs: [linux_suite] + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/develop2' + name: Deploy to TestPyPI + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: 3.9 + + - name: Install dependencies + run: | + pip install --upgrade pip + pip install twine + + - name: Bump Dev Version + run: | + python .ci/bump_dev_version.py + + - name: Build Package + run: | + python setup.py sdist + + - name: Upload to TestPyPI + env: + TWINE_USERNAME: ${{ secrets.TEST_PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.TEST_PYPI_PASSWORD }} + run: | + python -m twine upload --verbose --repository-url https://test.pypi.org/legacy/ dist/* + + - name: Deploy conan-server to TestPyPI + env: + TWINE_USERNAME: ${{ secrets.TEST_PYPI_SERVER_USERNAME }} + TWINE_PASSWORD: ${{ secrets.TEST_PYPI_SERVER_PASSWORD }} + run: | + rm -rf dist/ + mv setup_server.py setup.py + python setup.py sdist + python -m twine upload --verbose --repository-url https://test.pypi.org/legacy/ dist/* diff --git a/.github/workflows/osx-tests.yml b/.github/workflows/osx-tests.yml index 671f8d6bf0c..673b1147908 100644 --- a/.github/workflows/osx-tests.yml +++ b/.github/workflows/osx-tests.yml @@ -1,21 +1,10 @@ name: OSX Tests on: - push: - branches: - - develop2 - - release/* - pull_request: - branches: - - '*' - - 'release/*' - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true + workflow_call: jobs: - setup-caches: + osx_setup: runs-on: macos-14 name: Setup and Cache Dependencies steps: @@ -118,18 +107,22 @@ 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'] + 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 }}) - + include: + - test-type: unittests + test-name: Unit + - test-type: integration + test-name: Integration + - test-type: functional + test-name: Functional + name: ${{ matrix.test-name }} Tests (${{ matrix.python-version }}) steps: - name: Checkout code uses: actions/checkout@v4 @@ -175,4 +168,10 @@ jobs: cmake --version bazel --version - python -m pytest test/${{ matrix.test-type }} --durations=20 -n auto + pytest test/${{ matrix.test-type }} --durations=20 -n auto --cov=conan --cov-report=term-missing:skip-covered + + - name: Code coverage + uses: ./.github/actions/code-coverage + with: + python-version: ${{ matrix.python-version }} + test-type: ${{ matrix.test-type }} diff --git a/.github/workflows/win-tests.yml b/.github/workflows/win-tests.yml index 2b0df32c804..4cc90d64df6 100644 --- a/.github/workflows/win-tests.yml +++ b/.github/workflows/win-tests.yml @@ -1,27 +1,14 @@ name: Windows Tests on: - push: - branches: - - develop2 - - release/* - pull_request: - branches: - - '*' - - 'release/*' - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true + workflow_call: jobs: unit_integration_tests: runs-on: windows-2022 strategy: matrix: - python-version: ['3.13', '3.8', '3.6'] - + python-version: [3.13, 3.8, 3.6] name: Unit & Integration Tests (${{ matrix.python-version }}) steps: - name: Checkout code @@ -65,13 +52,19 @@ 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 --cov-report=term-missing:skip-covered + + - name: Code coverage + uses: ./.github/actions/code-coverage + with: + python-version: ${{ matrix.python-version }} + test-type: unit-integration functional_tests: runs-on: windows-2022 strategy: matrix: - python-version: ['3.13', '3.8', '3.6'] + python-version: [3.13, 3.8, 3.6] name: Functional Tests (${{ matrix.python-version }}) steps: @@ -260,4 +253,10 @@ 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 --cov-report=term-missing:skip-covered + + - name: Code coverage + uses: ./.github/actions/code-coverage + with: + python-version: ${{ matrix.python-version }} + test-type: functional diff --git a/.gitignore b/.gitignore index 87824d1019e..593c94534ba 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ parts/ sdist/ var/ venv/ +.venv/ *.egg-info/ .installed.cfg *.egg diff --git a/README.md b/README.md index 70207a0bfed..705d78f6c84 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,10 @@ # Conan +[![license](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE.md) +[![CI](https://github.com/conan-io/conan/actions/workflows/main.yml/badge.svg)](https://github.com/conan-io/conan/actions/workflows/main.yml) +![badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/perseoGI/f305b2c105b15ff2b620a7a728b14934/raw/conan-coverage.json) + Decentralized, open-source (MIT), C/C++ package manager. - Homepage: https://conan.io/ diff --git a/conans/requirements_dev.txt b/conans/requirements_dev.txt index e9e964c4569..b2876e233bb 100644 --- a/conans/requirements_dev.txt +++ b/conans/requirements_dev.txt @@ -8,3 +8,4 @@ PyJWT pluginbase docker setuptools +pytest-cov diff --git a/setup.cfg b/setup.cfg index 6ba9f60b404..6a06692da32 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,3 +3,12 @@ count = False max-line-length = 100 statistics = False +; https://coverage.readthedocs.io/en/coverage-4.0.3/config.html#paths +; The first value must be an actual file path on the machine where the +; reporting will happen +[coverage:paths] +source = + conan/ + /Users/runner/**/conan + /home/runner/**/conan + /__w/**/conan From 3ca53c5c296c01666e9efae0b72ce51fbec89775 Mon Sep 17 00:00:00 2001 From: PerseoGI Date: Thu, 16 Jan 2025 18:34:19 +0100 Subject: [PATCH 02/15] Use codecov --- .github/workflows/main.yml | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index efa673a699f..99ed9caba9a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -48,24 +48,10 @@ jobs: coverage report coverage xml - - name: Pytest coverage comment - id: coverageComment - uses: MishaKav/pytest-coverage-comment@main + - name: Code coverage + uses: codecov/codecov-action@v5 with: - pytest-xml-coverage-path: ./coverage.xml - xml-skip-covered: true # Only display non fully covered files - hide-report: true # Avoids GitHub message length limit issue - - - name: Update coverage badge - uses: schneegans/dynamic-badges-action@v1.7.0 - with: - auth: ${{ secrets.PYTEST_COVERAGE_COMMENT }} - gistID: f305b2c105b15ff2b620a7a728b14934 - filename: conan-coverage.json - label: Coverage Report - message: ${{ steps.coverageComment.outputs.coverage }} - color: ${{ steps.coverageComment.outputs.color }} - namedLogo: python + token: ${{ secrets.CODECOV_TOKEN }} - uses: geekyeggo/delete-artifact@v5 with: From fc5d86810e6a0b7d87e82d5e2972fb39b92e49bd Mon Sep 17 00:00:00 2001 From: PerseoGI Date: Fri, 17 Jan 2025 10:54:09 +0100 Subject: [PATCH 03/15] Removed badges and disable codecovs comment on PR --- README.md | 4 ---- codecov.yml | 1 + 2 files changed, 1 insertion(+), 4 deletions(-) create mode 100644 codecov.yml diff --git a/README.md b/README.md index 705d78f6c84..70207a0bfed 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,6 @@ # Conan -[![license](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE.md) -[![CI](https://github.com/conan-io/conan/actions/workflows/main.yml/badge.svg)](https://github.com/conan-io/conan/actions/workflows/main.yml) -![badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/perseoGI/f305b2c105b15ff2b620a7a728b14934/raw/conan-coverage.json) - Decentralized, open-source (MIT), C/C++ package manager. - Homepage: https://conan.io/ diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 00000000000..561bf760e25 --- /dev/null +++ b/codecov.yml @@ -0,0 +1 @@ +comment: false # Disable codecov PR comments -> leave only the checks From 2a483588219a0d9e7c059d4aa91d14dc3068ade3 Mon Sep 17 00:00:00 2001 From: PerseoGI Date: Mon, 20 Jan 2025 10:22:17 +0100 Subject: [PATCH 04/15] Only run coverage on develop2 branch --- .github/actions/code-coverage/action.yml | 5 +++++ .github/workflows/linux-tests.yml | 4 ++-- .github/workflows/main.yml | 4 ++++ .github/workflows/osx-tests.yml | 3 +-- .github/workflows/win-tests.yml | 4 ++-- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/actions/code-coverage/action.yml b/.github/actions/code-coverage/action.yml index 8bc37de57f2..1b40cd644af 100644 --- a/.github/actions/code-coverage/action.yml +++ b/.github/actions/code-coverage/action.yml @@ -1,6 +1,11 @@ name: 'Code coverage' description: 'Properly rename and upload coverage artifact for later process' +on: + push: + branches: + - develop2 + inputs: python-version: description: 'Python version in which the tests was ran' diff --git a/.github/workflows/linux-tests.yml b/.github/workflows/linux-tests.yml index a531d9ee670..70b13968e2a 100644 --- a/.github/workflows/linux-tests.yml +++ b/.github/workflows/linux-tests.yml @@ -84,7 +84,7 @@ jobs: - name: Run Tests run: | - pytest test/${{ matrix.test-type }} --durations=20 -n auto --cov=conan --cov-report=term-missing:skip-covered + pytest test/${{ matrix.test-type }} --durations=20 -n auto ${{ env.PYTEST_COV_OPTIONS }} - name: Code coverage uses: ./.github/actions/code-coverage @@ -119,7 +119,7 @@ jobs: - name: Run tests shell: bash run: | - pytest -m docker_runner --durations=20 -rs --cov=conan --cov-report=term-missing:skip-covered + pytest -m docker_runner --durations=20 -rs ${{ env.PYTEST_COV_OPTIONS }} - name: Code coverage uses: ./.github/actions/code-coverage diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 99ed9caba9a..0d3c4ecba2f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,6 +15,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true +env: + PYTEST_COV_OPTIONS: ${{ github.ref_name == 'develop2' && '--cov=conan --cov-report=term-missing:skip-covered' || '' }} + jobs: linux_suite: uses: ./.github/workflows/linux-tests.yml @@ -31,6 +34,7 @@ jobs: code_coverage: runs-on: ubuntu-latest name: Code coverage + if: github.ref == 'refs/heads/develop2' # Only measure code coverage on main branch needs: [linux_suite, osx_suite, windows_suite] steps: - name: Checkout code diff --git a/.github/workflows/osx-tests.yml b/.github/workflows/osx-tests.yml index 673b1147908..bc743b9169b 100644 --- a/.github/workflows/osx-tests.yml +++ b/.github/workflows/osx-tests.yml @@ -167,8 +167,7 @@ jobs: 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 --cov-report=term-missing:skip-covered + pytest test/${{ matrix.test-type }} --durations=20 -n auto ${{ env.PYTEST_COV_OPTIONS }} - name: Code coverage uses: ./.github/actions/code-coverage diff --git a/.github/workflows/win-tests.yml b/.github/workflows/win-tests.yml index 4cc90d64df6..6a0b9eb113e 100644 --- a/.github/workflows/win-tests.yml +++ b/.github/workflows/win-tests.yml @@ -52,7 +52,7 @@ jobs: shell: pwsh run: | git config --global core.autocrlf false - pytest test/unittests test/integration --durations=100 -n=auto --cov=conan --cov-report=term-missing:skip-covered + pytest test/unittests test/integration --durations=100 -n=auto ${{ env.PYTEST_COV_OPTIONS }} - name: Code coverage uses: ./.github/actions/code-coverage @@ -253,7 +253,7 @@ 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 --cov=conan --cov-report=term-missing:skip-covered + pytest test/functional -n=auto --durations=100 ${{ env.PYTEST_COV_OPTIONS }} - name: Code coverage uses: ./.github/actions/code-coverage From 9fbed1b0d64a1e701001d1e79c7afcefa960e6ee Mon Sep 17 00:00:00 2001 From: PerseoGI Date: Mon, 20 Jan 2025 10:45:45 +0100 Subject: [PATCH 05/15] Fix action --- .github/actions/code-coverage/action.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/actions/code-coverage/action.yml b/.github/actions/code-coverage/action.yml index 1b40cd644af..578e31e7bd2 100644 --- a/.github/actions/code-coverage/action.yml +++ b/.github/actions/code-coverage/action.yml @@ -1,11 +1,6 @@ name: 'Code coverage' description: 'Properly rename and upload coverage artifact for later process' -on: - push: - branches: - - develop2 - inputs: python-version: description: 'Python version in which the tests was ran' @@ -17,6 +12,7 @@ inputs: runs: using: "composite" + if: github.ref == 'refs/heads/develop2' steps: - name: Rename coverage file (Linux/MacOS) if: runner.os != 'Windows' From 4d0183531cba3c43c94acf0f0bb704ba9dac73ad Mon Sep 17 00:00:00 2001 From: PerseoGI Date: Mon, 20 Jan 2025 10:58:15 +0100 Subject: [PATCH 06/15] Fix action --- .github/actions/code-coverage/action.yml | 32 ------------------ .github/actions/test-coverage/action.yml | 41 ++++++++++++++++++++++++ .github/workflows/linux-tests.yml | 21 +++++------- .github/workflows/main.yml | 5 --- .github/workflows/osx-tests.yml | 10 +++--- .github/workflows/win-tests.yml | 23 ++++++------- 6 files changed, 63 insertions(+), 69 deletions(-) delete mode 100644 .github/actions/code-coverage/action.yml create mode 100644 .github/actions/test-coverage/action.yml diff --git a/.github/actions/code-coverage/action.yml b/.github/actions/code-coverage/action.yml deleted file mode 100644 index 578e31e7bd2..00000000000 --- a/.github/actions/code-coverage/action.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: 'Code coverage' -description: 'Properly rename and upload coverage artifact for later process' - -inputs: - python-version: - description: 'Python version in which the tests was ran' - required: true - - test-type: - description: 'Tests suite name' - required: true - -runs: - using: "composite" - if: github.ref == 'refs/heads/develop2' - steps: - - name: Rename coverage file (Linux/MacOS) - if: runner.os != 'Windows' - shell: bash - run: mv .coverage .coverage.${{ runner.os }}-${{ inputs.python-version }}-${{ inputs.test-type }} - - - name: Rename coverage file (Windows) - if: runner.os == 'Windows' - shell: pwsh - run: powershell Rename-Item .coverage coverage-${{ runner.os }}-${{ inputs.python-version }}-${{ inputs.test-type }}.coverage - - - name: Upload coverage artifact - uses: actions/upload-artifact@v4 - with: - name: .coverage.${{ runner.os }}-${{ inputs.python-version }}-${{ inputs.test-type }} - path: .coverage.${{ runner.os }}-${{ inputs.python-version }}-${{ inputs.test-type }} - include-hidden-files: true diff --git a/.github/actions/test-coverage/action.yml b/.github/actions/test-coverage/action.yml new file mode 100644 index 00000000000..448bc57e5eb --- /dev/null +++ b/.github/actions/test-coverage/action.yml @@ -0,0 +1,41 @@ +name: 'Run tests and measure code coverage' +description: 'Run tests enabling coverage in certain conditions and upload coverage artifacts for later process' + +inputs: + python-version: + description: 'Python version in which the tests was ran' + required: true + + test-type: + description: 'Tests suite name' + required: true + + duration: + description: 'Tests maximum duration' + required: true + default: '20' + + tests: + description: 'Tests folder and options to run' + required: true + +runs: + using: 'composite' + steps: + - name: Run tests with coverage + shell: bash + run: | + pytest ${{ inputs.tests }} --durations=${{ inputs.duration }} -n auto ${{ github.ref == 'refs/heads/develop2' && '--cov=conan --cov-report=term-missing:skip-covered' || '' }} + + - name: Rename coverage file + if: github.ref == 'refs/heads/develop2' + shell: bash + run: mv .coverage .coverage.${{ runner.os }}-${{ inputs.python-version }}-${{ inputs.test-type }} + + - name: Upload coverage artifact + if: github.ref == 'refs/heads/develop2' + uses: actions/upload-artifact@v4 + with: + name: .coverage.${{ runner.os }}-${{ inputs.python-version }}-${{ inputs.test-type }} + path: .coverage.${{ runner.os }}-${{ inputs.python-version }}-${{ inputs.test-type }} + include-hidden-files: true diff --git a/.github/workflows/linux-tests.yml b/.github/workflows/linux-tests.yml index 70b13968e2a..bfa70b4d027 100644 --- a/.github/workflows/linux-tests.yml +++ b/.github/workflows/linux-tests.yml @@ -82,15 +82,13 @@ jobs: pip install -r conans/requirements_server.txt pip install meson - - name: Run Tests - run: | - pytest test/${{ matrix.test-type }} --durations=20 -n auto ${{ env.PYTEST_COV_OPTIONS }} - - - name: Code coverage - uses: ./.github/actions/code-coverage + - name: Run tests + uses: ./.github/actions/test-coverage with: python-version: ${{ matrix.python-version }} test-type: ${{ matrix.test-type }} + tests: test/${{ matrix.test-type }} + duration: 20 linux_docker_tests: needs: build_container @@ -117,12 +115,9 @@ jobs: pip install -r conans/requirements_runner.txt - name: Run tests - shell: bash - run: | - pytest -m docker_runner --durations=20 -rs ${{ env.PYTEST_COV_OPTIONS }} - - - name: Code coverage - uses: ./.github/actions/code-coverage + uses: ./.github/actions/test-coverage with: python-version: ${{ matrix.python-version }} - test-type: ${{ matrix.test-type }} + test-type: docker + tests: '-m docker_runner -rs' + duration: 20 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0d3c4ecba2f..48bc50d59c5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,9 +15,6 @@ concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true -env: - PYTEST_COV_OPTIONS: ${{ github.ref_name == 'develop2' && '--cov=conan --cov-report=term-missing:skip-covered' || '' }} - jobs: linux_suite: uses: ./.github/workflows/linux-tests.yml @@ -63,9 +60,7 @@ jobs: .coverage.* deploy_to_pypi_test: - needs: [linux_suite] runs-on: ubuntu-latest - if: github.ref == 'refs/heads/develop2' name: Deploy to TestPyPI steps: - name: Checkout code diff --git a/.github/workflows/osx-tests.yml b/.github/workflows/osx-tests.yml index bc743b9169b..065afbc33c4 100644 --- a/.github/workflows/osx-tests.yml +++ b/.github/workflows/osx-tests.yml @@ -161,16 +161,14 @@ jobs: - name: Install homebrew dependencies run: | brew install xcodegen make libtool zlib autoconf automake ninja - - - 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 ${{ env.PYTEST_COV_OPTIONS }} - - name: Code coverage - uses: ./.github/actions/code-coverage + - name: Run tests + uses: ./.github/actions/test-coverage with: python-version: ${{ matrix.python-version }} test-type: ${{ matrix.test-type }} + tests: test/${{ matrix.test-type }} + duration: 20 diff --git a/.github/workflows/win-tests.yml b/.github/workflows/win-tests.yml index 6a0b9eb113e..2b379abb00e 100644 --- a/.github/workflows/win-tests.yml +++ b/.github/workflows/win-tests.yml @@ -32,7 +32,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: @@ -47,18 +46,15 @@ jobs: pip install -r conans/requirements.txt pip install -r conans/requirements_dev.txt pip install -r conans/requirements_server.txt - - - name: Run Unit & Integration Tests - shell: pwsh - run: | git config --global core.autocrlf false - pytest test/unittests test/integration --durations=100 -n=auto ${{ env.PYTEST_COV_OPTIONS }} - - name: Code coverage - uses: ./.github/actions/code-coverage + - name: Run Unit & Integration Tests + uses: ./.github/actions/test-coverage with: python-version: ${{ matrix.python-version }} test-type: unit-integration + tests: test/unittests test/integration + duration: 100 functional_tests: runs-on: windows-2022 @@ -220,7 +216,7 @@ jobs: Remove-Item $zipFile } - - name: Run Functional Tests + - name: Configure environment run: | git config --global core.autocrlf false @@ -253,10 +249,11 @@ 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 ${{ env.PYTEST_COV_OPTIONS }} - - - name: Code coverage - uses: ./.github/actions/code-coverage + - name: Run Functional Tests + if: ${{ env.PYTEST_COV_OPTIONS }} + uses: ./.github/actions/test-coverage with: python-version: ${{ matrix.python-version }} test-type: functional + tests: test/functional + duration: 100 From 5749d721ef9226ec499e34cc18c62853eb2b2759 Mon Sep 17 00:00:00 2001 From: PerseoGI Date: Mon, 20 Jan 2025 18:31:52 +0100 Subject: [PATCH 07/15] Added workers input to action --- .github/actions/test-coverage/action.yml | 6 +++++- .github/workflows/linux-tests.yml | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/actions/test-coverage/action.yml b/.github/actions/test-coverage/action.yml index 448bc57e5eb..a6d9babdea7 100644 --- a/.github/actions/test-coverage/action.yml +++ b/.github/actions/test-coverage/action.yml @@ -19,13 +19,17 @@ inputs: description: 'Tests folder and options to run' required: true + workers: + description: 'Number of workers to run tests' + default: auto + runs: using: 'composite' steps: - name: Run tests with coverage shell: bash run: | - pytest ${{ inputs.tests }} --durations=${{ inputs.duration }} -n auto ${{ github.ref == 'refs/heads/develop2' && '--cov=conan --cov-report=term-missing:skip-covered' || '' }} + pytest ${{ inputs.tests }} --durations=${{ inputs.duration }} -n ${{ inputs.workers }} ${{ github.ref == 'refs/heads/develop2' && '--cov=conan --cov-report=term-missing:skip-covered' || '' }} - name: Rename coverage file if: github.ref == 'refs/heads/develop2' diff --git a/.github/workflows/linux-tests.yml b/.github/workflows/linux-tests.yml index bfa70b4d027..1df2d43d13d 100644 --- a/.github/workflows/linux-tests.yml +++ b/.github/workflows/linux-tests.yml @@ -121,3 +121,4 @@ jobs: test-type: docker tests: '-m docker_runner -rs' duration: 20 + workers: 1 From aefdb7ae381938c7195d2c82981c0ab957d0dd8e Mon Sep 17 00:00:00 2001 From: PerseoGI Date: Tue, 21 Jan 2025 08:50:08 +0100 Subject: [PATCH 08/15] Update main.yml --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 48bc50d59c5..02a8ad19907 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -62,6 +62,7 @@ jobs: deploy_to_pypi_test: runs-on: ubuntu-latest name: Deploy to TestPyPI + if: github.ref == 'refs/heads/develop2' steps: - name: Checkout code uses: actions/checkout@v4 From 902856b36e1aa159a36849d0597c146110153279 Mon Sep 17 00:00:00 2001 From: PerseoGI Date: Tue, 21 Jan 2025 09:48:46 +0100 Subject: [PATCH 09/15] Measure coverage on conans and test folder --- .github/actions/test-coverage/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/test-coverage/action.yml b/.github/actions/test-coverage/action.yml index a6d9babdea7..28197f0eae1 100644 --- a/.github/actions/test-coverage/action.yml +++ b/.github/actions/test-coverage/action.yml @@ -7,7 +7,7 @@ inputs: required: true test-type: - description: 'Tests suite name' + description: 'Test suite name' required: true duration: @@ -29,7 +29,7 @@ runs: - name: Run tests with coverage shell: bash run: | - pytest ${{ inputs.tests }} --durations=${{ inputs.duration }} -n ${{ inputs.workers }} ${{ github.ref == 'refs/heads/develop2' && '--cov=conan --cov-report=term-missing:skip-covered' || '' }} + pytest ${{ inputs.tests }} --durations=${{ inputs.duration }} -n ${{ inputs.workers }} ${{ github.ref == 'refs/heads/develop2' && '--cov=conan --cov=conans --cov=test --cov-report=term-missing:skip-covered' || '' }} - name: Rename coverage file if: github.ref == 'refs/heads/develop2' From d479811e4cd6ff4e9e8ec8b259e9e1ed34363c21 Mon Sep 17 00:00:00 2001 From: PerseoGI Date: Tue, 21 Jan 2025 09:56:25 +0100 Subject: [PATCH 10/15] Test squash --- .github/actions/test-coverage/action.yml | 7 ++++--- .github/workflows/main.yml | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/actions/test-coverage/action.yml b/.github/actions/test-coverage/action.yml index 28197f0eae1..c18e408b311 100644 --- a/.github/actions/test-coverage/action.yml +++ b/.github/actions/test-coverage/action.yml @@ -23,21 +23,22 @@ inputs: description: 'Number of workers to run tests' default: auto +# pytest ${{ inputs.tests }} --durations=${{ inputs.duration }} -n ${{ inputs.workers }} ${{ github.ref == 'refs/heads/develop2' && '--cov=conan --cov=conans --cov=test --cov-report=term-missing:skip-covered' || '' }} runs: using: 'composite' steps: - name: Run tests with coverage shell: bash run: | - pytest ${{ inputs.tests }} --durations=${{ inputs.duration }} -n ${{ inputs.workers }} ${{ github.ref == 'refs/heads/develop2' && '--cov=conan --cov=conans --cov=test --cov-report=term-missing:skip-covered' || '' }} + pytest ${{ inputs.tests }} --durations=${{ inputs.duration }} -n ${{ inputs.workers }} --cov=conan --cov=conans --cov=test --cov-report=term-missing:skip-covered - name: Rename coverage file - if: github.ref == 'refs/heads/develop2' + # if: github.ref == 'refs/heads/develop2' shell: bash run: mv .coverage .coverage.${{ runner.os }}-${{ inputs.python-version }}-${{ inputs.test-type }} - name: Upload coverage artifact - if: github.ref == 'refs/heads/develop2' + # if: github.ref == 'refs/heads/develop2' uses: actions/upload-artifact@v4 with: name: .coverage.${{ runner.os }}-${{ inputs.python-version }}-${{ inputs.test-type }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 02a8ad19907..a2718731db4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -31,7 +31,7 @@ jobs: code_coverage: runs-on: ubuntu-latest name: Code coverage - if: github.ref == 'refs/heads/develop2' # Only measure code coverage on main branch + # if: github.ref == 'refs/heads/develop2' # Only measure code coverage on main branch needs: [linux_suite, osx_suite, windows_suite] steps: - name: Checkout code From fcae0f381c97fe8a0b5708d03990bd60cf440c6e Mon Sep 17 00:00:00 2001 From: PerseoGI Date: Tue, 21 Jan 2025 10:59:11 +0100 Subject: [PATCH 11/15] Test --- setup.cfg | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/setup.cfg b/setup.cfg index 6a06692da32..09014329fc7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -6,9 +6,12 @@ statistics = False ; https://coverage.readthedocs.io/en/coverage-4.0.3/config.html#paths ; The first value must be an actual file path on the machine where the ; reporting will happen -[coverage:paths] -source = - conan/ - /Users/runner/**/conan - /home/runner/**/conan - /__w/**/conan +; [coverage:paths] +; source = +; conan/ +; /Users/runner/**/conan +; /home/runner/**/conan +; /__w/**/conan + +[coverage:run] +relative_files = True From 071f39de1ade8096814a1df132f0e6c1c0b645ea Mon Sep 17 00:00:00 2001 From: PerseoGI Date: Tue, 21 Jan 2025 12:33:14 +0100 Subject: [PATCH 12/15] Restore coverage behavior --- .github/actions/test-coverage/action.yml | 7 +++---- .github/workflows/main.yml | 2 +- setup.cfg | 14 +++++--------- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/.github/actions/test-coverage/action.yml b/.github/actions/test-coverage/action.yml index c18e408b311..28197f0eae1 100644 --- a/.github/actions/test-coverage/action.yml +++ b/.github/actions/test-coverage/action.yml @@ -23,22 +23,21 @@ inputs: description: 'Number of workers to run tests' default: auto -# pytest ${{ inputs.tests }} --durations=${{ inputs.duration }} -n ${{ inputs.workers }} ${{ github.ref == 'refs/heads/develop2' && '--cov=conan --cov=conans --cov=test --cov-report=term-missing:skip-covered' || '' }} runs: using: 'composite' steps: - name: Run tests with coverage shell: bash run: | - pytest ${{ inputs.tests }} --durations=${{ inputs.duration }} -n ${{ inputs.workers }} --cov=conan --cov=conans --cov=test --cov-report=term-missing:skip-covered + pytest ${{ inputs.tests }} --durations=${{ inputs.duration }} -n ${{ inputs.workers }} ${{ github.ref == 'refs/heads/develop2' && '--cov=conan --cov=conans --cov=test --cov-report=term-missing:skip-covered' || '' }} - name: Rename coverage file - # if: github.ref == 'refs/heads/develop2' + if: github.ref == 'refs/heads/develop2' shell: bash run: mv .coverage .coverage.${{ runner.os }}-${{ inputs.python-version }}-${{ inputs.test-type }} - name: Upload coverage artifact - # if: github.ref == 'refs/heads/develop2' + if: github.ref == 'refs/heads/develop2' uses: actions/upload-artifact@v4 with: name: .coverage.${{ runner.os }}-${{ inputs.python-version }}-${{ inputs.test-type }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a2718731db4..02a8ad19907 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -31,7 +31,7 @@ jobs: code_coverage: runs-on: ubuntu-latest name: Code coverage - # if: github.ref == 'refs/heads/develop2' # Only measure code coverage on main branch + if: github.ref == 'refs/heads/develop2' # Only measure code coverage on main branch needs: [linux_suite, osx_suite, windows_suite] steps: - name: Checkout code diff --git a/setup.cfg b/setup.cfg index 09014329fc7..ca70e3f2f14 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,15 +3,11 @@ count = False max-line-length = 100 statistics = False +; Coverage files are generated across different OS and machines, thus, coverage +; reports will contain different absolute paths to reference to the same +; project relative paths. +; This option makes coverage to use relative paths to the project root, +; removing the need for setting arbitrary runners paths described in here: ; https://coverage.readthedocs.io/en/coverage-4.0.3/config.html#paths -; The first value must be an actual file path on the machine where the -; reporting will happen -; [coverage:paths] -; source = -; conan/ -; /Users/runner/**/conan -; /home/runner/**/conan -; /__w/**/conan - [coverage:run] relative_files = True From 3202c93103883e53438b1ddb2d1d9318caa260e0 Mon Sep 17 00:00:00 2001 From: PerseoGI Date: Tue, 21 Jan 2025 18:02:07 +0100 Subject: [PATCH 13/15] Fix functional test not running windows --- .github/workflows/win-tests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/win-tests.yml b/.github/workflows/win-tests.yml index 2b379abb00e..f5d98569b6a 100644 --- a/.github/workflows/win-tests.yml +++ b/.github/workflows/win-tests.yml @@ -250,7 +250,6 @@ jobs: Write-Host "Added MSYS2_PATH environment variable: $msys2Path" - name: Run Functional Tests - if: ${{ env.PYTEST_COV_OPTIONS }} uses: ./.github/actions/test-coverage with: python-version: ${{ matrix.python-version }} From 64304ac25737adae31bcc675ef9d8dab2073524b Mon Sep 17 00:00:00 2001 From: PerseoGI Date: Wed, 22 Jan 2025 10:13:36 +0100 Subject: [PATCH 14/15] Run tests on pwsh on windows --- .github/actions/test-coverage/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/test-coverage/action.yml b/.github/actions/test-coverage/action.yml index 28197f0eae1..0988e8aa206 100644 --- a/.github/actions/test-coverage/action.yml +++ b/.github/actions/test-coverage/action.yml @@ -27,7 +27,7 @@ runs: using: 'composite' steps: - name: Run tests with coverage - shell: bash + shell: ${{ runner.os == 'Windows' && 'pwsh' || 'bash' }} run: | pytest ${{ inputs.tests }} --durations=${{ inputs.duration }} -n ${{ inputs.workers }} ${{ github.ref == 'refs/heads/develop2' && '--cov=conan --cov=conans --cov=test --cov-report=term-missing:skip-covered' || '' }} From 8650926b2abce0907cef1eeae80bba0815b49788 Mon Sep 17 00:00:00 2001 From: PerseoGI Date: Wed, 22 Jan 2025 11:41:06 +0100 Subject: [PATCH 15/15] Run win functional tests in same develop2 step --- .github/actions/test-coverage/action.yml | 5 +++-- .github/workflows/win-tests.yml | 8 +++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/actions/test-coverage/action.yml b/.github/actions/test-coverage/action.yml index 0988e8aa206..2b05757578f 100644 --- a/.github/actions/test-coverage/action.yml +++ b/.github/actions/test-coverage/action.yml @@ -1,4 +1,4 @@ -name: 'Run tests and measure code coverage' + description: 'Run tests enabling coverage in certain conditions and upload coverage artifacts for later process' inputs: @@ -17,7 +17,7 @@ inputs: tests: description: 'Tests folder and options to run' - required: true + required: false workers: description: 'Number of workers to run tests' @@ -27,6 +27,7 @@ runs: using: 'composite' steps: - name: Run tests with coverage + if: ${{ inputs.tests }} shell: ${{ runner.os == 'Windows' && 'pwsh' || 'bash' }} run: | pytest ${{ inputs.tests }} --durations=${{ inputs.duration }} -n ${{ inputs.workers }} ${{ github.ref == 'refs/heads/develop2' && '--cov=conan --cov=conans --cov=test --cov-report=term-missing:skip-covered' || '' }} diff --git a/.github/workflows/win-tests.yml b/.github/workflows/win-tests.yml index f5d98569b6a..b9885b6bb8e 100644 --- a/.github/workflows/win-tests.yml +++ b/.github/workflows/win-tests.yml @@ -216,7 +216,7 @@ jobs: Remove-Item $zipFile } - - name: Configure environment + - name: Run Functional Tests run: | git config --global core.autocrlf false @@ -249,10 +249,12 @@ jobs: [System.Environment]::SetEnvironmentVariable('MSYS2_PATH', $msys2Path, [System.EnvironmentVariableTarget]::Process) Write-Host "Added MSYS2_PATH environment variable: $msys2Path" - - name: Run Functional Tests + # Run tests in this step context to preserve fragile environment + pytest test/functional -n=auto --durations=100 ${{ github.ref == 'refs/heads/develop2' && '--cov=conan --cov=conans --cov=test --cov-report=term-missing:skip-covered' || '' }} + + - name: Code Coverage uses: ./.github/actions/test-coverage with: python-version: ${{ matrix.python-version }} test-type: functional - tests: test/functional duration: 100