-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #215 from geo-engine/reusable-workflow
reusable-workflow
- Loading branch information
Showing
5 changed files
with
178 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
name: Test Python Library | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
python-version: | ||
type: string | ||
required: true | ||
description: 'Python version to use, e.g., "3.9"' | ||
use-uv: | ||
type: boolean | ||
default: false | ||
description: 'Use `uv` for minimum version resolution' | ||
coverage: | ||
type: boolean | ||
default: false | ||
description: 'Generate coverage report' | ||
|
||
jobs: | ||
check: | ||
runs-on: ubuntu-22.04 | ||
|
||
services: | ||
postgres: | ||
image: postgis/postgis | ||
env: | ||
POSTGRES_USER: geoengine | ||
POSTGRES_PASSWORD: geoengine | ||
POSTGRES_DB: geoengine | ||
ports: | ||
- 5432:5432 | ||
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | ||
|
||
defaults: | ||
run: | ||
working-directory: library | ||
|
||
steps: | ||
- name: Checkout library code | ||
uses: actions/checkout@v4 | ||
with: | ||
path: library | ||
- name: Setup variables | ||
id: vars | ||
run: | | ||
echo "GEOENGINE_VERSION=$(cat .github/.backend_git_ref)" >> $GITHUB_OUTPUT | ||
if ${{ inputs.use-uv }}; then | ||
echo "PIP_INSTALL=uv pip install --resolution=lowest-direct" >> $GITHUB_OUTPUT | ||
echo "VENV_CALL=source .venv/bin/activate" >> $GITHUB_OUTPUT | ||
else | ||
echo "PIP_INSTALL=pip install" >> $GITHUB_OUTPUT | ||
echo "VENV_CALL=" >> $GITHUB_OUTPUT | ||
fi | ||
if ${{ inputs.coverage }}; then | ||
echo "COVERAGE_COMMAND=--cov=geoengine --cov-report=lcov" >> $GITHUB_OUTPUT | ||
else | ||
echo "COVERAGE_COMMAND=" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Checkout Geo Engine code | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: geo-engine/geoengine | ||
ref: ${{ steps.vars.outputs.GEOENGINE_VERSION }} | ||
path: backend | ||
- name: Free Disk Space (Ubuntu) | ||
uses: jlumbroso/free-disk-space@main | ||
with: | ||
tool-cache: true | ||
android: true | ||
dotnet: true | ||
haskell: true | ||
large-packages: true | ||
docker-images: true | ||
swap-storage: true | ||
- name: Install lld & GDAL & Protobuf | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install lld libgdal-dev gdal-bin build-essential clang curl protobuf-compiler libgeos-dev libproj-dev | ||
sudo apt-get clean | ||
export C_INCLUDE_PATH=/usr/include/gdal:$C_INCLUDE_PATH | ||
export CPLUS_INCLUDE_PATH=/usr/include/gdal:$CPLUS_INCLUDE_PATH | ||
sudo ldconfig | ||
- name: Install Rustup | ||
run: | | ||
curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused -fsSL "https://sh.rustup.rs" | sh -s -- --profile minimal --default-toolchain none -y | ||
echo "${CARGO_HOME:-$HOME/.cargo}/bin" >> $GITHUB_PATH | ||
- name: Set up Python ${{ inputs.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ inputs.python-version }} | ||
- name: Upgrade PIP | ||
run: python -m pip install --upgrade pip | ||
- name: Setup UV and create venv | ||
if: ${{ inputs.use-uv }} | ||
run: | | ||
pip install uv | ||
uv venv | ||
- name: Install build dependencies | ||
run: | | ||
${{ steps.vars.outputs.VENV_CALL }} | ||
${{ steps.vars.outputs.PIP_INSTALL }} -e .[dev] | ||
- name: Check Formatting | ||
run: | | ||
${{ steps.vars.outputs.VENV_CALL }} | ||
python -m pycodestyle | ||
- name: Lint code | ||
run: | | ||
${{ steps.vars.outputs.VENV_CALL }} | ||
python -m pylint geoengine | ||
- name: Type-check code | ||
# mypy seems buggy with uv | ||
if: ${{ !inputs.use-uv }} | ||
run: | | ||
${{ steps.vars.outputs.VENV_CALL }} | ||
python -m mypy geoengine | ||
- name: Build | ||
run: | | ||
${{ steps.vars.outputs.VENV_CALL }} | ||
python -m build . | ||
- name: Install test dependencies | ||
run: | | ||
${{ steps.vars.outputs.VENV_CALL }} | ||
${{ steps.vars.outputs.PIP_INSTALL }} -e .[test] | ||
- name: Lint tests | ||
run: | | ||
${{ steps.vars.outputs.VENV_CALL }} | ||
python -m pylint tests | ||
- name: Type-check tests | ||
# mypy seems buggy with uv | ||
if: ${{ !inputs.use-uv }} | ||
run: | | ||
${{ steps.vars.outputs.VENV_CALL }} | ||
python -m mypy tests | ||
- name: Test | ||
run: | | ||
${{ steps.vars.outputs.VENV_CALL }} | ||
pytest ${{ steps.vars.outputs.COVERAGE_COMMAND }} | ||
env: | ||
GEOENGINE_TEST_CODE_PATH: ${{ github.workspace }}/backend | ||
GEOENGINE_TEST_BUILD_TYPE: "release" | ||
- name: Upload coverage to Coveralls | ||
if: ${{ inputs.coverage }} | ||
uses: coverallsapp/github-action@v2 | ||
with: | ||
base-path: library | ||
- name: Examples | ||
run: | | ||
${{ steps.vars.outputs.VENV_CALL }} | ||
${{ steps.vars.outputs.PIP_INSTALL }} -e .[examples] | ||
python test_all_notebooks.py | ||
env: | ||
GEOENGINE_TEST_CODE_PATH: ${{ github.workspace }}/backend | ||
GEOENGINE_TEST_BUILD_TYPE: "release" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ __pycache__ | |
# Virtual Environments | ||
env | ||
env-* | ||
.venv | ||
|
||
# Private files | ||
.pypirc | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.