|
| 1 | +name: Run tests and upload coverage |
| 2 | + |
| 3 | +on: |
| 4 | + push |
| 5 | + |
| 6 | +jobs: |
| 7 | + test: |
| 8 | + name: Run tests with pytest |
| 9 | + runs-on: ${{ matrix.os }} |
| 10 | + strategy: |
| 11 | + matrix: |
| 12 | + os: ["ubuntu-latest", "windows-latest", "macos-latest"] |
| 13 | + python-version: ["3.10"] |
| 14 | + fail-fast: false |
| 15 | + |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v4 |
| 18 | + |
| 19 | + - name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }} |
| 20 | + uses: actions/setup-python@v5 |
| 21 | + with: |
| 22 | + python-version: ${{ matrix.python-version }} |
| 23 | + allow-prereleases: true |
| 24 | + |
| 25 | + # Step for Windows: Create and activate a virtual environment |
| 26 | + - name: Create and activate a virtual environment (Windows) |
| 27 | + if: ${{ runner.os == 'Windows' }} |
| 28 | + run: | |
| 29 | + irm https://astral.sh/uv/install.ps1 | iex |
| 30 | + uv venv .venv |
| 31 | + "VIRTUAL_ENV=.venv" | Out-File -FilePath $env:GITHUB_ENV -Append |
| 32 | + "$PWD/.venv/Scripts" | Out-File -FilePath $env:GITHUB_PATH -Append |
| 33 | +
|
| 34 | + # Step for Unix: Create and activate a virtual environment |
| 35 | + - name: Create and activate a virtual environment (Unix) |
| 36 | + if: ${{ runner.os != 'Windows' }} |
| 37 | + run: | |
| 38 | + curl -LsSf https://astral.sh/uv/install.sh | sh |
| 39 | + uv venv .venv |
| 40 | + echo "VIRTUAL_ENV=.venv" >> $GITHUB_ENV |
| 41 | + echo "$PWD/.venv/bin" >> $GITHUB_PATH |
| 42 | +
|
| 43 | + # Install dependencies using uv pip |
| 44 | + - name: Install dependencies |
| 45 | + run: make install |
| 46 | + # run: uv pip install -e ".[pytest]" |
| 47 | + |
| 48 | + # Run tests with coverage |
| 49 | + - name: Run tests under coverage |
| 50 | + run: | |
| 51 | + coverage run -m pytest |
| 52 | + coverage report |
| 53 | +
|
| 54 | + # Upload results to Codecov |
| 55 | + - name: Upload results to Codecov |
| 56 | + uses: codecov/codecov-action@v4 |
| 57 | + with: |
| 58 | + token: ${{ secrets.CODECOV_TOKEN }} |
0 commit comments