|
4 | 4 | # :Author: Martin Thoma <info@martin-thoma.de> |
5 | 5 | # :License: MIT License |
6 | 6 | # :Copyright: © 2020 Martin Thoma |
7 | | -# :Copyright: © 2020 Lele Gaifax |
| 7 | +# :Copyright: © 2020, 2021 Lele Gaifax |
8 | 8 | # |
9 | 9 |
|
10 | 10 | # For more information see: |
11 | 11 | # https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions |
| 12 | +# and |
| 13 | +# https://packaging.python.org/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ |
12 | 14 |
|
13 | | -name: Python Unittests |
| 15 | +name: Build, test and upload to PyPI |
14 | 16 |
|
15 | 17 | on: |
16 | 18 | push: |
|
19 | 21 | branches: [ master ] |
20 | 22 |
|
21 | 23 | jobs: |
22 | | - build: |
23 | | - |
| 24 | + tests: |
| 25 | + name: All tests, on current Python |
24 | 26 | runs-on: ubuntu-latest |
| 27 | + |
25 | 28 | strategy: |
26 | 29 | matrix: |
27 | | - python-version: [3.6, 3.7, 3.8, 3.9] |
| 30 | + python-version: [3.9] |
28 | 31 |
|
29 | 32 | steps: |
30 | 33 | - uses: actions/checkout@v2 |
31 | 34 | with: |
32 | 35 | submodules: recursive |
| 36 | + |
33 | 37 | - name: Set up Python ${{ matrix.python-version }} |
34 | 38 | uses: actions/setup-python@v2 |
35 | 39 | with: |
36 | 40 | python-version: ${{ matrix.python-version }} |
| 41 | + |
37 | 42 | - name: Install dependencies |
38 | 43 | run: | |
39 | 44 | python -m pip install --upgrade pip |
40 | 45 | pip install -r requirements-test.txt |
41 | 46 | pip install . |
| 47 | +
|
42 | 48 | - name: Test with pytest |
43 | 49 | run: | |
44 | 50 | pytest tests |
| 51 | +
|
| 52 | + - name: Test memory leaks |
| 53 | + uses: deadsnakes/action@v2.1.1 |
| 54 | + with: |
| 55 | + python-version: ${{ matrix.python-version }} |
| 56 | + debug: true |
| 57 | + run: | |
| 58 | + pytest tests |
| 59 | +
|
| 60 | + - name: Execute doctest |
| 61 | + run: | |
| 62 | + make -C docs doctest -e PYTHON=$(which python3) |
| 63 | +
|
| 64 | + build_wheels: |
| 65 | + name: Build wheels on ${{ matrix.os }} |
| 66 | + runs-on: ${{ matrix.os }} |
| 67 | + strategy: |
| 68 | + matrix: |
| 69 | + os: |
| 70 | + - ubuntu-20.04 |
| 71 | + - macOS-10.15 |
| 72 | + - windows-2019 |
| 73 | + |
| 74 | + steps: |
| 75 | + - name: Checkout sources |
| 76 | + uses: actions/checkout@v2 |
| 77 | + with: |
| 78 | + submodules: true |
| 79 | + |
| 80 | + - name: Install Python |
| 81 | + uses: actions/setup-python@v2 |
| 82 | + with: |
| 83 | + python-version: '3.8' |
| 84 | + |
| 85 | + - name: Build wheels |
| 86 | + uses: pypa/cibuildwheel@v1.11.1 |
| 87 | + env: |
| 88 | + CIBW_TEST_REQUIRES: "pytest pytest-benchmark pytz" |
| 89 | + CIBW_TEST_COMMAND="pytest {project}/tests" |
| 90 | + CIBW_SKIP="cp2* cp33* cp34* cp35* pp*" |
| 91 | + |
| 92 | + - name: Upload artifacts |
| 93 | + uses: actions/upload-artifact@v2 |
| 94 | + with: |
| 95 | + path: ./wheelhouse/*.whl |
| 96 | + |
| 97 | + upload_wheels: |
| 98 | + name: Upload wheels |
| 99 | + needs: build_wheels |
| 100 | + runs-on: ubuntu-latest |
| 101 | + |
| 102 | + steps: |
| 103 | + - uses: actions/download-artifact@v2 |
| 104 | + with: |
| 105 | + name: artifact |
| 106 | + path: dist |
| 107 | + |
| 108 | + - name: Upload to Test PyPI |
| 109 | + uses: pypa/gh-action-pypi-publish@master |
| 110 | + with: |
| 111 | + password: ${{ secrets.TEST_PYPI_API_TOKEN }} |
| 112 | + repository_url: https://test.pypi.org/legacy/ |
| 113 | + |
| 114 | + # upload to PyPI on every tag starting with 'v' |
| 115 | + - name: Upload to PyPI |
| 116 | + uses: pypa/gh-action-pypi-publish@master |
| 117 | + if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') |
| 118 | + with: |
| 119 | + password: ${{ secrets.PYPI_API_TOKEN }} |
0 commit comments