Skip to content

Commit f247c80

Browse files
Merge pull request #215 from geo-engine/reusable-workflow
reusable-workflow
2 parents 2848c68 + 6c9038e commit f247c80

File tree

6 files changed

+179
-196
lines changed

6 files changed

+179
-196
lines changed

.github/.backend_git_ref

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
main
1+
c4af2b856f9205ce9848d5b9695cf4710c25e83f

.github/workflows/ci.yml

Lines changed: 14 additions & 193 deletions
Original file line numberDiff line numberDiff line change
@@ -3,213 +3,34 @@ name: CI
33
on:
44
pull_request:
55
merge_group:
6+
# Creates a coverage of the main branch
7+
push:
8+
branches:
9+
- main
610
# Allows you to run this workflow manually from the Actions tab
711
workflow_dispatch:
812

913
jobs:
1014
check:
11-
runs-on: ubuntu-22.04
12-
13-
services:
14-
postgres:
15-
image: postgis/postgis
16-
env:
17-
POSTGRES_USER: geoengine
18-
POSTGRES_PASSWORD: geoengine
19-
POSTGRES_DB: geoengine
20-
ports:
21-
- 5432:5432
22-
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
15+
uses: geo-engine/geoengine-python/.github/workflows/test-python.yml@reusable-workflow
2316

2417
strategy:
2518
fail-fast: false
2619
matrix:
2720
# use all supported versions from https://devguide.python.org/versions/
2821
python-version: ["3.9", "3.10", "3.11", "3.12"]
2922

30-
defaults:
31-
run:
32-
working-directory: library
33-
34-
steps:
35-
- name: Checkout library code
36-
uses: actions/checkout@v4
37-
with:
38-
path: library
39-
- name: Read backend version
40-
id: read-backend-version
41-
run: echo "GEOENGINE_VERSION=$(cat .github/.backend_git_ref)" >> $GITHUB_OUTPUT
42-
- name: Checkout Geo Engine code
43-
uses: actions/checkout@v4
44-
with:
45-
repository: geo-engine/geoengine
46-
ref: ${{ steps.read-backend-version.outputs.GEOENGINE_VERSION }}
47-
path: backend
48-
- name: Free Disk Space (Ubuntu)
49-
uses: jlumbroso/free-disk-space@main
50-
with:
51-
tool-cache: true
52-
android: true
53-
dotnet: true
54-
haskell: true
55-
large-packages: true
56-
docker-images: true
57-
swap-storage: true
58-
- name: Install lld & GDAL & Protobuf
59-
run: |
60-
sudo apt-get update
61-
sudo apt-get install lld libgdal-dev gdal-bin build-essential clang curl protobuf-compiler libgeos-dev libproj-dev
62-
sudo apt-get clean
63-
export C_INCLUDE_PATH=/usr/include/gdal:$C_INCLUDE_PATH
64-
export CPLUS_INCLUDE_PATH=/usr/include/gdal:$CPLUS_INCLUDE_PATH
65-
sudo ldconfig
66-
- name: Install Rustup
67-
run: |
68-
curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused -fsSL "https://sh.rustup.rs" | sh -s -- --profile minimal --default-toolchain none -y
69-
echo "${CARGO_HOME:-$HOME/.cargo}/bin" >> $GITHUB_PATH
70-
- name: Set up Python ${{ matrix.python-version }}
71-
uses: actions/setup-python@v4
72-
with:
73-
python-version: ${{ matrix.python-version }}
74-
- name: Install build dependencies
75-
run: |
76-
python -m pip install --upgrade pip
77-
pip install -e .
78-
pip install -e .[dev]
79-
- name: Check Formatting
80-
run: |
81-
python -m pycodestyle
82-
- name: Lint code
83-
run: |
84-
python -m pylint geoengine
85-
- name: Type-check code
86-
run: |
87-
python -m mypy geoengine
88-
- name: Build
89-
run: python -m build .
90-
- name: Install test dependencies
91-
run: |
92-
pip install -e .[test]
93-
- name: Lint tests
94-
run: |
95-
python -m pylint tests
96-
- name: Type-check tests
97-
run: |
98-
python -m mypy tests
99-
- name: Test
100-
run: pytest
101-
env:
102-
GEOENGINE_TEST_CODE_PATH: ${{ github.workspace }}/backend
103-
GEOENGINE_TEST_BUILD_TYPE: "release"
104-
- name: Examples
105-
run: |
106-
python -m pip install -e .[examples]
107-
python test_all_notebooks.py
108-
env:
109-
GEOENGINE_TEST_CODE_PATH: ${{ github.workspace }}/backend
110-
GEOENGINE_TEST_BUILD_TYPE: "release"
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
use-uv: false
26+
coverage: false
11127

