Merge pull request #164 from mpigou/feat-verbose-cmake #123
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Run tests on push | |
| on: | |
| push: | |
| jobs: | |
| cache_files: | |
| name: Cache files | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Check if cache already exists | |
| uses: actions/cache/restore@v4 | |
| id: file_cache | |
| with: | |
| path: local_cache | |
| key: ${{ hashFiles('src/few/files/registry.yml') }} | |
| lookup-only: true | |
| - name: Install Python 3.12 | |
| if: steps.file_cache.outputs.cache-hit != 'true' | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Install bare package | |
| if: steps.file_cache.outputs.cache-hit != 'true' | |
| run: | | |
| python -m pip install . --config-settings=cmake.define.FEW_WITH_GPU=BARE | |
| - name: Download files into cache | |
| if: steps.file_cache.outputs.cache-hit != 'true' | |
| run: | | |
| mkdir -p local_cache | |
| few_files fetch --download-dir $(pwd)/local_cache --tag testfile | |
| - name: Save the cache | |
| uses: actions/cache/save@v4 | |
| if: steps.file_cache.outputs.cache-hit != 'true' | |
| with: | |
| path: local_cache | |
| key: ${{ hashFiles('src/few/files/registry.yml') }} | |
| select_matrix: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| matrix: ${{ steps.read-matrix.outputs.matrix }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| sparse-checkout: | | |
| .github | |
| - id: read-matrix | |
| run: | | |
| echo matrix=$(jq -c . .github/workflows/tests.matrix.${{ github.event.repository.visibility }}.json) >> $GITHUB_OUTPUT | |
| install_and_run_tests: | |
| name: Install and run non-GPU tests | |
| runs-on: ${{ matrix.os }} | |
| needs: | |
| - cache_files | |
| - select_matrix | |
| strategy: | |
| fail-fast: false | |
| matrix: ${{ fromJson(needs.select_matrix.outputs.matrix) }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Restore the cache | |
| uses: actions/cache/restore@v4 | |
| id: restore_cache | |
| with: | |
| path: local_cache | |
| key: ${{ hashFiles('src/few/files/registry.yml') }} | |
| - name: List artifacts | |
| if: steps.restore_cache.outputs.cache-hit == 'true' | |
| run: | | |
| ls -R ./local_cache | |
| - name: Export configuration options to force using prefetched cache of files | |
| if: steps.restore_cache.outputs.cache-hit == 'true' | |
| run: | | |
| echo "FEW_FILE_ALLOW_DOWNLOAD=no" >> "$GITHUB_ENV" | |
| echo "FEW_FILE_EXTRA_PATHS=$(pwd)/local_cache" >> "$GITHUB_ENV" | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: '${{ matrix.python-version }}' | |
| - name: Install LAPACKE and pandoc | |
| uses: ConorMacBride/install-package@v1 | |
| with: | |
| brew: lapack pandoc | |
| apt: liblapacke-dev pandoc | |
| - name: Export LAPACK pkgconfig path (macOS 13) | |
| if: matrix.os == 'macos-13' | |
| run: | | |
| echo "LAPACK_PKG_CONFIG_PATH=/usr/local/opt/lapack/lib/pkgconfig" >> "$GITHUB_ENV" | |
| - name: Export LAPACK pkgconfig path (macOS 14 and 15) | |
| if: matrix.os == 'macos-14' || matrix.os == 'macos-15' | |
| run: | | |
| echo "LAPACK_PKG_CONFIG_PATH=/opt/homebrew/opt/lapack/lib/pkgconfig" >> "$GITHUB_ENV" | |
| - name: Build list of disabled tags | |
| if: matrix.disabled_tags | |
| run: | | |
| echo "FEW_DISABLED_TAGS=${{ matrix.disabled_tags }}" >> "$GITHUB_ENV" | |
| - name: Enable test duration measurments | |
| if: matrix.python-version == '3.12' || matrix.python-version == '3.13' | |
| run: | | |
| echo FEWTEST_OTHER_ARGS='--durations 0' >> "$GITHUB_ENV" | |
| - name: Install package | |
| run: | | |
| which python | |
| export PKG_CONFIG_PATH=${LAPACK_PKG_CONFIG_PATH}:${PKG_CONFIG_PATH} | |
| python --version | |
| python -m pip install '.[testing, doc]' \ | |
| --config-settings=cmake.define.FEW_WITH_GPU=OFF \ | |
| --config-settings=cmake.define.FEW_LAPACKE_FETCH=OFF \ | |
| --config-settings=cmake.define.FEW_LAPACKE_DETECT_WITH=PKGCONFIG | |
| - name: Install coverage | |
| run: | | |
| python -m pip install coverage[toml] | |
| - name: Run module tests | |
| run: | | |
| echo "coverage run --source=few -m few.tests ${FEWTEST_OTHER_ARGS}" | |
| coverage run --source=few -m few.tests ${FEWTEST_OTHER_ARGS} | |
| - name: Run doc tests | |
| if: matrix.doctest == 'true' | |
| run: | | |
| coverage run --source=few -m sphinx.cmd.build -M doctest docs/source docs/build --define nbsphinx_execute=never | |
| - name: Show coverage results | |
| run: | | |
| coverage report -m | |
| - name: Upload coverage results as artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-${{ strategy.job-index }} | |
| path: .coverage | |
| retention-days: 2 | |
| include-hidden-files: true | |
| if-no-files-found: error | |
| compute-coverage: | |
| runs-on: ubuntu-latest | |
| needs: | |
| - install_and_run_tests | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install coverage | |
| run: | | |
| python -m pip install coverage | |
| - name: Retrieve release distributions | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: coverage_results/ | |
| merge-multiple: false | |
| - name: Merge coverage files | |
| run: | | |
| coverage combine coverage_results/*/.coverage | |
| - name: Export to Cobertura XML | |
| run: | | |
| coverage xml | |
| - name: Summary | |
| uses: irongut/CodeCoverageSummary@v1.3.0 | |
| with: | |
| filename: coverage.xml | |
| badge: true | |
| output: both | |
| thresholds: '40 80' |