Skip to content

Commit 824c232

Browse files
build: update build scripts and CI
1 parent d02feef commit 824c232

File tree

21 files changed

+2937
-320
lines changed

21 files changed

+2937
-320
lines changed

.github/workflows/ci.yml

Lines changed: 107 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,10 @@ jobs:
1919
permissions:
2020
contents: read
2121

22-
defaults:
23-
run:
24-
working-directory: ./backend
25-
2622
steps:
2723
- name: Checkout code
2824
uses: actions/checkout@v6
25+
- uses: extractions/setup-just@v3
2926
- name: Init rustup toolchain
3027
run: rustup show
3128
- name: setup rust build cache
@@ -41,20 +38,78 @@ jobs:
4138
# Default: empty
4239
key: ci_test_
4340
- name: Rustfmt
44-
run: ./lint.sh rustfmt
41+
run: just lint-backend-rustfmt
4542
- name: Clippy
46-
run: ./lint.sh clippy
43+
run: just lint-backend-clippy
4744
- name: SQLFluff
48-
run: ./lint.sh sqlfluff
45+
run: just lint-backend-sqlfluff
4946
- name: Start PostgreSQL
5047
run: |
5148
service postgresql start
5249
psql postgres://geoengine:geoengine@localhost -c "CREATE DATABASE biois;"
5350
- name: Diesel Check
54-
run: ./lint.sh diesel_cli --with-install
51+
run: |
52+
just install-diesel-cli
53+
just lint-backend-diesel-cli
5554
env:
5655
DATABASE_URL: postgres://geoengine:geoengine@localhost/biois
5756

57+
lint-api-client:
58+
name: Lint API Client
59+
60+
runs-on: ubuntu-24.04
61+
container: quay.io/geoengine/devcontainer:latest
62+
63+
permissions:
64+
contents: read
65+
66+
steps:
67+
- name: Checkout code
68+
uses: actions/checkout@v6
69+
- uses: extractions/setup-just@v3
70+
- name: Idempotency of OpenAPI doc generation
71+
run: |
72+
just generate-openapi-spec
73+
if [ -n "$(git status --porcelain)" ]; then
74+
echo "Error: Uncommitted changes found after OpenAPI spec generation."
75+
echo "The following files have uncommitted changes:"
76+
git status --porcelain
77+
exit 1
78+
fi
79+
- name: Idempotency of API client code generation
80+
run: |
81+
just build-api-client
82+
if [ -n "$(git status --porcelain)" ]; then
83+
echo "Error: Uncommitted changes found after code generation."
84+
echo "The following files have uncommitted changes:"
85+
git status --porcelain
86+
exit 1
87+
fi
88+
- name: Check API client for build errors
89+
run: just lint-api-client
90+
91+
lint-frontend:
92+
name: Lint Frontend
93+
94+
runs-on: ubuntu-24.04
95+
container: quay.io/geoengine/devcontainer:latest
96+
97+
permissions:
98+
contents: read
99+
100+
steps:
101+
- name: Checkout code
102+
uses: actions/checkout@v6
103+
- uses: extractions/setup-just@v3
104+
- name: Install dependencies
105+
run: |
106+
just install-api-client-deps
107+
just install-frontend-deps
108+
- name: Code Format
109+
run: just lint-frontend-fmt
110+
- name: Lints
111+
run: just lint-frontend-code
112+
58113
test-backend:
59114
name: Test Backend
60115

@@ -67,13 +122,10 @@ jobs:
67122
outputs:
68123
coverage-artifact-id: ${{ steps.upload-artifact.outputs.artifact-id }}
69124

70-
defaults:
71-
run:
72-
working-directory: ./backend
73-
74125
steps:
75126
- name: Checkout code
76127
uses: actions/checkout@v6
128+
- uses: extractions/setup-just@v3
77129
- name: Init rustup toolchain
78130
run: rustup show
79131

