|
| 1 | +name: Test with pytest |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + pull_request: |
| 9 | + branches: |
| 10 | + - main |
| 11 | + - dev |
| 12 | + |
| 13 | +concurrency: |
| 14 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} |
| 15 | + cancel-in-progress: true |
| 16 | + |
| 17 | +env: |
| 18 | + LIBRARY_BASE_REPO: NTIA/LFMF |
| 19 | + LIBRARY_RELEASE_TAG: v1.1 |
| 20 | + LIBRARY_DESTINATION_DIRECTORY: 'src/ITS/Propagation/LFMF' |
| 21 | + |
| 22 | +jobs: |
| 23 | + run-all-tests: |
| 24 | + name: ${{ matrix.platform.os-name }} / Py${{ matrix.py }} |
| 25 | + runs-on: ${{ matrix.platform.os-runner }} |
| 26 | + strategy: |
| 27 | + fail-fast: false |
| 28 | + matrix: |
| 29 | + platform: |
| 30 | + - os-name: 'Windows (64-bit)' |
| 31 | + os-runner: 'windows-latest' |
| 32 | + arch-id: 'x64' |
| 33 | + release-file-pattern: '*-x64.dll' |
| 34 | + - os-name: 'Windows (32-bit)' |
| 35 | + os-runner: 'windows-latest' |
| 36 | + arch-id: 'x86' |
| 37 | + release-file-pattern: '*-x86.dll' |
| 38 | + - os-name: 'macOS (intel/x64)' |
| 39 | + os-runner: 'macos-13' |
| 40 | + arch-id: 'x64' |
| 41 | + release-file-pattern: '*.dylib' |
| 42 | + - os-name: 'macOS (apple/arm64)' |
| 43 | + os-runner: 'macos-latest' |
| 44 | + arch-id: 'arm64' |
| 45 | + release-file-pattern: '*.dylib' |
| 46 | + - os-name: 'Linux (Ubuntu)' |
| 47 | + os-runner: 'ubuntu-latest' |
| 48 | + arch-id: 'x64' |
| 49 | + release-file-pattern: '*.so' |
| 50 | + py: # Python versions to test on all platforms |
| 51 | + - "3.9" |
| 52 | + - "3.10" |
| 53 | + - "3.11" |
| 54 | + - "3.12" |
| 55 | + steps: |
| 56 | + - name: Check out repository |
| 57 | + uses: actions/checkout@v4 |
| 58 | + with: |
| 59 | + submodules: true |
| 60 | + |
| 61 | + # Cache key is unique to the combination of runner OS + architecture (matrix.arch-id) + release tag |
| 62 | + - name: Restore ${{ env.LIBRARY_RELEASE_TAG }} binaries from cache if available |
| 63 | + id: cache-restore |
| 64 | + uses: actions/cache@v4 |
| 65 | + with: |
| 66 | + key: ${{ runner.os }}-${{ matrix.platform.arch-id }}-${{ env.LIBRARY_RELEASE_TAG }} |
| 67 | + path: ${{ env.LIBRARY_DESTINATION_DIRECTORY}}/${{ matrix.platform.release-file-pattern }} |
| 68 | + |
| 69 | + # Only the binaries required for the current platform are downloaded. Note that the distributed |
| 70 | + # wheel for proplib python packages includes all binaries, so that the wheel is inherently cross-platform. |
| 71 | + - name: Download required ${{ env.LIBRARY_RELEASE_TAG }} binaries |
| 72 | + if: ${{ steps.cache-restore.outputs.cache-hit != 'true' }} |
| 73 | + uses: robinraju/release-downloader@v1 |
| 74 | + with: |
| 75 | + repository: ${{ env.LIBRARY_BASE_REPO }} |
| 76 | + tag: ${{ env.LIBRARY_RELEASE_TAG }} |
| 77 | + fileName: ${{ matrix.platform.release-file-pattern }} |
| 78 | + tarBall: false |
| 79 | + zipBall: false |
| 80 | + out-file-path: ${{ env.LIBRARY_DESTINATION_DIRECTORY }} |
| 81 | + |
| 82 | + - name: Set up Python ${{ matrix.py }} |
| 83 | + uses: actions/setup-python@v5 |
| 84 | + with: |
| 85 | + architecture: ${{ matrix.platform.arch-id }} |
| 86 | + python-version: ${{ matrix.py }} |
| 87 | + cache: 'pip' |
| 88 | + |
| 89 | + - name: Install dependencies for testing |
| 90 | + run: python -m pip install -e .[tests] |
| 91 | + |
| 92 | + - name: Run pytest |
| 93 | + run: pytest --cov-report=term-missing --no-cov-on-fail --cov |
0 commit comments