Skip to content

Commit

Permalink
Merge pull request #828 from hotosm/fix/underpass-env-var
Browse files Browse the repository at this point in the history
Set underpass url via env var
  • Loading branch information
robsavoye authored Sep 12, 2023
2 parents 59da130 + 8f812f5 commit 66e5659
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 22 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ FMTM_DB_HOST=fmtm-db
FMTM_DB_USER=fmtm
FMTM_DB_PASSWORD=fmtm
FMTM_DB_NAME=fmtm

### Underpass (optional) ###
# UNDERPASS_API_URL=
16 changes: 16 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: PR

on:
pull_request:
branches:
- main
- staging
- development
# Allow manual trigger (workflow_dispatch)
workflow_dispatch:

jobs:
pytest:
uses: ./.github/workflows/reusable/pytest.yml
frontend-tests:
uses: ./.github/workflows/reusable/frontend_tests.yml
24 changes: 24 additions & 0 deletions .github/workflows/pr_pytest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: PR

on:
pull_request:
branches:
- main
- staging
- development
paths:
- src/backend/**
# Allow manual trigger (workflow_dispatch)
workflow_dispatch:

jobs:
frontend-tests:
runs-on: ubuntu-latest
environment:
name: ${{ github.ref_name }}
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: PyTest
uses: ./.github/workflows/reusable/pytest.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
name: Frontend Tests

on:
push:
workflow_call:
paths:
- "src/frontend/**" # Trigger the workflow only when files within srv/frontend change
- ".github/workflows/**" # Also trigger if github workflow changes
workflow_dispatch:
- src/frontend/**

jobs:
test:
name: Run Frontend Tests
runs-on: ubuntu-latest

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

- name: Setup Node.js
uses: actions/setup-node@v2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
name: pytest

on:
# Run tests on all pushed branches
push:
branches:
- "*"
# Run tests on PR, prior to merge to main & development.
pull_request:
branches:
- main
- staging
- development
# Allow manual trigger (workflow_dispatch)
workflow_dispatch:
workflow_call:
paths:
- src/backend/**

permissions:
contents: read
Expand Down
1 change: 1 addition & 0 deletions src/backend/app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def assemble_db_connection(cls, v: Optional[str], info: FieldValidationInfo) ->
OSM_SCOPE: str = "read_prefs"
OSM_LOGIN_REDIRECT_URI: str = "http://127.0.0.1:8080/osmauth/"

UNDERPASS_API_URL: str = "https://raw-data-api0.hotosm.org/v1"
SENTRY_DSN: Optional[str] = None

model_config = SettingsConfigDict(
Expand Down
6 changes: 3 additions & 3 deletions src/backend/app/projects/project_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ def get_osm_extracts(boundary: str):
else:
query["geometry"] = json_boundary

base_url = "https://raw-data-api0.hotosm.org/v1"
base_url = settings.UNDERPASS_API_URL
query_url = f"{base_url}/snapshot/"
headers = {"accept": "application/json", "Content-Type": "application/json"}

Expand Down Expand Up @@ -1394,7 +1394,7 @@ def generate_appuser_files(
project_log.info(f"Extracting Data from OSM")

# OSM Extracts for whole project
pg = PostgresClient("https://raw-data-api0.hotosm.org/v1", "underpass")
pg = PostgresClient(settings.UNDERPASS_API_URL, "underpass")
# This file will store osm extracts
outfile = f"/tmp/{prefix}_{xform_title}.geojson"

Expand Down Expand Up @@ -2019,7 +2019,7 @@ async def update_project_form(
db.commit()

# OSM Extracts for whole project
pg = PostgresClient("https://raw-data-api0.hotosm.org/v1", "underpass")
pg = PostgresClient(settings.UNDERPASS_API_URL, "underpass")
outfile = (
f"/tmp/{project_title}_{category}.geojson" # This file will store osm extracts
)
Expand Down
3 changes: 2 additions & 1 deletion src/backend/app/tasks/tasks_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
from ..projects import project_crud
from ..tasks import tasks_schemas
from ..users import user_crud
from app.config import settings


async def get_task_count_in_project(db: Session, project_id: int):
Expand Down Expand Up @@ -330,7 +331,7 @@ async def update_task_files(
task_polygons = f"/tmp/{project_name}_{category}_{task_id}.geojson"

# Update data extracts in the odk central
pg = PostgresClient("https://raw-data-api0.hotosm.org/v1", "underpass")
pg = PostgresClient(settings.UNDERPASS_API_URL, "underpass")

category = "buildings"

Expand Down

0 comments on commit 66e5659

Please sign in to comment.