Skip to content

Commit 20fae4a

Browse files
build: update build scripts and CI
1 parent d02feef commit 20fae4a

File tree

24 files changed

+3013
-334
lines changed

24 files changed

+3013
-334
lines changed

.github/workflows/ci.yml

Lines changed: 110 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,81 @@ 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: Start PostgreSQL
71+
run: |
72+
service postgresql start
73+
psql postgres://geoengine:geoengine@localhost -c "CREATE DATABASE biois;"
74+
- name: Install Java (OpenAPI Generator requires Java to run)
75+
run: |
76+
# deleted in devcontainer image, but required by java installer
77+
mkdir -p /usr/share/man/man1
78+
apt-get update
79+
apt-get install -y openjdk-21-jre-headless
80+
- name: Lint OpenAPI specification
81+
run: |
82+
just lint-openapi-spec
83+
- name: Idempotency of OpenAPI doc generation
84+
run: |
85+
just generate-openapi-spec
86+
just check-no-changes-in-git-repo
87+
- name: Idempotency of API client code generation
88+
run: |
89+
just build-api-client
90+
just check-no-changes-in-git-repo
91+
- name: Check API client for build errors
92+
run: just lint-api-client
93+
94+
lint-frontend:
95+
name: Lint Frontend
96+
97+
runs-on: ubuntu-24.04
98+
container: quay.io/geoengine/devcontainer:latest
99+
100+
permissions:
101+
contents: read
102+
103+
steps:
104+
- name: Checkout code
105+
uses: actions/checkout@v6
106+
- uses: extractions/setup-just@v3
107+
- name: Install dependencies
108+
run: |
109+
just install-api-client-deps
110+
just install-frontend-deps
111+
- name: Code Format
112+
run: just lint-frontend-fmt
113+
- name: Lints
114+
run: just lint-frontend-code
115+
58116
test-backend:
59117
name: Test Backend
60118

@@ -67,13 +125,10 @@ jobs:
67125
outputs:
68126
coverage-artifact-id: ${{ steps.upload-artifact.outputs.artifact-id }}
69127

70-
defaults:
71-
run:
72-
working-directory: ./backend
73-
74128
steps:
75129
- name: Checkout code
76130
uses: actions/checkout@v6
131+
- uses: extractions/setup-just@v3
77132
- name: Init rustup toolchain
78133
run: rustup show
79134

@@ -95,13 +150,8 @@ jobs:
95150
key: ci_test_
96151
- name: Test
97152
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
153+
just install-llvm-cov
154+
just test-backend-with-coverage "/lcov.info"
105155
- id: upload-artifact
106156
uses: actions/upload-artifact@v6
107157
with:
@@ -110,6 +160,41 @@ jobs:
110160
compression-level: 9
111161
retention-days: 1
112162
if-no-files-found: error
163+
164+
test-frontend:
165+
name: Test Frontend
166+
167+
runs-on: ubuntu-24.04
168+
container: quay.io/geoengine/devcontainer:latest
169+
170+
permissions:
171+
contents: read
172+
173+
outputs:
174+
coverage-artifact-id: ${{ steps.upload-artifact.outputs.artifact-id }}
175+
176+
steps:
177+
- name: Checkout code
178+
uses: actions/checkout@v6
179+
- uses: extractions/setup-just@v3
180+
- name: Install dependencies
181+
run: |
182+
just install-api-client-deps
183+
just install-frontend-deps
184+
- name: Build
185+
run: just build-frontend
186+
187+
- name: Test
188+
run: just test-frontend
189+
190+
- id: upload-artifact
191+
uses: actions/upload-artifact@v6
192+
with:
193+
name: lcov-report-frontend-${{ github.run_id }}-${{ github.run_attempt }}
194+
path: frontend/coverage/BioIS/lcov.info
195+
compression-level: 9
196+
retention-days: 1
197+
if-no-files-found: error
113198

114199
upload-coverage:
115200
name: Upload Coverage Report
@@ -121,7 +206,7 @@ jobs:
121206

122207
needs:
123208
- test-backend
124-
209+
- test-frontend
125210
steps:
126211
- name: Checkout code
127212
uses: actions/checkout@v6
@@ -133,6 +218,11 @@ jobs:
133218
- name: Modify lcov paths
134219
run: |
135220
sed -i 's|SF:/__w/BioIS/BioIS/|SF:|' backend/lcov.info
221+
- name: Download Frontend Coverage Report
222+
uses: actions/download-artifact@v7
223+
with:
224+
artifact-ids: ${{ needs.test-frontend.outputs.coverage-artifact-id }}
225+
path: frontend/
136226
- name: Upload coverage to Coveralls
137227
uses: coverallsapp/github-action@v2
138228
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/config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
inputSpec: /local/openapi.json
2-
outputDir: /local/typescript
1+
inputSpec: ../openapi.json
2+
outputDir: typescript
33
generatorName: typescript
44
gitHost: github.com
55
gitUserId: geo-engine

api-client/openapi.json

Whitespace-only changes.

api-client/openapitools.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"$schema": "./node_modules/@openapitools/openapi-generator-cli/config.schema.json",
3+
"spaces": 2,
4+
"generator-cli": {
5+
"version": "7.19.0"
6+
}
7+
}

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/.openapi-generator/VERSION

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/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.

0 commit comments

Comments
 (0)