|
1 | 1 | name: CI |
2 | 2 |
|
3 | | -'on': |
| 3 | +"on": |
| 4 | + merge_group: {} |
| 5 | + pull_request: {} |
4 | 6 | push: |
5 | 7 | 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: {} |
| 8 | + - "dependabot/**" |
| 9 | + - "renovate/**" |
| 10 | + - "u/**" |
| 11 | + release: |
| 12 | + types: [published] |
17 | 13 |
|
18 | 14 | jobs: |
19 | 15 | lint: |
20 | 16 | runs-on: ubuntu-latest |
| 17 | + timeout-minutes: 10 |
21 | 18 |
|
22 | 19 | steps: |
23 | | - - uses: actions/checkout@v3 |
| 20 | + - uses: actions/checkout@v4 |
24 | 21 |
|
25 | 22 | - name: Set up Python |
26 | | - uses: actions/setup-python@v4 |
| 23 | + uses: actions/setup-python@v5 |
27 | 24 | with: |
28 | | - python-version: "3.10" |
| 25 | + python-version-file: ".python-version" |
| 26 | + |
| 27 | + - name: Install uv |
| 28 | + uses: astral-sh/setup-uv@v5 |
29 | 29 |
|
30 | | - - name: Run pre-commit |
31 | | - uses: pre-commit/action@v3.0.0 |
| 30 | + - name: Run linters |
| 31 | + run: uv run --only-group=lint pre-commit run --all-files |
32 | 32 |
|
33 | 33 | test: |
34 | 34 | runs-on: ubuntu-latest |
35 | | - needs: [lint] |
36 | | - |
37 | | - strategy: |
38 | | - matrix: |
39 | | - python: |
40 | | - - "3.10" |
41 | | - db: |
42 | | - - sqlite |
43 | | - - postgres |
44 | | - # - mysql |
| 35 | + timeout-minutes: 10 |
45 | 36 |
|
46 | 37 | steps: |
47 | | - - uses: actions/checkout@v3 |
48 | | - |
49 | | - - name: Install build tools |
50 | | - run: sudo apt-get install build-essential |
| 38 | + - uses: actions/checkout@v4 |
| 39 | + with: |
| 40 | + fetch-depth: 0 |
51 | 41 |
|
52 | 42 | - name: Set up Python |
53 | | - uses: actions/setup-python@v4 |
| 43 | + uses: actions/setup-python@v5 |
54 | 44 | with: |
55 | | - python-version: ${{ matrix.python }} |
| 45 | + python-version-file: ".python-version" |
56 | 46 |
|
57 | | - - name: Install tox |
58 | | - run: | |
59 | | - pip install 'requests<2.32.0' |
60 | | - pip install tox |
61 | | - pip install --pre tox-docker |
| 47 | + - name: Install uv |
| 48 | + uses: astral-sh/setup-uv@v5 |
62 | 49 |
|
63 | | - - name: Cache tox environments |
64 | | - id: cache-tox |
65 | | - uses: actions/cache@v3 |
66 | | - with: |
67 | | - path: .tox |
68 | | - # requirements/*.txt and pyproject.toml have versioning info |
69 | | - # that would impact the tox environment. |
70 | | - key: tox-${{ matrix.python }}--${{ matrix.db }}-${{ hashFiles('requirements/*.txt') }}-${{ hashFiles('pyproject.toml') }} |
71 | | - restore-keys: | |
72 | | - tox-${{ matrix.python }}-${{ matrix.db }}-${{ hashFiles('requirements/*.txt') }}- |
73 | | -
|
74 | | - - name: Run tox with external services |
75 | | - if: ${{ matrix.python == '3.10' && matrix.db == 'postgres' }} |
76 | | - env: |
77 | | - LTD_KEEPER_TEST_AWS_ID: ${{ secrets.LTD_KEEPER_TEST_AWS_ID }} |
78 | | - LTD_KEEPER_TEST_AWS_SECRET: ${{ secrets.LTD_KEEPER_TEST_AWS_SECRET }} |
79 | | - LTD_KEEPER_TEST_BUCKET: ${{ secrets.LTD_KEEPER_TEST_BUCKET }} |
80 | | - # run: tox -e typing,${{matrix.db}},coverage-report # run tox using Python in path |
81 | | - run: tox -e ${{matrix.db}},coverage-report # run tox using Python in path |
82 | | - |
83 | | - - name: Run tox without external services |
84 | | - if: ${{ !(matrix.python != '3.10' && matrix.db != 'postgres') }} |
85 | | - # run: tox -e typing,${{matrix.db}},coverage-report # run tox using Python in path |
86 | | - run: tox -e ${{matrix.db}},coverage-report # run tox using Python in path |
87 | | - |
88 | | - docs: |
| 50 | + - name: Run typing |
| 51 | + run: uv run --only-group=nox nox -s typing |
| 52 | + |
| 53 | + - name: Run tests |
| 54 | + run: uv run --only-group=nox nox -s test |
| 55 | + |
| 56 | + client-test: |
89 | 57 | runs-on: ubuntu-latest |
90 | | - needs: [lint] |
| 58 | + timeout-minutes: 10 |
91 | 59 |
|
92 | 60 | steps: |
93 | | - - uses: actions/checkout@v3 |
| 61 | + - uses: actions/checkout@v4 |
94 | 62 | with: |
95 | 63 | fetch-depth: 0 |
96 | 64 |
|
97 | 65 | - name: Set up Python |
98 | | - uses: actions/setup-python@v4 |
| 66 | + uses: actions/setup-python@v5 |
99 | 67 | with: |
100 | | - python-version: "3.10" |
| 68 | + python-version: | |
| 69 | + 3.12 |
| 70 | + 3.13 |
101 | 71 |
|
102 | | - - name: Install Python dependencies |
103 | | - run: pip install tox ltd-conveyor |
| 72 | + - name: Install uv |
| 73 | + uses: astral-sh/setup-uv@v5 |
104 | 74 |
|
105 | | - - name: Cache tox environment for docs |
106 | | - id: cache-tox |
107 | | - uses: actions/cache@v3 |
108 | | - with: |
109 | | - path: .tox |
110 | | - # requirements/*.txt, pyproject.toml, and .pre-commit-config.yaml |
111 | | - # have versioning info that would impact the tox environment. |
112 | | - key: tox-docs-${{ hashFiles('requirements/*.txt') }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('.pre-commit-config.yaml') }} |
113 | | - |
114 | | - - name: Run tox |
115 | | - run: tox -e docs |
116 | | - |
117 | | - - name: Upload documentation |
118 | | - if: ${{ github.event_name == 'push' }} |
119 | | - env: |
120 | | - LTD_PASSWORD: ${{ secrets.LTD_PASSWORD }} |
121 | | - LTD_USERNAME: ${{ secrets.LTD_USERNAME }} |
122 | | - run: | |
123 | | - ltd upload --gh --dir docs/_build/html --product ltd-keeper |
| 75 | + - name: Run client tests |
| 76 | + run: >- |
| 77 | + uv run --only-group=nox nox -s |
| 78 | + client_test |
| 79 | + client_test_compat |
| 80 | + client_test_oldest |
124 | 81 |
|
125 | 82 | build: |
| 83 | + needs: [test, client-test] |
| 84 | + uses: lsst-sqre/multiplatform-build-and-push/.github/workflows/build.yaml@v3 |
| 85 | + with: |
| 86 | + images: ghcr.io/${{ github.repository }} |
| 87 | + # Build on server releases and ticket branch PRs (exclude client releases) |
| 88 | + if: > |
| 89 | + (github.event_name == 'release' |
| 90 | + && !startsWith(github.event.release.tag_name, 'client/')) |
| 91 | + || (github.event_name != 'merge_group' |
| 92 | + && (startsWith(github.head_ref, 'tickets/') |
| 93 | + || startsWith(github.head_ref, 't/'))) |
| 94 | +
|
| 95 | + client-test-packaging: |
| 96 | + name: Test client packaging |
126 | 97 | runs-on: ubuntu-latest |
127 | | - needs: [test] |
128 | | - |
129 | | - # Only do Docker builds of ticket branches and tagged releases, as well |
130 | | - # as J.Sick Codes branches. |
131 | | - # if: > |
132 | | - # (startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/tickets/')) || startsWith(github.ref, 'refs/heads/u/jsickcodes/') |
| 98 | + timeout-minutes: 5 |
| 99 | + needs: [lint, test, client-test] |
133 | 100 |
|
134 | 101 | steps: |
135 | | - - uses: actions/checkout@v3 |
| 102 | + - uses: actions/checkout@v4 |
136 | 103 | with: |
137 | | - fetch-depth: 0 |
| 104 | + fetch-depth: 0 # full history for setuptools_scm |
138 | 105 |
|
139 | | - - name: Define the Docker tag |
140 | | - id: vars |
141 | | - run: echo ::set-output name=tag::$(bin/docker-tag.sh) |
142 | | - |
143 | | - - name: Print the tag |
144 | | - id: print |
145 | | - run: echo ${{ steps.vars.outputs.tag }} |
| 106 | + - name: Build and publish |
| 107 | + uses: lsst-sqre/build-and-publish-to-pypi@v3 |
| 108 | + with: |
| 109 | + working-directory: client |
| 110 | + upload: false |
146 | 111 |
|
147 | | - - name: Set up Docker Buildx |
148 | | - uses: docker/setup-buildx-action@v2 |
| 112 | + client-pypi: |
| 113 | + name: Upload client to PyPI |
| 114 | + runs-on: ubuntu-latest |
| 115 | + timeout-minutes: 10 |
| 116 | + needs: [lint, test, client-test, client-test-packaging] |
| 117 | + environment: |
| 118 | + name: pypi |
| 119 | + url: https://pypi.org/p/docverse-client |
| 120 | + permissions: |
| 121 | + id-token: write |
| 122 | + if: > |
| 123 | + github.event_name == 'release' |
| 124 | + && startsWith(github.event.release.tag_name, 'client/') |
149 | 125 |
|
150 | | - - name: Log in to GitHub Container Registry |
151 | | - uses: docker/login-action@v2 |
| 126 | + steps: |
| 127 | + - uses: actions/checkout@v4 |
152 | 128 | with: |
153 | | - registry: ghcr.io |
154 | | - username: ${{ github.repository_owner }} |
155 | | - password: ${{ secrets.GITHUB_TOKEN }} |
| 129 | + fetch-depth: 0 # full history for setuptools_scm |
156 | 130 |
|
157 | | - - name: Build and push |
158 | | - uses: docker/build-push-action@v3 |
| 131 | + - name: Build and publish |
| 132 | + uses: lsst-sqre/build-and-publish-to-pypi@v3 |
159 | 133 | with: |
160 | | - context: . |
161 | | - push: true |
162 | | - tags: | |
163 | | - ghcr.io/lsst-sqre/ltd-keeper:${{ steps.vars.outputs.tag }} |
164 | | - cache-from: type=gha |
165 | | - cache-to: type=gha,mode=max |
| 134 | + working-directory: client |
0 commit comments