|
| 1 | +--- |
| 2 | +name: CI |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + branches: [master] |
| 7 | + tags: [v*] |
| 8 | + pull_request: |
| 9 | + branches: [master] |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +jobs: |
| 13 | + lint: |
| 14 | + name: Run linters |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v2 |
| 18 | + - uses: actions/setup-python@v2 |
| 19 | + - name: Install check-wheel-content, pre-commit, and twine |
| 20 | + run: python -m pip install build pre-commit check-wheel-contents twine |
| 21 | + - name: Build package |
| 22 | + run: python -m build |
| 23 | + - name: Run linter |
| 24 | + run: python -m pre_commit run --all-files --show-diff-on-failure |
| 25 | + - name: Check wheel contents |
| 26 | + run: check-wheel-contents dist/*.whl |
| 27 | + - name: Check by twine |
| 28 | + run: python -m twine check dist/* |
| 29 | + |
| 30 | + test: |
| 31 | + strategy: |
| 32 | + matrix: |
| 33 | + python-version: ['3.7', '3.8', '3.9', '3.10'] |
| 34 | + runs-on: ubuntu-latest |
| 35 | + |
| 36 | + steps: |
| 37 | + - uses: actions/checkout@v2 |
| 38 | + - name: Set up Python ${{ matrix.python-version }} |
| 39 | + uses: actions/setup-python@v2 |
| 40 | + with: |
| 41 | + python-version: ${{ matrix.python-version }} |
| 42 | + - name: Install Python ${{ matrix.python-version }} dependencies |
| 43 | + run: | |
| 44 | + python -m pip install --upgrade pip |
| 45 | + pip install . |
| 46 | + - name: Run pytest |
| 47 | + run: pytest |
| 48 | + |
| 49 | + |
| 50 | + deploy: |
| 51 | + name: Deploy |
| 52 | + environment: release |
| 53 | + # Run only on pushing a tag |
| 54 | + if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') |
| 55 | + needs: [lint, test] |
| 56 | + runs-on: ubuntu-latest |
| 57 | + steps: |
| 58 | + - name: Checkout |
| 59 | + |
| 60 | + with: |
| 61 | + fetch-depth: 0 |
| 62 | + - name: Install build |
| 63 | + run: python -m pip install build pre-commit check-wheel-contents twine |
| 64 | + - name: Build package |
| 65 | + run: python -m build |
| 66 | + - name: PyPI upload |
| 67 | + |
| 68 | + with: |
| 69 | + packages_dir: dist |
| 70 | + password: ${{ secrets.PYPI_API_TOKEN }} |
| 71 | + - name: GitHub Release |
| 72 | + uses: ncipollo/release-action@v1 |
| 73 | + with: |
| 74 | + name: pytest-aiohttp ${{ github.ref_name }} |
| 75 | + artifacts: dist/* |
| 76 | + bodyFile: README.rst |
| 77 | + token: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments