|
| 1 | +name: Test |
| 2 | +concurrency: |
| 3 | + group: ${{ github.workflow }}-${{ github.event.number }}-${{ github.event.ref }} |
| 4 | + cancel-in-progress: true |
| 5 | + |
| 6 | +on: |
| 7 | + pull_request: |
| 8 | + paths-ignore: |
| 9 | + - 'docs/**' |
| 10 | + push: |
| 11 | + branches: |
| 12 | + - main |
| 13 | + release: |
| 14 | + types: |
| 15 | + - published |
| 16 | + |
| 17 | +jobs: |
| 18 | + style: |
| 19 | + name: Check style |
| 20 | + runs-on: ubuntu-22.04 |
| 21 | + timeout-minutes: 2 |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v4 |
| 24 | + - uses: actions/setup-python@v5 |
| 25 | + with: |
| 26 | + python-version: '3.12' |
| 27 | + - uses: pre-commit/action@v3.0.1 |
| 28 | + |
| 29 | + build_wheels: |
| 30 | + needs: style |
| 31 | + strategy: |
| 32 | + matrix: |
| 33 | + os: [ubuntu-22.04, windows-2022, macos-15, macos-13] |
| 34 | + arch: [native] |
| 35 | + include: |
| 36 | + - os: ubuntu-22.04 |
| 37 | + arch: aarch64 |
| 38 | + fail-fast: false |
| 39 | + timeout-minutes: 15 # Linux ~1 min, Windows ~4 min, aarch64 emulated ~8 min with tests (~3 min without) |
| 40 | + name: cibuildwheel (${{ matrix.os }} ${{ matrix.arch }}) |
| 41 | + runs-on: ${{ matrix.os }} |
| 42 | + steps: |
| 43 | + - uses: actions/checkout@v4 |
| 44 | + - name: Set wheel tests to be skipped on emulated archs on PRs |
| 45 | + run: | |
| 46 | + if [[ "${{ github.event_name }}" == "pull_request" ]] && [[ "${{ matrix.arch }}" == "aarch64" ]]; then |
| 47 | + echo "CIBW_TEST_SKIP=*" | tee -a $GITHUB_ENV |
| 48 | + fi |
| 49 | + shell: bash |
| 50 | + # For aarch64 support https://cibuildwheel.pypa.io/en/stable/faq/#emulation |
| 51 | + - uses: docker/setup-qemu-action@v3 |
| 52 | + with: |
| 53 | + platforms: all |
| 54 | + if: runner.os == 'Linux' && matrix.arch == 'aarch64' |
| 55 | + - name: Build wheels and run tests |
| 56 | + uses: pypa/cibuildwheel@v2.22.0 |
| 57 | + env: |
| 58 | + CIBW_ARCHS: ${{ matrix.arch }} |
| 59 | + - uses: actions/upload-artifact@v4 |
| 60 | + with: |
| 61 | + name: artifact-${{ matrix.os }}-${{ matrix.arch }} |
| 62 | + path: ./wheelhouse/*.whl |
| 63 | + |
| 64 | + test: |
| 65 | + needs: build_wheels |
| 66 | + strategy: |
| 67 | + matrix: |
| 68 | + os: [ubuntu-22.04, windows-2022, macos-15, macos-13] |
| 69 | + python-version: ['3.12'] |
| 70 | + include: |
| 71 | + - os: ubuntu-22.04 |
| 72 | + python-version: '3.13' |
| 73 | + fail-fast: false |
| 74 | + name: Test wheels (${{ matrix.os }} py${{ matrix.python-version }}) |
| 75 | + runs-on: ${{ matrix.os }} |
| 76 | + timeout-minutes: 5 |
| 77 | + defaults: |
| 78 | + run: |
| 79 | + shell: bash -eo pipefail {0} |
| 80 | + steps: |
| 81 | + - uses: actions/checkout@v4 |
| 82 | + - uses: actions/setup-python@v5 |
| 83 | + with: |
| 84 | + python-version: ${{ matrix.python-version }} |
| 85 | + - uses: actions/download-artifact@v4 |
| 86 | + with: |
| 87 | + pattern: artifact-${{ matrix.os }}-native |
| 88 | + merge-multiple: true |
| 89 | + path: dist |
| 90 | + - run: ls -al dist |
| 91 | + - name: Triage dependencies |
| 92 | + run: | |
| 93 | + if [[ "${{ matrix.python-version }}" != "3.13" ]]; then |
| 94 | + echo "PIP_EXTRA=wfdb numpy<2 numba pytest-error-for-skips" | tee -a $GITHUB_ENV |
| 95 | + echo "PYTEST_EXTRA=--error-for-skips" | tee -a $GITHUB_ENV |
| 96 | + fi |
| 97 | + - run: python -m pip install ./dist/*.whl pytest pytest-cov edfio $PIP_EXTRA --only-binary="numpy,numba,edfio" |
| 98 | + - run: pytest -rfEXs --cov=sleepecg --cov-report=xml --tb=short --cov-branch --color=yes $PYTEST_EXTRA tests/ |
| 99 | + - uses: codecov/codecov-action@v5 |
| 100 | + with: |
| 101 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 102 | + if: success() || failure() |
| 103 | + |
| 104 | + build_sdist: |
| 105 | + needs: style |
| 106 | + name: Build source distribution |
| 107 | + runs-on: ubuntu-22.04 |
| 108 | + steps: |
| 109 | + - uses: actions/checkout@v4 |
| 110 | + - uses: actions/setup-python@v5 |
| 111 | + name: Install Python |
| 112 | + with: |
| 113 | + python-version: 3.12 |
| 114 | + - name: Build sdist |
| 115 | + run: | |
| 116 | + set -eo pipefail |
| 117 | + python -m pip install build numpy |
| 118 | + python -m build --sdist |
| 119 | + - uses: actions/upload-artifact@v4 |
| 120 | + with: |
| 121 | + name: artifact-sdist |
| 122 | + path: dist/*.tar.gz |
| 123 | + |
| 124 | + check_wheels: |
| 125 | + needs: [build_wheels, build_sdist] |
| 126 | + name: Check wheels and source distribution |
| 127 | + runs-on: ubuntu-22.04 |
| 128 | + steps: |
| 129 | + - uses: actions/download-artifact@v4 |
| 130 | + with: |
| 131 | + pattern: artifact-* |
| 132 | + merge-multiple: true |
| 133 | + path: dist |
| 134 | + - run: ls -al dist |
| 135 | + shell: bash |
| 136 | + - uses: actions/setup-python@v5 |
| 137 | + with: |
| 138 | + python-version: 3.12 |
| 139 | + - run: python -m pip install twine |
| 140 | + - run: python -m twine check --strict dist/* |
| 141 | + |
| 142 | + upload-pypi: |
| 143 | + name: Upload to PyPI |
| 144 | + needs: [check_wheels, test] |
| 145 | + runs-on: ubuntu-latest |
| 146 | + if: github.event_name == 'release' |
| 147 | + steps: |
| 148 | + - uses: actions/download-artifact@v4 |
| 149 | + with: |
| 150 | + pattern: artifact-* |
| 151 | + merge-multiple: true |
| 152 | + path: dist |
| 153 | + - uses: pypa/gh-action-pypi-publish@v1.12.3 |
0 commit comments