Skip to content

Commit c1dc704

Browse files
Merge pull request #380 from hydroserver2/monorepo
Monorepo
2 parents d792775 + 5297a08 commit c1dc704

846 files changed

Lines changed: 148885 additions & 26 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 333 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,333 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
pull_request:
8+
release:
9+
types: [created]
10+
11+
permissions:
12+
contents: read
13+
14+
concurrency:
15+
group: ci-${{ github.workflow }}-${{ github.ref }}
16+
cancel-in-progress: ${{ github.event_name != 'release' }}
17+
18+
jobs:
19+
docs:
20+
name: Docs Build
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
27+
- name: Set up Node.js
28+
uses: actions/setup-node@v4
29+
with:
30+
node-version: 20
31+
cache: npm
32+
cache-dependency-path: apps/docs/package-lock.json
33+
34+
- name: Install docs dependencies
35+
working-directory: apps/docs
36+
run: npm ci
37+
38+
- name: Build docs
39+
working-directory: apps/docs
40+
run: npm run docs:build
41+
42+
hydroserver-ts:
43+
name: TypeScript Client
44+
runs-on: ubuntu-latest
45+
46+
steps:
47+
- name: Checkout repository
48+
uses: actions/checkout@v4
49+
50+
- name: Set up Node.js
51+
uses: actions/setup-node@v4
52+
with:
53+
node-version: 22
54+
cache: npm
55+
cache-dependency-path: packages/hydroserver-ts/package-lock.json
56+
57+
- name: Set up Python
58+
uses: actions/setup-python@v5
59+
with:
60+
python-version: "3.11"
61+
cache: pip
62+
63+
- name: Install API dependencies
64+
run: |
65+
python -m pip install --upgrade pip
66+
pip install -r django/requirements.txt
67+
pip install -e packages/hydroserverpy
68+
69+
- name: Install client dependencies
70+
working-directory: packages/hydroserver-ts
71+
run: npm ci
72+
73+
- name: Verify TypeScript client contract artifacts
74+
working-directory: packages/hydroserver-ts
75+
run: npm run check:contract
76+
77+
- name: Run TypeScript client tests
78+
working-directory: packages/hydroserver-ts
79+
run: npm run coverage
80+
81+
- name: Build TypeScript client
82+
working-directory: packages/hydroserver-ts
83+
run: npm run build
84+
85+
data-management:
86+
name: Data Management App
87+
runs-on: ubuntu-latest
88+
89+
steps:
90+
- name: Checkout repository
91+
uses: actions/checkout@v4
92+
93+
- name: Set up Node.js
94+
uses: actions/setup-node@v4
95+
with:
96+
node-version: 22
97+
cache: npm
98+
cache-dependency-path: |
99+
apps/data-management/package-lock.json
100+
packages/hydroserver-ts/package-lock.json
101+
102+
- name: Install TypeScript client dependencies
103+
working-directory: packages/hydroserver-ts
104+
run: npm ci
105+
106+
- name: Install app dependencies
107+
working-directory: apps/data-management
108+
run: npm ci
109+
110+
- name: Configure app environment
111+
working-directory: apps/data-management
112+
run: |
113+
{
114+
echo "VITE_APP_VERSION=ci"
115+
echo "VITE_APP_GOOGLE_MAPS_API_KEY="
116+
echo "VITE_APP_GOOGLE_MAPS_MAP_ID="
117+
echo "VITE_APP_PROXY_BASE_URL=http://127.0.0.1:8000"
118+
echo "VITE_HYDROSERVER_CLIENT_LOCAL=1"
119+
echo "VITE_HYDROSERVER_CLIENT_PATH=../../packages/hydroserver-ts/src"
120+
} > .env
121+
122+
- name: Run app tests
123+
working-directory: apps/data-management
124+
run: npm run coverage
125+
126+
- name: Build app
127+
working-directory: apps/data-management
128+
run: npm run build
129+
130+
hydroserverpy:
131+
name: Python Client
132+
runs-on: ubuntu-latest
133+
134+
strategy:
135+
fail-fast: false
136+
matrix:
137+
python-version:
138+
- "3.11"
139+
- "3.12"
140+
- "3.13"
141+
142+
steps:
143+
- name: Checkout repository
144+
uses: actions/checkout@v4
145+
146+
- name: Set up Python
147+
uses: actions/setup-python@v5
148+
with:
149+
python-version: ${{ matrix.python-version }}
150+
cache: pip
151+
152+
- name: Install Python client dependencies
153+
working-directory: packages/hydroserverpy
154+
run: |
155+
python -m pip install --upgrade pip
156+
pip install -e .
157+
pip install pytest
158+
159+
- name: Run Python client tests
160+
working-directory: packages/hydroserverpy
161+
run: python -m pytest --import-mode=append tests/
162+
163+
api:
164+
name: API Service
165+
runs-on: ubuntu-latest
166+
167+
services:
168+
postgres:
169+
image: postgres:17
170+
env:
171+
POSTGRES_DB: hydroserver
172+
POSTGRES_USER: hsdbadmin
173+
POSTGRES_PASSWORD: admin
174+
options: >-
175+
--health-cmd "pg_isready -U hsdbadmin -d hydroserver"
176+
--health-interval 10s
177+
--health-timeout 5s
178+
--health-retries 5
179+
ports:
180+
- 5432:5432
181+
182+
redis:
183+
image: redis:7
184+
options: >-
185+
--health-cmd "redis-cli ping"
186+
--health-interval 10s
187+
--health-timeout 5s
188+
--health-retries 5
189+
ports:
190+
- 6379:6379
191+
192+
mailhog:
193+
image: mailhog/mailhog:latest
194+
ports:
195+
- 1025:1025
196+
197+
steps:
198+
- name: Checkout repository
199+
uses: actions/checkout@v4
200+
201+
- name: Set up Python
202+
uses: actions/setup-python@v5
203+
with:
204+
python-version: "3.11"
205+
cache: pip
206+
207+
- name: Install API dependencies
208+
run: |
209+
python -m pip install --upgrade pip
210+
pip install -r django/requirements.txt
211+
pip install -e packages/hydroserverpy
212+
pip install pytest pytest-django pytest-cov
213+
214+
- name: Run API test suite
215+
working-directory: django
216+
env:
217+
DATABASE_URL: postgresql://hsdbadmin:admin@127.0.0.1:5432/hydroserver
218+
CELERY_BROKER_URL: redis://127.0.0.1:6379/0
219+
SMTP_URL: smtp://127.0.0.1:1025
220+
run: python -m pytest
221+
222+
e2e:
223+
name: End-to-End Tests
224+
runs-on: ubuntu-latest
225+
env:
226+
E2E_DATABASE_URL: postgresql://hsdbadmin:admin@127.0.0.1:5432/hydroserver_e2e_${{ github.run_id }}_${{ github.run_attempt }}
227+
E2E_ADMIN_DATABASE_URL: postgresql://hsdbadmin:admin@127.0.0.1:5432/postgres
228+
229+
services:
230+
postgres:
231+
image: postgres:17
232+
env:
233+
POSTGRES_DB: hydroserver
234+
POSTGRES_USER: hsdbadmin
235+
POSTGRES_PASSWORD: admin
236+
options: >-
237+
--health-cmd "pg_isready -U hsdbadmin -d hydroserver"
238+
--health-interval 10s
239+
--health-timeout 5s
240+
--health-retries 5
241+
ports:
242+
- 5432:5432
243+
244+
redis:
245+
image: redis:7
246+
options: >-
247+
--health-cmd "redis-cli ping"
248+
--health-interval 10s
249+
--health-timeout 5s
250+
--health-retries 5
251+
ports:
252+
- 6379:6379
253+
254+
steps:
255+
- name: Checkout repository
256+
uses: actions/checkout@v4
257+
258+
- name: Set up Python
259+
uses: actions/setup-python@v5
260+
with:
261+
python-version: "3.11"
262+
cache: pip
263+
264+
- name: Set up Node.js
265+
uses: actions/setup-node@v4
266+
with:
267+
node-version: 22
268+
cache: npm
269+
cache-dependency-path: |
270+
apps/data-management/package-lock.json
271+
packages/hydroserver-ts/package-lock.json
272+
tests/e2e/package-lock.json
273+
274+
- name: Install API dependencies
275+
run: |
276+
python -m pip install --upgrade pip
277+
pip install -r django/requirements.txt
278+
pip install -e packages/hydroserverpy
279+
280+
- name: Install TypeScript client dependencies
281+
working-directory: packages/hydroserver-ts
282+
run: npm ci
283+
284+
- name: Install app dependencies
285+
working-directory: apps/data-management
286+
run: npm ci
287+
288+
- name: Install E2E dependencies
289+
working-directory: tests/e2e
290+
run: npm ci
291+
292+
- name: Install Playwright browser
293+
working-directory: tests/e2e
294+
run: npx playwright install --with-deps chromium
295+
296+
- name: Run Playwright E2E suite
297+
env:
298+
E2E_PYTHON: python
299+
run: ./scripts/e2e test
300+
301+
- name: Upload Playwright report
302+
if: always()
303+
uses: actions/upload-artifact@v4
304+
with:
305+
name: playwright-report
306+
path: |
307+
tests/e2e/playwright-report
308+
tests/e2e/test-results
309+
if-no-files-found: ignore
310+
311+
trigger-release:
312+
name: Trigger Release Workflow
313+
runs-on: ubuntu-latest
314+
if: github.event_name == 'release'
315+
needs: [docs, hydroserver-ts, data-management, hydroserverpy, api, e2e]
316+
permissions:
317+
actions: write
318+
319+
steps:
320+
- name: Trigger release workflow
321+
uses: actions/github-script@v7
322+
with:
323+
script: |
324+
await github.rest.actions.createWorkflowDispatch({
325+
owner: context.repo.owner,
326+
repo: context.repo.repo,
327+
workflow_id: 'release.yml',
328+
ref: context.payload.release.target_commitish,
329+
inputs: {
330+
tag: context.payload.release.tag_name,
331+
prerelease: String(context.payload.release.prerelease),
332+
},
333+
});