11228
# Checks the library using minimum version resolution
11329
# `uv` has this feature built-in, c.f. https://github.com/astral-sh/uv
11430
check-min-version:
115-
runs-on: ubuntu-22.04
116-
117-
services:
118-
postgres:
119-
image: postgis/postgis
120-
env:
121-
POSTGRES_USER: geoengine
122-
POSTGRES_PASSWORD: geoengine
123-
POSTGRES_DB: geoengine
124-
ports:
125-
- 5432:5432
126-
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
127-
128-
defaults:
129-
run:
130-
working-directory: library
131-
132-
env:
133-
# use minimum supported versions from https://devguide.python.org/versions/
134-
python-version: "3.9"
135-
# lowest compatible versions for all direct dependencies
136-
# cf., https://github.com/astral-sh/uv#resolution-strategy
137-
resolution: "lowest-direct"
138-
139-
steps:
140-
- name: Checkout library code
141-
uses: actions/checkout@v4
142-
with:
143-
path: library
144-
- name: Read backend version
145-
id: read-backend-version
146-
run: echo "GEOENGINE_VERSION=$(cat .github/.backend_git_ref)" >> $GITHUB_OUTPUT
147-
- name: Checkout Geo Engine code
148-
uses: actions/checkout@v4
149-
with:
150-
repository: geo-engine/geoengine
151-
ref: ${{ steps.read-backend-version.outputs.GEOENGINE_VERSION }}
152-
path: backend
153-
- name: Free Disk Space (Ubuntu)
154-
uses: jlumbroso/free-disk-space@main
155-
with:
156-
tool-cache: true
157-
android: true
158-
dotnet: true
159-
haskell: true
160-
large-packages: true
161-
docker-images: true
162-
swap-storage: true
163-
- name: Install lld & GDAL & Protobuf
164-
run: |
165-
sudo apt-get update
166-
sudo apt-get install lld libgdal-dev gdal-bin build-essential clang curl protobuf-compiler libgeos-dev libproj-dev
167-
sudo apt-get clean
168-
export C_INCLUDE_PATH=/usr/include/gdal:$C_INCLUDE_PATH
169-
export CPLUS_INCLUDE_PATH=/usr/include/gdal:$CPLUS_INCLUDE_PATH
170-
sudo ldconfig
171-
- name: Install Rustup
172-
run: |
173-
curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused -fsSL "https://sh.rustup.rs" | sh -s -- --profile minimal --default-toolchain none -y
174-
echo "${CARGO_HOME:-$HOME/.cargo}/bin" >> $GITHUB_PATH
175-
- name: Set up Python ${{ env.python-version }}
176-
uses: actions/setup-python@v4
177-
with:
178-
python-version: ${{ env.python-version }}
179-
- name: Install build dependencies
180-
run: |
181-
python -m pip install --upgrade pip
182-
pip install uv
183-
184-
uv venv
185-
source .venv/bin/activate
31+
uses: geo-engine/geoengine-python/.github/workflows/test-python.yml@reusable-workflow
18632

187-
uv pip install --resolution=${{ env.resolution }} -e .
188-
uv pip install --resolution=${{ env.resolution }} -e .[dev]
189-
- name: Build
190-
run: |
191-
source .venv/bin/activate
192-
python -m build .
193-
- name: Install test dependencies
194-
run: |
195-
source .venv/bin/activate
196-
uv pip install --resolution=${{ env.resolution }} -e .[test]
197-
- name: Test
198-
run: |
199-
source .venv/bin/activate
200-
pytest --cov=geoengine --cov-report=lcov
201-
env:
202-
GEOENGINE_TEST_CODE_PATH: ${{ github.workspace }}/backend
203-
GEOENGINE_TEST_BUILD_TYPE: "release"
204-
- name: Upload coverage to Coveralls
205-
uses: coverallsapp/github-action@v2
206-
with:
207-
base-path: library
208-
- name: Examples
209-
run: |
210-
source .venv/bin/activate
211-
uv pip install --resolution=${{ env.resolution }} -e .[examples]
212-
python test_all_notebooks.py
213-
env:
214-
GEOENGINE_TEST_CODE_PATH: ${{ github.workspace }}/backend
215-
GEOENGINE_TEST_BUILD_TYPE: "release"
33+
with:
34+
python-version: 3.9
35+
use-uv: true
36+
coverage: true

