|
| 1 | +# This is our full unit tests |
| 2 | +# Self-hosted, run on an old notebook |
| 3 | +name: Unit testing |
| 4 | + |
| 5 | +on: |
| 6 | + push: |
| 7 | + branches: [development, maintenance] |
| 8 | + pull_request: |
| 9 | + branches: [development, maintenance] |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +jobs: |
| 13 | + |
| 14 | + build: |
| 15 | + name: Unit tests |
| 16 | + runs-on: self-hosted |
| 17 | + |
| 18 | + strategy: |
| 19 | + matrix: |
| 20 | + os: [ubuntu-latest] |
| 21 | + python-version: ['3.9.13', '3.10', '3.11', '3.12', '3.13'] |
| 22 | + architecture: ['x64'] |
| 23 | + |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@v4 |
| 26 | + - name: Setup Python |
| 27 | + uses: actions/setup-python@v5 |
| 28 | + with: |
| 29 | + python-version: ${{ matrix.python-version }} |
| 30 | + |
| 31 | + - name: Install dependencies part 1 |
| 32 | + run: | |
| 33 | + rm -rf .venv |
| 34 | + python -m venv .venv |
| 35 | + source .venv/bin/activate |
| 36 | + pip install --upgrade pip |
| 37 | + python -m pip install -U pip wheel setuptools |
| 38 | + - name: Install dependencies part 2 |
| 39 | + run: | |
| 40 | + source .venv/bin/activate |
| 41 | + python -m pip install -I -e .[testing_libraries] |
| 42 | + - name: Test with pytest |
| 43 | + run: | |
| 44 | + source .venv/bin/activate |
| 45 | + which python |
| 46 | + python -c "import pyglet; print('pyglet version', pyglet.__version__)" |
| 47 | + python -c "import PIL; print('Pillow version', PIL.__version__)" |
| 48 | + pytest --maxfail=10 |
| 49 | +
|
| 50 | + # Prepare the Pull Request Payload artifact. If this fails, we |
| 51 | + # we fail silently using the `continue-on-error` option. It's |
| 52 | + # nice if this succeeds, but if it fails for any reason, it |
| 53 | + # does not mean that our main workflow has failed. |
| 54 | + - name: Prepare Pull Request Payload artifact |
| 55 | + id: prepare-artifact |
| 56 | + if: always() && github.event_name == 'pull_request' |
| 57 | + continue-on-error: true |
| 58 | + run: cat $GITHUB_EVENT_PATH | jq '.pull_request' > pull_request_payload.json |
| 59 | + |
| 60 | + # This only makes sense if the previous step succeeded. To |
| 61 | + # get the original outcome of the previous step before the |
| 62 | + # `continue-on-error` conclusion is applied, we use the |
| 63 | + # `.outcome` value. This step also fails silently. |
| 64 | + - name: Upload a Build Artifact |
| 65 | + if: always() && steps.prepare-artifact.outcome == 'success' |
| 66 | + continue-on-error: true |
| 67 | + uses: actions/upload-artifact@v4 |
| 68 | + with: |
| 69 | + name: pull-request-payload |
| 70 | + path: pull_request_payload.json |
0 commit comments