|
| 1 | +name: Testing and distribution |
| 2 | +on: |
| 3 | + push: |
| 4 | + pull_request: |
| 5 | + workflow_dispatch: |
| 6 | + |
| 7 | +jobs: |
| 8 | + lint-python: |
| 9 | + name: Lint Python code |
| 10 | + runs-on: ubuntu-latest |
| 11 | + steps: |
| 12 | + - name: Checkout |
| 13 | + uses: actions/checkout@v2 |
| 14 | + |
| 15 | + - name: Install pipenv |
| 16 | + run: pipx install pipenv |
| 17 | + |
| 18 | + - uses: actions/setup-python@v2 |
| 19 | + with: |
| 20 | + python-version: '3.9' |
| 21 | + cache: 'pipenv' |
| 22 | + |
| 23 | + - id: pipenv-install |
| 24 | + name: Install Python dependencies |
| 25 | + run: pipenv install --dev --python `which python` |
| 26 | + |
| 27 | + - id: lint |
| 28 | + name: Lint |
| 29 | + run: pipenv run flake8 ./censusbatchgeocoder |
| 30 | + |
| 31 | + test-python: |
| 32 | + name: Test Python code |
| 33 | + runs-on: ubuntu-latest |
| 34 | + steps: |
| 35 | + - name: Checkout |
| 36 | + uses: actions/checkout@v2 |
| 37 | + |
| 38 | + - name: Install pipenv |
| 39 | + run: pipx install pipenv |
| 40 | + |
| 41 | + - uses: actions/setup-python@v2 |
| 42 | + with: |
| 43 | + python-version: '3.9' |
| 44 | + cache: 'pipenv' |
| 45 | + |
| 46 | + - id: pipenv-install |
| 47 | + name: Install Python dependencies |
| 48 | + run: pipenv install --dev --python `which python` |
| 49 | + |
| 50 | + - id: run |
| 51 | + name: Run tests |
| 52 | + run: pipenv run python setup.py test |
| 53 | + shell: bash |
| 54 | + |
| 55 | + test-build: |
| 56 | + name: Build Python package |
| 57 | + runs-on: ubuntu-latest |
| 58 | + needs: [test-python] |
| 59 | + steps: |
| 60 | + - name: Checkout |
| 61 | + uses: actions/checkout@v2 |
| 62 | + |
| 63 | + - name: Install pipenv |
| 64 | + run: pipx install pipenv |
| 65 | + |
| 66 | + - uses: actions/setup-python@v2 |
| 67 | + with: |
| 68 | + python-version: '3.9' |
| 69 | + cache: 'pipenv' |
| 70 | + |
| 71 | + - id: pipenv-install |
| 72 | + name: Install Python dependencies |
| 73 | + run: pipenv install --dev --python `which python` |
| 74 | + |
| 75 | + - id: build |
| 76 | + name: Build release |
| 77 | + run: | |
| 78 | + pipenv run python setup.py sdist |
| 79 | + pipenv run python setup.py bdist_wheel |
| 80 | +
|
| 81 | + - id: check |
| 82 | + name: Check release |
| 83 | + run: pipenv run twine check dist/* |
| 84 | + |
| 85 | + - id: save |
| 86 | + name: Save artifact |
| 87 | + uses: actions/upload-artifact@v2 |
| 88 | + with: |
| 89 | + name: test-release-${{ github.run_number }} |
| 90 | + path: ./dist |
| 91 | + if-no-files-found: error |
| 92 | + |
| 93 | + tag-release: |
| 94 | + name: Tagged PyPI release |
| 95 | + runs-on: ubuntu-latest |
| 96 | + needs: [test-build] |
| 97 | + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') |
| 98 | + steps: |
| 99 | + - uses: actions/setup-python@v2 |
| 100 | + with: |
| 101 | + python-version: '3.9' |
| 102 | + |
| 103 | + - id: fetch |
| 104 | + name: Fetch artifact |
| 105 | + uses: actions/download-artifact@v2 |
| 106 | + with: |
| 107 | + name: test-release-${{ github.run_number }} |
| 108 | + path: ./dist |
| 109 | + |
| 110 | + - id: publish |
| 111 | + name: Publish release |
| 112 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 113 | + with: |
| 114 | + user: __token__ |
| 115 | + password: ${{ secrets.PYPI_API_TOKEN }} |
| 116 | + verbose: true |
| 117 | + verify_metadata: false |
0 commit comments