.github/workflows/test-python.yml

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
name: Test Python Library
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
python-version:
7+
type: string
8+
required: true
9+
description: 'Python version to use, e.g., "3.9"'
10+
use-uv:
11+
type: boolean
12+
default: false
13+
description: 'Use `uv` for minimum version resolution'
14+
coverage:
15+
type: boolean
16+
default: false
17+
description: 'Generate coverage report'
18+
19+
jobs:
20+
check:
21+
runs-on: ubuntu-22.04
22+
23+
services:
24+
postgres:
25+
image: postgis/postgis
26+
env:
27+
POSTGRES_USER: geoengine
28+
POSTGRES_PASSWORD: geoengine
29+
POSTGRES_DB: geoengine
30+
ports:
31+
- 5432:5432
32+
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
33+
34+
defaults:
35+
run:
36+
working-directory: library
37+
38+
steps:
39+
- name: Checkout library code
40+
uses: actions/checkout@v4
41+
with:
42+
path: library
43+
- name: Setup variables
44+
id: vars
45+
run: |
46+
echo "GEOENGINE_VERSION=$(cat .github/.backend_git_ref)" >> $GITHUB_OUTPUT
47+
if ${{ inputs.use-uv }}; then
48+
echo "PIP_INSTALL=uv pip install --resolution=lowest-direct" >> $GITHUB_OUTPUT
49+
echo "VENV_CALL=source .venv/bin/activate" >> $GITHUB_OUTPUT
50+
else
51+
echo "PIP_INSTALL=pip install" >> $GITHUB_OUTPUT
52+
echo "VENV_CALL=" >> $GITHUB_OUTPUT
53+
fi
54+
if ${{ inputs.coverage }}; then
55+
echo "COVERAGE_COMMAND=--cov=geoengine --cov-report=lcov" >> $GITHUB_OUTPUT
56+
else
57+
echo "COVERAGE_COMMAND=" >> $GITHUB_OUTPUT
58+
fi
59+
- name: Checkout Geo Engine code
60+
uses: actions/checkout@v4
61+
with:
62+
repository: geo-engine/geoengine
63+
ref: ${{ steps.vars.outputs.GEOENGINE_VERSION }}
64+
path: backend
65+
- name: Free Disk Space (Ubuntu)
66+
uses: jlumbroso/free-disk-space@main
67+
with:
68+
tool-cache: true
69+
android: true
70+
dotnet: true
71+
haskell: true
72+
large-packages: true
73+
docker-images: true
74+
swap-storage: true
75+
- name: Install lld & GDAL & Protobuf
76+
run: |
77+
sudo apt-get update
78+
sudo apt-get install lld libgdal-dev gdal-bin build-essential clang curl protobuf-compiler libgeos-dev libproj-dev
79+
sudo apt-get clean
80+
export C_INCLUDE_PATH=/usr/include/gdal:$C_INCLUDE_PATH
81+
export CPLUS_INCLUDE_PATH=/usr/include/gdal:$CPLUS_INCLUDE_PATH
82+
sudo ldconfig
83+
- name: Install Rustup
84+
run: |
85+
curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused -fsSL "https://sh.rustup.rs" | sh -s -- --profile minimal --default-toolchain none -y
86+
echo "${CARGO_HOME:-$HOME/.cargo}/bin" >> $GITHUB_PATH
87+
- name: Set up Python ${{ inputs.python-version }}
88+
uses: actions/setup-python@v4
89+
with:
90+
python-version: ${{ inputs.python-version }}
91+
- name: Upgrade PIP
92+
run: python -m pip install --upgrade pip
93+
- name: Setup UV and create venv
94+
if: ${{ inputs.use-uv }}
95+
run: |
96+
pip install uv
97+
uv venv
98+
- name: Install build dependencies
99+
run: |
100+
${{ steps.vars.outputs.VENV_CALL }}
101+
${{ steps.vars.outputs.PIP_INSTALL }} -e .[dev]
102+
- name: Check Formatting
103+
run: |
104+
${{ steps.vars.outputs.VENV_CALL }}
105+
python -m pycodestyle
106+
- name: Lint code
107+
run: |
108+
${{ steps.vars.outputs.VENV_CALL }}
109+
python -m pylint geoengine
110+
- name: Type-check code
111+
# mypy seems buggy with uv
112+
if: ${{ !inputs.use-uv }}
113+
run: |
114+
${{ steps.vars.outputs.VENV_CALL }}
115+
python -m mypy geoengine
116+
- name: Build
117+
run: |
118+
${{ steps.vars.outputs.VENV_CALL }}
119+
python -m build .
120+
- name: Install test dependencies
121+
run: |
122+
${{ steps.vars.outputs.VENV_CALL }}
123+
${{ steps.vars.outputs.PIP_INSTALL }} -e .[test]
124+
- name: Lint tests
125+
run: |
126+
${{ steps.vars.outputs.VENV_CALL }}
127+
python -m pylint tests
128+
- name: Type-check tests
129+
# mypy seems buggy with uv
130+
if: ${{ !inputs.use-uv }}
131+
run: |
132+
${{ steps.vars.outputs.VENV_CALL }}
133+
python -m mypy tests
134+
- name: Test
135+
run: |
136+
${{ steps.vars.outputs.VENV_CALL }}
137+
pytest ${{ steps.vars.outputs.COVERAGE_COMMAND }}
138+
env:
139+
GEOENGINE_TEST_CODE_PATH: ${{ github.workspace }}/backend
140+
GEOENGINE_TEST_BUILD_TYPE: "release"
141+
- name: Upload coverage to Coveralls
142+
if: ${{ inputs.coverage }}
143+
uses: coverallsapp/github-action@v2
144+
with:
145+
base-path: library
146+
- name: Examples
147+
run: |
148+
${{ steps.vars.outputs.VENV_CALL }}
149+
${{ steps.vars.outputs.PIP_INSTALL }} -e .[examples]
150+
python test_all_notebooks.py
151+
env:
152+
GEOENGINE_TEST_CODE_PATH: ${{ github.workspace }}/backend
153+
GEOENGINE_TEST_BUILD_TYPE: "release"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ __pycache__
1414
# Virtual Environments
1515
env
1616
env-*
17+
.venv
1718

1819
# Private files
1920
.pypirc

0 commit comments

Comments
 (0)