|
| 1 | +name: Code CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + pull_request: |
| 6 | + |
| 7 | +jobs: |
| 8 | + lint: |
| 9 | + runs-on: "ubuntu-latest" |
| 10 | + steps: |
| 11 | + - name: Checkout Source |
| 12 | + uses: actions/checkout@v2 |
| 13 | + |
| 14 | + - name: Install Python |
| 15 | + uses: actions/setup-python@v2 |
| 16 | + with: |
| 17 | + python-version: '3.7' |
| 18 | + |
| 19 | + - name: Install Python Dependencies |
| 20 | + run: pip install flake8 |
| 21 | + |
| 22 | + - name: Lint |
| 23 | + run: flake8 |
| 24 | + |
| 25 | + build: |
| 26 | + name: ${{ matrix.os }}/${{ matrix.python }} |
| 27 | + runs-on: ${{ matrix.os }} |
| 28 | + |
| 29 | + strategy: |
| 30 | + fail-fast: false |
| 31 | + matrix: |
| 32 | + os: [ubuntu-latest, windows-latest, macos-latest] |
| 33 | + python: [cp27, cp37, cp38, cp39] |
| 34 | + |
| 35 | + exclude: |
| 36 | + - os: windows-latest |
| 37 | + # No cothread or asyncio so doesn't work |
| 38 | + python: cp27 |
| 39 | + |
| 40 | + include: |
| 41 | + - os: ubuntu-latest |
| 42 | + # Put coverage in the output dir mounted in docker |
| 43 | + cov_file: /output/coverage.xml |
| 44 | + test_requires: cothread pytest-asyncio aioca |
| 45 | + |
| 46 | + - os: windows-latest |
| 47 | + cov_file: '{project}/dist/coverage.xml' |
| 48 | + # cothread doesn't work on windows |
| 49 | + test_requires: pytest-asyncio aioca |
| 50 | + |
| 51 | + - os: macos-latest |
| 52 | + cov_file: '{project}/dist/coverage.xml' |
| 53 | + test_requires: cothread pytest-asyncio aioca |
| 54 | + |
| 55 | + - os: ubuntu-latest |
| 56 | + python: cp27 |
| 57 | + # asyncio doesn't work on Python2.7 |
| 58 | + test_requires: cothread |
| 59 | + |
| 60 | + - os: macos-latest |
| 61 | + python: cp27 |
| 62 | + # asyncio doesn't work on Python2.7 |
| 63 | + test_requires: cothread |
| 64 | + |
| 65 | + |
| 66 | + steps: |
| 67 | + - name: Checkout Source |
| 68 | + uses: actions/checkout@v2 |
| 69 | + with: |
| 70 | + submodules: true |
| 71 | + |
| 72 | + - name: Install Python |
| 73 | + uses: actions/setup-python@v2 |
| 74 | + with: |
| 75 | + python-version: '3.7' |
| 76 | + |
| 77 | + - name: Install Python Dependencies |
| 78 | + run: pip install twine build cibuildwheel |
| 79 | + |
| 80 | + - name: Build Sdist |
| 81 | + run: python -m build --sdist . |
| 82 | + |
| 83 | + - name: Build Wheel |
| 84 | + run: cibuildwheel --output-dir dist |
| 85 | + env: |
| 86 | + CIBW_BUILD: ${{ matrix.python }}*64 |
| 87 | + CIBW_TEST_REQUIRES: pytest-cov ${{ matrix.test_requires }} |
| 88 | + CIBW_TEST_COMMAND: pytest --cov=softioc {project}/tests --cov-report xml:${{ matrix.cov_file }} |
| 89 | + # Disable auditwheel as it isn't compatible with setuptools_dso approach |
| 90 | + # https://github.com/mdavidsaver/setuptools_dso/issues/17 |
| 91 | + CIBW_REPAIR_WHEEL_COMMAND: '' |
| 92 | + |
| 93 | + - name: Upload Wheel and Sdist |
| 94 | + uses: actions/upload-artifact@v2 |
| 95 | + with: |
| 96 | + name: dist |
| 97 | + path: dist/softioc* |
| 98 | + |
| 99 | + - name: Upload coverage to Codecov |
| 100 | + uses: codecov/codecov-action@v1 |
| 101 | + with: |
| 102 | + name: ${{ matrix.os }}/${{ matrix.python }} |
| 103 | + directory: dist |
| 104 | + |
| 105 | + upload_pypi: |
| 106 | + needs: [build] |
| 107 | + runs-on: ubuntu-latest |
| 108 | + # upload to PyPI on every tag |
| 109 | + if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') |
| 110 | + steps: |
| 111 | + - uses: actions/download-artifact@v2 |
| 112 | + with: |
| 113 | + name: dist |
| 114 | + path: dist |
| 115 | + |
| 116 | + - name: Publish to PyPI |
| 117 | + env: |
| 118 | + TWINE_USERNAME: __token__ |
| 119 | + TWINE_PASSWORD: ${{ secrets.pypi_token }} |
| 120 | + run: twine upload dist/* |
| 121 | + |
0 commit comments