2
0

python_matrix.yml 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. name: Python Matrix from config file
  2. on:
  3. pull_request:
  4. types: [labeled, synchronize, opened, reopened]
  5. paths-ignore:
  6. - 'docs/**'
  7. workflow_dispatch:
  8. concurrency:
  9. group: ${{ github.workflow }}-${{ github.ref }}
  10. cancel-in-progress: true
  11. permissions:
  12. contents: read
  13. jobs:
  14. define-matrix:
  15. if: contains(github.event.pull_request.labels.*.name, 'python-matrix')
  16. runs-on: ubuntu-latest
  17. outputs:
  18. python_versions_output: ${{ steps.set-matrix.outputs.python_versions }}
  19. steps:
  20. - name: Checkout code
  21. uses: actions/checkout@v4
  22. - id: set-matrix
  23. run: |
  24. python_versions=$(sed -n "s/^.*Programming Language :: Python :: \([[:digit:]]\+\.[[:digit:]]\+\).*$/'\1', /p" pyproject.toml | tr -d '\n' | sed 's/, $//g')
  25. echo "Supported Python versions: $python_versions"
  26. echo "python_versions=[$python_versions]" >> "$GITHUB_OUTPUT"
  27. python:
  28. runs-on: ubuntu-latest
  29. needs: define-matrix
  30. strategy:
  31. matrix:
  32. python-version: ${{ fromJson(needs.define-matrix.outputs.python_versions_output) }}
  33. steps:
  34. - name: Checkout
  35. uses: actions/checkout@v4
  36. - name: Set up Python ${{ matrix.python-version }}
  37. uses: actions/setup-python@v5
  38. with:
  39. python-version: ${{ matrix.python-version }}
  40. cache: 'pip'
  41. cache-dependency-path: 'tests/requirements/py3.txt'
  42. - name: Install libmemcached-dev for pylibmc
  43. run: sudo apt-get install libmemcached-dev
  44. - name: Install and upgrade packaging tools
  45. run: python -m pip install --upgrade pip setuptools wheel
  46. - run: python -m pip install -r tests/requirements/py3.txt -e .
  47. - name: Run tests
  48. run: python tests/runtests.py -v2