@@ -95,13 +147,8 @@ jobs:
95147
key: ci_test_
96148
- name: Test
97149
run: |
98-
cargo install --locked cargo-llvm-cov
99-
100-
cargo llvm-cov \
101-
--locked \
102-
--all-features \
103-
--lcov \
104-
--output-path /lcov.info
150+
just install-llvm-cov
151+
just test-backend-with-coverage "/lcov.info"
105152
- id: upload-artifact
106153
uses: actions/upload-artifact@v6
107154
with:
@@ -110,6 +157,41 @@ jobs:
110157
compression-level: 9
111158
retention-days: 1
112159
if-no-files-found: error
160+
161+
test-frontend:
162+
name: Test Frontend
163+
164+
runs-on: ubuntu-24.04
165+
container: quay.io/geoengine/devcontainer:latest
166+
167+
permissions:
168+
contents: read
169+
170+
outputs:
171+
coverage-artifact-id: ${{ steps.upload-artifact.outputs.artifact-id }}
172+
173+
steps:
174+
- name: Checkout code
175+
uses: actions/checkout@v6
176+
- uses: extractions/setup-just@v3
177+
- name: Install dependencies
178+
run: |
179+
just install-api-client-deps
180+
just install-frontend-deps
181+
- name: Build
182+
run: just build-frontend
183+
184+
- name: Test
185+
run: just test-frontend
186+
187+
- id: upload-artifact
188+
uses: actions/upload-artifact@v6
189+
with:
190+
name: lcov-report-frontend-${{ github.run_id }}-${{ github.run_attempt }}
191+
path: frontend/coverage/BioIS/lcov.info
192+
compression-level: 9
193+
retention-days: 1
194+
if-no-files-found: error
113195

114196
upload-coverage:
115197
name: Upload Coverage Report
@@ -121,7 +203,7 @@ jobs:
121203

122204
needs:
123205
- test-backend
124-
206+
- test-frontend
125207
steps:
126208
- name: Checkout code
127209
uses: actions/checkout@v6
@@ -133,6 +215,11 @@ jobs:
133215
- name: Modify lcov paths
134216
run: |
135217
sed -i 's|SF:/__w/BioIS/BioIS/|SF:|' backend/lcov.info
218+
- name: Download Frontend Coverage Report
219+
uses: actions/download-artifact@v7
220+
with:
221+
artifact-ids: ${{ needs.test-frontend.outputs.coverage-artifact-id }}
222+
path: frontend/
136223
- name: Upload coverage to Coveralls
137224
uses: coverallsapp/github-action@v2
138225
with:
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: "Lint PR"
2+
on:
3+
pull_request:
4+
types:
5+
- opened
6+
- edited
7+
8+
jobs:
9+
title:
10+
name: Title
11+
if: github.event.action == 'opened' || github.event.changes.title.from
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: geo-engine/conventional-pr-title@v1
15+
with:
16+
types: |-
17+
build
18+
ci
19+
docs
20+
feat
21+
fix
22+
perf
23+
refactor
24+
test
25+
scopes: |-
26+
api-client
27+
backend
28+
frontend

api-client/openapi.json

Whitespace-only changes.

api-client/post-process.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/usr/bin/env python3
2+
3+
"""
4+
Post-processing of generated code.
5+
"""
6+
7+
from collections.abc import Generator, Callable
8+
from pathlib import Path
9+
from textwrap import dedent
10+
from typing import TypeAlias
11+
import logging
12+
13+
14+
FileModifier: TypeAlias = Callable[[list[str]], Generator[str, None, None]]
15+
INDENT = " "
16+
17+
18+
def file_modifications() -> Generator[tuple[Path, FileModifier], None, None]:
19+
yield Path("types/ObjectParamAPI.ts"), object_param_api_ts
20+
yield Path("types/PromiseAPI.ts"), promise_api_ts
21+
22+
23+
def main():
24+
logging.basicConfig(level=logging.INFO, format="[%(levelname)s] %(message)s")
25+
26+
subdir = Path("typescript")
27+
for file_path, modify_fn in file_modifications():
28+
logging.info(f"Modifying {file_path}…")
29+
30+
file_path = subdir / file_path
31+
32+
try:
33+
with open(file_path, "r", encoding="utf-8") as f:
34+
file_contents = f.readlines()
35+
36+
with open(file_path, "w", encoding="utf-8") as f:
37+
for line in modify_fn(file_contents):
38+
f.write(line)
39+
except Exception as e:
40+
logging.error(f"Error modifying {file_path}: {e}")
41+
42+
43+
def object_param_api_ts(file_contents: list[str]) -> Generator[str, None, None]:
44+
"""Modify the ObjectParamAPI.ts file."""
45+
for line in file_contents:
46+
if dedent(line).startswith("public api("):
47+
line = line.replace("public api(", "public api_(")
48+
yield line
49+
50+
51+
def promise_api_ts(file_contents: list[str]) -> Generator[str, None, None]:
52+
"""Modify the PromiseAPI.ts file."""
53+
for line in file_contents:
54+
if dedent(line).startswith("public api("):
55+
line = line.replace("public api(", "public api_(")
56+
yield line
57+
58+
59+
if __name__ == "__main__":
60+
main()

api-client/typescript/types/ObjectParamAPI.ts

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api-client/typescript/types/PromiseAPI.ts

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/justfile

Lines changed: 0 additions & 44 deletions
This file was deleted.

backend/lint.sh

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)