.github/workflows/deploy.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ on:
44
# Runs on pushes targeting the default branch
55
push:
66
branches: ["main"]
7+
paths:
8+
- "apps/docs/**"
79

810
# Allows you to run this workflow manually from the Actions tab
911
workflow_dispatch:
@@ -33,19 +35,22 @@ jobs:
3335
- name: Setup Node.js
3436
uses: actions/setup-node@v3
3537
with:
36-
node-version: 16
38+
node-version: 20
3739
cache: npm
40+
cache-dependency-path: apps/docs/package-lock.json
3841
- name: Install dependencies
42+
working-directory: apps/docs
3943
run: npm install --also=dev
4044
- name: Build
45+
working-directory: apps/docs
4146
run: npm run docs:build
4247
- name: Setup Pages
4348
uses: actions/configure-pages@v3
4449
- name: Upload artifact
4550
uses: actions/upload-pages-artifact@v3
4651
with:
4752
# Upload the dist folder
48-
path: docs/.vitepress/dist
53+
path: apps/docs/docs/.vitepress/dist
4954
- name: Deploy to GitHub Pages
5055
id: deployment
5156
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
node_modules
2-
docs/.vitepress/cache/
3-
docs/.vitepress/dist/
2+
**/node_modules/
3+
**/.vitepress/cache/
4+
**/.vitepress/dist/
5+
**/.vitepress/.temp/
6+
**/__pycache__/
7+
**/*.pyc
48

59
.idea*
610
.DS_Store
711
.terraform*
812
terraform.tfstate*
9-
.env
13+
.env
14+
.venv
15+
playwright-report/
16+
test-results/
17+
tests/e2e/.auth/
18+
.playwright-mcp/

0 commit comments

Comments
 (0)