Skip to content

Commit 81cf4c5

Browse files
committed
feat: project documentation
Added swagger ui for github pages; added github actions with periodic task to update openapi specs
1 parent 3b610cc commit 81cf4c5

45 files changed

Lines changed: 20504 additions & 19 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 366 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,366 @@
1+
name: Documentation build and push
2+
on:
3+
push:
4+
branches:
5+
- main
6+
- "**"
7+
jobs:
8+
annotation:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
python-version: [ "3.8.15" ]
13+
env:
14+
SPEC_PATH: ./docs/openapi/annotation.json
15+
steps:
16+
- uses: actions/checkout@v3
17+
- name: Set up Python ${{ matrix.python-version }}
18+
uses: actions/setup-python@v4
19+
with:
20+
python-version: ${{ matrix.python-version }}
21+
cache: 'pip'
22+
- name: Install dependencies
23+
working-directory: ./annotation
24+
run: |
25+
python -m pip install --upgrade pip
26+
pip install poetry
27+
poetry install --no-root
28+
poetry add --editable ../lib/filter_lib
29+
poetry add --editable ../lib/tenants
30+
- name: Generate documentation
31+
working-directory: ./annotation
32+
run: poetry run python app/cli.py openapi .$SPEC_PATH
33+
env:
34+
PYTHONPATH: .
35+
- name: Save documentation
36+
uses: actions/upload-artifact@v3
37+
with:
38+
path: ${{ env.SPEC_PATH }}
39+
assets:
40+
runs-on: ubuntu-latest
41+
strategy:
42+
matrix:
43+
python-version: [ "3.8.15" ]
44+
env:
45+
SPEC_PATH: ./docs/openapi/assets.json
46+
steps:
47+
- uses: actions/checkout@v3
48+
- name: Set up Python ${{ matrix.python-version }}
49+
uses: actions/setup-python@v4
50+
with:
51+
python-version: ${{ matrix.python-version }}
52+
cache: 'pip'
53+
- name: Install dependencies
54+
working-directory: ./assets
55+
run: |
56+
python -m pip install --upgrade pip
57+
sudo apt-get update && sudo apt-get -y install poppler-utils
58+
pip install -r requirements.txt
59+
pip install -e ../lib/filter_lib
60+
pip install -e ../lib/tenants
61+
- name: Generate documentation
62+
working-directory: ./assets
63+
run: python src/cli.py openapi .$SPEC_PATH
64+
env:
65+
PYTHONPATH: .
66+
- name: Save documentation
67+
uses: actions/upload-artifact@v3
68+
with:
69+
path: ${{ env.SPEC_PATH }}
70+
convert:
71+
runs-on: ubuntu-latest
72+
strategy:
73+
matrix:
74+
python-version: [ "3.8.15" ]
75+
env:
76+
SPEC_PATH: ./docs/openapi/convert.json
77+
steps:
78+
- uses: actions/checkout@v3
79+
- name: Set up Python ${{ matrix.python-version }}
80+
uses: actions/setup-python@v4
81+
with:
82+
python-version: ${{ matrix.python-version }}
83+
cache: 'pip'
84+
- name: Install dependencies
85+
working-directory: ./convert
86+
run: |
87+
python -m pip install --upgrade pip
88+
pip install poetry
89+
poetry install --no-root
90+
poetry add --editable ../lib/tenants
91+
- name: Generate documentation
92+
working-directory: ./convert
93+
run: poetry run python src/cli.py openapi .$SPEC_PATH
94+
env:
95+
PYTHONPATH: .
96+
- name: Save documentation
97+
uses: actions/upload-artifact@v3
98+
with:
99+
path: ${{ env.SPEC_PATH }}
100+
jobs:
101+
runs-on: ubuntu-latest
102+
strategy:
103+
matrix:
104+
python-version: [ "3.8.15" ]
105+
env:
106+
SPEC_PATH: ./docs/openapi/jobs.json
107+
steps:
108+
- uses: actions/checkout@v3
109+
- name: Set up Python ${{ matrix.python-version }}
110+
uses: actions/setup-python@v4
111+
with:
112+
python-version: ${{ matrix.python-version }}
113+
cache: 'pip'
114+
- name: Install dependencies
115+
working-directory: ./jobs
116+
run: |
117+
python -m pip install --upgrade pip
118+
pip install -r requirements.txt
119+
pip install -e ../lib/filter_lib
120+
pip install -e ../lib/tenants
121+
- name: Generate documentation
122+
working-directory: ./jobs
123+
run: python jobs/cli.py openapi .$SPEC_PATH
124+
env:
125+
PYTHONPATH: .
126+
- name: Save documentation
127+
uses: actions/upload-artifact@v3
128+
with:
129+
path: ${{ env.SPEC_PATH }}
130+
models:
131+
runs-on: ubuntu-latest
132+
strategy:
133+
matrix:
134+
python-version: [ "3.8.15" ]
135+
env:
136+
SPEC_PATH: ./docs/openapi/models.json
137+
steps:
138+
- uses: actions/checkout@v3
139+
- name: Set up Python ${{ matrix.python-version }}
140+
uses: actions/setup-python@v4
141+
with:
142+
python-version: ${{ matrix.python-version }}
143+
cache: 'pip'
144+
- name: Install dependencies
145+
working-directory: ./models
146+
run: |
147+
python -m pip install --upgrade pip
148+
pip install poetry
149+
poetry install --no-root
150+
poetry add --editable ../lib/filter_lib
151+
poetry add --editable ../lib/tenants
152+
- name: Generate documentation
153+
working-directory: ./models
154+
run: poetry run python src/cli.py openapi .$SPEC_PATH
155+
env:
156+
PYTHONPATH: .
157+
- name: Save documentation
158+
uses: actions/upload-artifact@v3
159+
with:
160+
path: ${{ env.SPEC_PATH }}
161+
pipelines:
162+
runs-on: ubuntu-latest
163+
strategy:
164+
matrix:
165+
python-version: [ "3.8.15" ]
166+
env:
167+
SPEC_PATH: ./docs/openapi/pipelines.json
168+
steps:
169+
- uses: actions/checkout@v3
170+
- name: Set up Python ${{ matrix.python-version }}
171+
uses: actions/setup-python@v4
172+
with:
173+
python-version: ${{ matrix.python-version }}
174+
cache: 'pip'
175+
- name: Install dependencies
176+
working-directory: ./pipelines
177+
run: |
178+
python -m pip install --upgrade pip
179+
pip install -r requirements.txt
180+
pip install -e ../lib/filter_lib
181+
pip install -e ../lib/tenants
182+
- name: Generate documentation
183+
working-directory: ./pipelines
184+
run: python src/cli.py openapi .$SPEC_PATH
185+
env:
186+
PYTHONPATH: .
187+
- name: Save documentation
188+
uses: actions/upload-artifact@v3
189+
with:
190+
path: ${{ env.SPEC_PATH }}
191+
processing:
192+
runs-on: ubuntu-latest
193+
strategy:
194+
matrix:
195+
python-version: [ "3.8.15" ]
196+
env:
197+
SPEC_PATH: ./docs/openapi/processing.json
198+
steps:
199+
- uses: actions/checkout@v3
200+
- name: Set up Python ${{ matrix.python-version }}
201+
uses: actions/setup-python@v4
202+
with:
203+
python-version: ${{ matrix.python-version }}
204+
cache: 'pip'
205+
- name: Install dependencies
206+
working-directory: ./processing
207+
run: |
208+
python -m pip install --upgrade pip
209+
pip install poetry
210+
poetry install --no-root
211+
poetry add --editable ../lib/tenants
212+
- name: Generate documentation
213+
working-directory: ./processing
214+
run: poetry run python src/cli.py openapi .$SPEC_PATH
215+
env:
216+
PYTHONPATH: .
217+
- name: Save documentation
218+
uses: actions/upload-artifact@v3
219+
with:
220+
path: ${{ env.SPEC_PATH }}
221+
scheduler:
222+
runs-on: ubuntu-latest
223+
strategy:
224+
matrix:
225+
python-version: [ "3.8.15" ]
226+
env:
227+
SPEC_PATH: ./docs/openapi/scheduler.json
228+
steps:
229+
- uses: actions/checkout@v3
230+
- name: Set up Python ${{ matrix.python-version }}
231+
uses: actions/setup-python@v4
232+
with:
233+
python-version: ${{ matrix.python-version }}
234+
cache: 'pip'
235+
- name: Install dependencies
236+
working-directory: ./scheduler
237+
run: |
238+
python -m pip install --upgrade pip
239+
pip install -r requirements.txt
240+
pip install -e ../lib/tenants
241+
- name: Generate documentation
242+
working-directory: ./scheduler
243+
run: python scheduler/cli.py openapi .$SPEC_PATH
244+
env:
245+
PYTHONPATH: .
246+
- name: Save documentation
247+
uses: actions/upload-artifact@v3
248+
with:
249+
path: ${{ env.SPEC_PATH }}
250+
search:
251+
runs-on: ubuntu-latest
252+
strategy:
253+
matrix:
254+
python-version: [ "3.8.15" ]
255+
env:
256+
SPEC_PATH: ./docs/openapi/search.json
257+
steps:
258+
- uses: actions/checkout@v3
259+
- name: Set up Python ${{ matrix.python-version }}
260+
uses: actions/setup-python@v4
261+
with:
262+
python-version: ${{ matrix.python-version }}
263+
cache: 'pip'
264+
- name: Install dependencies
265+
working-directory: ./search
266+
run: |
267+
python -m pip install --upgrade pip
268+
pip install poetry
269+
poetry install --no-root
270+
poetry add --editable ../lib/filter_lib
271+
poetry add --editable ../lib/tenants
272+
- name: Generate documentation
273+
working-directory: ./search
274+
run: poetry run python search/cli.py openapi .$SPEC_PATH
275+
env:
276+
PYTHONPATH: .
277+
- name: Save documentation
278+
uses: actions/upload-artifact@v3
279+
with:
280+
path: ${{ env.SPEC_PATH }}
281+
taxonomy:
282+
runs-on: ubuntu-latest
283+
strategy:
284+
matrix:
285+
python-version: [ "3.8.15" ]
286+
env:
287+
SPEC_PATH: ./docs/openapi/taxonomy.json
288+
steps:
289+
- uses: actions/checkout@v3
290+
- name: Set up Python ${{ matrix.python-version }}
291+
uses: actions/setup-python@v4
292+
with:
293+
python-version: ${{ matrix.python-version }}
294+
cache: 'pip'
295+
- name: Install dependencies
296+
working-directory: ./taxonomy
297+
run: |
298+
python -m pip install --upgrade pip
299+
pip install poetry
300+
poetry install --no-root
301+
poetry add --editable ../lib/filter_lib
302+
poetry add --editable ../lib/tenants
303+
- name: Generate documentation
304+
working-directory: ./taxonomy
305+
run: poetry run python app/cli.py openapi .$SPEC_PATH
306+
env:
307+
PYTHONPATH: .
308+
- name: Save documentation
309+
uses: actions/upload-artifact@v3
310+
with:
311+
path: ${{ env.SPEC_PATH }}
312+
users:
313+
runs-on: ubuntu-latest
314+
strategy:
315+
matrix:
316+
python-version: [ "3.8.15" ]
317+
env:
318+
SPEC_PATH: ./docs/openapi/users.json
319+
steps:
320+
- uses: actions/checkout@v3
321+
- name: Set up Python ${{ matrix.python-version }}
322+
uses: actions/setup-python@v4
323+
with:
324+
python-version: ${{ matrix.python-version }}
325+
cache: 'pip'
326+
- name: Install dependencies
327+
working-directory: ./users
328+
run: |
329+
python -m pip install --upgrade pip
330+
pip install -r requirements.txt
331+
pip install -e ../lib/tenants
332+
- name: Generate documentation
333+
working-directory: ./users
334+
run: python src/cli.py openapi .$SPEC_PATH
335+
env:
336+
PYTHONPATH: .
337+
- name: Save documentation
338+
uses: actions/upload-artifact@v3
339+
with:
340+
path: ${{ env.SPEC_PATH }}
341+
commit-specs:
342+
runs-on: ubuntu-latest
343+
needs: [annotation, assets, convert, jobs, models, pipelines, processing, scheduler, search, taxonomy, users]
344+
env:
345+
DOCS_PATH: ./docs/openapi
346+
steps:
347+
- uses: actions/checkout@v3
348+
- name: Download generated specs
349+
id: download
350+
uses: actions/download-artifact@v3
351+
with:
352+
path: /tmp
353+
- name: Extract downloaded specs
354+
run: mv ${{ steps.download.outputs.download-path }}/artifact/*.json ${{ env.DOCS_PATH }}
355+
- name: Push documentation
356+
working-directory: ${{ env.DOCS_PATH }}
357+
run: |
358+
git add .
359+
if git diff --quiet HEAD ./; then
360+
echo No changes in documentation, exiting
361+
exit 0
362+
fi
363+
echo '# TODO: Do nothing right now, replace with push to S3 later'
364+
# git -c user.name='github-actions[bot]' -c user.email='github-actions[bot]@users.noreply.github.com' \
365+
# commit --message "docs: update openapi specs"
366+
# git push origin HEAD

annotation/alembic/versions/66cd6054c2d0_add_categories_tree.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import sqlalchemy_utils
1010

1111
from alembic import op
12+
from app import database
1213

1314
# revision identifiers, used by Alembic.
1415
revision = "66cd6054c2d0"
@@ -19,6 +20,7 @@
1920

2021
def upgrade():
2122
# ### commands auto generated by Alembic - please adjust! ###
23+
database.install_ltree_extension()
2224
op.add_column(
2325
"categories",
2426
sa.Column(

0 commit comments

Comments
 (0)