|
| 1 | +name: CI |
| 2 | + |
| 3 | +# concurrency: |
| 4 | +# group: ${{ github.workflow }}-${{ github.event.number }}-${{ github.event.ref }} |
| 5 | +# cancel-in-progress: true |
| 6 | + |
| 7 | +on: |
| 8 | + push: |
| 9 | + pull_request: |
| 10 | + branches: [ "main" ] |
| 11 | + # schedule: |
| 12 | + # - cron: '2 1 3 * *' |
| 13 | + |
| 14 | + # Allows you to run this workflow manually from the Actions tab |
| 15 | + workflow_dispatch: |
| 16 | + |
| 17 | +permissions: |
| 18 | + contents: read |
| 19 | + |
| 20 | +env: |
| 21 | + PACKAGE: polsarpro |
| 22 | + |
| 23 | +jobs: |
| 24 | + build: |
| 25 | + runs-on: ubuntu-latest |
| 26 | + |
| 27 | + steps: |
| 28 | + - uses: actions/checkout@v6 |
| 29 | + with: |
| 30 | + fetch-depth: 0 |
| 31 | + submodules: 'true' |
| 32 | + |
| 33 | + - name: Set up Python |
| 34 | + uses: actions/setup-python@v6 |
| 35 | + with: |
| 36 | + python-version: "3.x" |
| 37 | + |
| 38 | + - name: Install build dependencies |
| 39 | + run: | |
| 40 | + python -m pip install --upgrade pip |
| 41 | + python -m pip install build twine |
| 42 | +
|
| 43 | + - name: Build the package |
| 44 | + run: | |
| 45 | + python -m build |
| 46 | + python -m twine check dist/* |
| 47 | +
|
| 48 | + - name: Upload build artifacts |
| 49 | + uses: actions/upload-artifact@v6 |
| 50 | + with: |
| 51 | + name: dist |
| 52 | + path: | |
| 53 | + dist/*.tar.gz |
| 54 | + dist/*.whl |
| 55 | +
|
| 56 | + test: |
| 57 | + runs-on: ${{ matrix.os }} |
| 58 | + name: ${{ matrix.os }} ${{ matrix.python-version }} |
| 59 | + needs: build |
| 60 | + strategy: |
| 61 | + matrix: |
| 62 | + python-version: ["3.12", "3.13", "3.14"] |
| 63 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 64 | + |
| 65 | + steps: |
| 66 | + # Only necessary if the test code is located outside the package |
| 67 | + - uses: actions/checkout@v6 |
| 68 | + with: |
| 69 | + submodules: 'true' |
| 70 | + |
| 71 | + - name: Get distribution |
| 72 | + uses: actions/download-artifact@v7 |
| 73 | + with: |
| 74 | + name: dist |
| 75 | + path: dist |
| 76 | + |
| 77 | + - name: Set up Python ${{ matrix.python-version }} |
| 78 | + uses: actions/setup-python@v6 |
| 79 | + with: |
| 80 | + python-version: ${{ matrix.python-version }} |
| 81 | + |
| 82 | + - name: Install |
| 83 | + shell: bash |
| 84 | + run: | |
| 85 | + python -m pip install dist/${PACKAGE}*.whl |
| 86 | +
|
| 87 | + - name: Install test dependencies |
| 88 | + shell: bash |
| 89 | + run: | |
| 90 | + python -m pip install pytest pytest-cov |
| 91 | +
|
| 92 | + - name: Test |
| 93 | + # working-directory: dist |
| 94 | + shell: bash |
| 95 | + run: | |
| 96 | + python -m pytest --cov=${PACKAGE} --cov-report=html --cov-report=term --pyargs ${PACKAGE} |
0 commit comments