Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor to ease usage and packaging #32

Merged
merged 10 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 21 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,38 @@ jobs:
test:
runs-on: ubuntu-latest

env:
DB_HOST: localhost
DB_PORT: 5432
DB_NAME: mydatabase
DB_USER: myuser
DB_PASSWORD: mypassword
DB_TABLE_NAME: space2stats

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: 3.11

- name: Install dependencies
- name: Install Poetry
run: |
python -m pip install --upgrade pip
pip install -r space2stats_api/src/requirements.txt
pip install pre-commit pytest
python -m pip install poetry

- name: Set PYTHONPATH
run: echo "PYTHONPATH=$(pwd)/space2stats_api" >> $GITHUB_ENV
- name: Install dependencies
working-directory: ./space2stats_api/src
run: |
poetry install --with test

- name: Run pre-commit
run: pre-commit run --all-files
working-directory: ./space2stats_api/src
run: |
poetry run pre-commit run --all-files

- name: Run tests
run: pytest space2stats_api/tests
working-directory: ./space2stats_api/src
run: |
poetry run pytest -s -vv
env:
DB_HOST: localhost
DB_PORT: 5432
DB_NAME: mydatabase
DB_USER: myuser
DB_PASSWORD: mypassword
DB_TABLE_NAME: space2stats
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,4 @@ db.env
space2stats_api/space2stats_env
*.env
cdk.out
lambda_layer
lambda_layer
11 changes: 6 additions & 5 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ version: '3'

services:
database:
image: ghcr.io/stac-utils/pgstac:v0.8.5
# at time of writing this, ARM64 is not supported so we make sure to use
# a supported platform: https://github.com/postgis/docker-postgis/issues/216
# Could possibly switch to https://github.com/vincentsarago/containers
platform: linux/amd64
image: postgis/postgis:15-3.4
vincentsarago marked this conversation as resolved.
Show resolved Hide resolved
environment:
- POSTGRES_USER=username
- POSTGRES_PASSWORD=password
- POSTGRES_DB=postgis
- PGUSER=username
- PGPASSWORD=password
- PGDATABASE=postgis
ports:
- "${MY_DOCKER_IP:-127.0.0.1}:5439:5432"
command: postgres -N 500
volumes:
- ./.pgdata:/var/lib/postgresql/data
- ./.pgdata:/var/lib/postgresql/data
2 changes: 1 addition & 1 deletion space2stats_api/cdk/aws_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self, scope: Construct, id: str, **kwargs) -> None:
self, "Space2StatsFunction",
entry="../src",
runtime=_lambda.Runtime.PYTHON_3_11,
index="app/main.py",
index="space2stats/handler.py",
timeout=Duration.seconds(120),
handler="handler",
environment=app_settings.model_dump(),
Expand Down
6 changes: 0 additions & 6 deletions space2stats_api/local_db.env

This file was deleted.

2 changes: 0 additions & 2 deletions space2stats_api/pytest.ini

This file was deleted.

541 changes: 541 additions & 0 deletions space2stats_api/src/LICENSE

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions space2stats_api/src/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
## space2stats
Empty file.
23 changes: 0 additions & 23 deletions space2stats_api/src/app/main.py

This file was deleted.

Empty file.
59 changes: 0 additions & 59 deletions space2stats_api/src/app/routers/api.py

This file was deleted.

16 changes: 0 additions & 16 deletions space2stats_api/src/app/settings.py

This file was deleted.

Empty file.
60 changes: 0 additions & 60 deletions space2stats_api/src/app/utils/db_utils.py

This file was deleted.

Loading