Merge pull request #67 from psf/sdist-tox-ini #170
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Run CI | |
| on: [push, pull_request] | |
| jobs: | |
| unit-tests: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| # PyPy is omitted: the mainapp extra pulls gevent, which ships no PyPy | |
| # wheels and fails to build from source on PyPy under Cython 3. | |
| python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] | |
| os: [ubuntu-22.04, macOS-latest, windows-latest] | |
| # Python 3.8 and 3.9 do not run on macOS-latest which | |
| # is now using arm64 hardware. | |
| # https://github.com/actions/setup-python/issues/696#issuecomment-1637587760 | |
| exclude: | |
| - { python-version: "3.8", os: "macos-latest" } | |
| - { python-version: "3.9", os: "macos-latest" } | |
| include: | |
| - { python-version: "3.8", os: "macos-13" } | |
| - { python-version: "3.9", os: "macos-13" } | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| # from https://github.com/actions/cache/blob/main/examples.md#python---pip | |
| - name: Get pip cache dir | |
| id: pip-cache | |
| shell: bash | |
| run: | | |
| echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT | |
| - name: pip cache | |
| uses: actions/cache@v3 | |
| with: | |
| path: ${{ steps.pip-cache.outputs.dir }} | |
| # the action does not permit updating an existing cache, so we need | |
| # unique keys | |
| key: ${{ runner.os }}-${{ matrix.python-version }}-pip-${{ github.sha }} | |
| restore-keys: | | |
| ${{ runner.os }}-${{ matrix.python-version }}-pip- | |
| - name: Set up environment & install dependencies | |
| run: | | |
| python -m pip install pip-tools | |
| pip-compile --quiet --generate-hashes --extra mainapp > requirements.txt | |
| python -m pip install --use-pep517 --requirement requirements.txt | |
| python -m pip install --use-pep517 .[test] | |
| - name: Run tests | |
| run: python -m pytest tests | |
| - name: Store tested requirements.txt file as artifact | |
| # Only upload from a single matrix job: upload-artifact@v4 errors on | |
| # duplicate artifact names, and the docker job only needs one copy. | |
| if: matrix.os == 'ubuntu-22.04' && matrix.python-version == '3.10' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: requirements.txt | |
| path: | | |
| requirements.txt | |
| publish-docker-image: | |
| runs-on: ubuntu-latest | |
| needs: [unit-tests] | |
| steps: | |
| - name: System Dependencies for Packaging | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y python3-pip python3-venv | |
| python3 -m venv /tmp/tomlq | |
| /tmp/tomlq/bin/pip install --upgrade pip | |
| /tmp/tomlq/bin/pip install yq | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| - name: Set Environment | |
| run: | | |
| echo "APP_VERSION=$(/tmp/tomlq/bin/tomlq -r .project.version pyproject.toml)" >> $GITHUB_ENV | |
| echo "APP_DESC=$(/tmp/tomlq/bin/tomlq -r .project.description pyproject.toml)" >> $GITHUB_ENV | |
| - name: Retrieve tested requirements file | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: requirements.txt | |
| - name: Ensure docker build is working | |
| run: > | |
| docker build | |
| --build-arg "APP_VERSION=${APP_VERSION}" | |
| --build-arg "APP_DESC=${APP_DESC}" | |
| . |