|
1 | 1 | name: Python CI
|
2 | 2 |
|
3 |
| -on: [push] |
| 3 | +"on": |
| 4 | + push: |
| 5 | + branches-ignore: |
| 6 | + # These should always correspond to pull requests, so ignore them for |
| 7 | + # the push trigger and let them be triggered by the pull_request |
| 8 | + # trigger, avoiding running the workflow twice. This is a minor |
| 9 | + # optimization so there's no need to ensure this is comprehensive. |
| 10 | + - "dependabot/**" |
| 11 | + - "renovate/**" |
| 12 | + - "tickets/**" |
| 13 | + - "u/**" |
| 14 | + tags: |
| 15 | + - "*" |
| 16 | + pull_request: {} |
4 | 17 |
|
5 | 18 | jobs:
|
| 19 | + lint: |
| 20 | + |
| 21 | + runs-on: ubuntu-latest |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v3 |
| 24 | + |
| 25 | + - name: Set up Python |
| 26 | + uses: actions/setup-python@v4 |
| 27 | + with: |
| 28 | + python-version: "3.10" |
| 29 | + |
| 30 | + - name: Run pre-commit |
| 31 | + uses: pre-commit/[email protected] |
| 32 | + |
6 | 33 | test:
|
7 | 34 |
|
8 | 35 | runs-on: ubuntu-latest
|
| 36 | + |
9 | 37 | strategy:
|
10 | 38 | matrix:
|
11 | 39 | python:
|
12 |
| - - 3.7 |
13 |
| - - 3.8 |
| 40 | + - "3.8" |
| 41 | + - "3.9" |
| 42 | + - "3.10" |
14 | 43 |
|
15 | 44 | steps:
|
16 |
| - - uses: actions/checkout@v2 |
| 45 | + - uses: actions/checkout@v3 |
17 | 46 |
|
18 |
| - - name: Set up Python |
19 |
| - uses: actions/setup-python@v1 |
| 47 | + - name: Run tox |
| 48 | + uses: lsst-sqre/run-tox@v1 |
20 | 49 | with:
|
21 | 50 | python-version: ${{ matrix.python }}
|
22 |
| - |
23 |
| - - name: Install tox |
24 |
| - run: pip install tox |
25 |
| - |
26 |
| - - name: Run tox |
27 |
| - run: tox -e py,lint,typing # run tox using Python in path |
| 51 | + tox-envs: "py,typing" |
28 | 52 |
|
29 | 53 | docs:
|
30 | 54 |
|
31 | 55 | runs-on: ubuntu-latest
|
32 | 56 |
|
33 | 57 | steps:
|
34 |
| - - uses: actions/checkout@v2 |
35 |
| - |
36 |
| - - name: Set up Python |
37 |
| - uses: actions/setup-python@v1 |
| 58 | + - uses: actions/checkout@v3 |
38 | 59 | with:
|
39 |
| - python-version: 3.7 |
| 60 | + fetch-depth: 0 # full history for setuptools_scm |
40 | 61 |
|
41 |
| - - name: Install tox and LTD Conveyor |
42 |
| - run: pip install tox ltd-conveyor |
| 62 | + - name: Install Graphviz |
| 63 | + run: sudo apt-get install graphviz |
43 | 64 |
|
44 | 65 | - name: Run tox
|
45 |
| - run: tox -e docs |
| 66 | + uses: lsst-sqre/run-tox@v1 |
| 67 | + with: |
| 68 | + python-version: "3.10" |
| 69 | + tox-envs: "docs,docs-linkcheck" |
46 | 70 |
|
| 71 | + # Only attempt documentation uploads for tagged releases and pull |
| 72 | + # requests from ticket branches in the same repository. This avoids |
| 73 | + # version clutter in the docs and failures when a PR doesn't have access |
| 74 | + # to secrets. |
47 | 75 | - name: Upload to LSST the Docs
|
48 |
| - env: |
49 |
| - LTD_USERNAME: travis |
50 |
| - LTD_PASSWORD: ${{ secrets.LTD_PASSWORD }} |
51 |
| - run: ltd upload --product kafkit --gh --dir docs/_build/html |
| 76 | + uses: lsst-sqre/ltd-upload@v1 |
| 77 | + with: |
| 78 | + project: "kafkit" |
| 79 | + dir: "docs/_build/html" |
| 80 | + username: ${{ secrets.LTD_USERNAME }} |
| 81 | + password: ${{ secrets.LTD_PASSWORD }} |
| 82 | + if: > |
| 83 | + github.event_name != 'pull_request' |
| 84 | + || startsWith(github.head_ref, 'tickets/') |
52 | 85 |
|
53 | 86 | pypi:
|
54 | 87 |
|
55 | 88 | runs-on: ubuntu-latest
|
56 |
| - needs: [test, docs] |
57 |
| - if: startsWith(github.ref, 'refs/tags/') |
| 89 | + needs: [lint, test, docs] |
58 | 90 |
|
59 | 91 | steps:
|
60 |
| - - uses: actions/checkout@v2 |
61 |
| - |
62 |
| - - name: Set up Python |
63 |
| - uses: actions/setup-python@v1 |
| 92 | + - uses: actions/checkout@v3 |
64 | 93 | with:
|
65 |
| - python-version: 3.7 |
66 |
| - |
67 |
| - - name: Install dependencies |
68 |
| - run: | |
69 |
| - python -m pip install --upgrade pip |
70 |
| - pip install --upgrade setuptools wheel twine |
| 94 | + fetch-depth: 0 # full history for setuptools_scm |
71 | 95 |
|
72 | 96 | - name: Build and publish
|
73 |
| - env: |
74 |
| - TWINE_USERNAME: "__token__" |
75 |
| - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} |
76 |
| - run: | |
77 |
| - python setup.py sdist bdist_wheel |
78 |
| - twine upload dist/* |
| 97 | + uses: lsst-sqre/build-and-publish-to-pypi@v1 |
| 98 | + with: |
| 99 | + pypi-token: ${{ secrets.PYPI_SQRE_ADMIN }} |
| 100 | + python-version: "3.10" |
| 101 | + upload: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }} |
0 commit comments