From 6001838fc840db1524b03da2a2af8bac5ec525b7 Mon Sep 17 00:00:00 2001 From: kshitijrajsharma Date: Thu, 16 Nov 2023 15:28:40 +0545 Subject: [PATCH 1/2] Export sample variables to build and unit test --- .github/workflows/Unit-Test.yml | 6 +++++- .github/workflows/build.yml | 7 +++++++ config.txt.sample | 4 ++-- src/config.py | 2 +- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/Unit-Test.yml b/.github/workflows/Unit-Test.yml index 7284bdd5..00928eb8 100644 --- a/.github/workflows/Unit-Test.yml +++ b/.github/workflows/Unit-Test.yml @@ -58,7 +58,11 @@ jobs: python -m pip install --upgrade pip pip install -r requirements.txt pip install -e . - + - name: Export essential dummy env + run: | + export OSM_CLIENT_ID=thisisfakeosmcliendid + export OSM_CLIENT_SECRET=thisisclientosm + export APP_SECRET_KEY=thisissecretkey - name: Launch Worker run: | celery --app API.api_worker worker --loglevel=INFO --queues='raw_default' & diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f1370dbc..fd6f8d7e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -66,6 +66,13 @@ jobs: python -m pip install --upgrade pip pip install -r requirements.txt pip install -e . + + - name: Export essential dummy env + run: | + export OSM_CLIENT_ID=thisisfakeosmcliendid + export OSM_CLIENT_SECRET=thisisclientosm + export APP_SECRET_KEY=thisissecretkey + - name: Run uvicorn server run: | uvicorn API.main:app &> uvicorn.log & diff --git a/config.txt.sample b/config.txt.sample index b9a09c9a..937c0cdc 100644 --- a/config.txt.sample +++ b/config.txt.sample @@ -19,8 +19,8 @@ PGDATABASE=rawdata # for scope. Callback / Redirect URI should be set when the OAuth2 app # is created on OSM portal. App secret key is a high-entropy string. [OAUTH] -OSM_CLIENT_ID=0yhbzr7-e0F-DGgyxXOyq2Y4d_sYLflMzVvLIfRtxHg -OSM_CLIENT_SECRET= KI59u4PLCQFAd8Vo2oewaHNmlf2EfTcfGgwWd2VCtk8 +OSM_CLIENT_ID=0yhbzr7-e0F-DGgyxXOyq2Y4d_sYLfdflMzVvLIfRtxHg +OSM_CLIENT_SECRET= KI59u4PLCQFAd8Vo2oewaHNmlf2EfTcfGgwWd2VCsdtk8 ;OSM_URL=https://www.openstreetmap.org ;OSM_PERMISSION_SCOPE=read_prefs LOGIN_REDIRECT_URI=http://raw-data-test.example.net:8000/v1/auth/callback/ diff --git a/src/config.py b/src/config.py index 290f5d9c..deaea7df 100644 --- a/src/config.py +++ b/src/config.py @@ -209,7 +209,7 @@ def get_oauth_credentials() -> tuple: "OAUTH", "APP_SECRET_KEY" ) login_redirect_uri = os.environ.get("LOGIN_REDIRECT_URI") or config.get( - "OAUTH", "LOGIN_REDIRECT_URI" + "OAUTH", "LOGIN_REDIRECT_URI", fallback="http://127.0.0.1:8000/v1/auth/callback" ) scope = os.environ.get("OSM_PERMISSION_SCOPE") or config.get( "OAUTH", "OSM_PERMISSION_SCOPE", fallback="read_prefs" From 6e73c438528f20bd17b159a539b441b49ecfa739 Mon Sep 17 00:00:00 2001 From: kshitijrajsharma Date: Thu, 16 Nov 2023 15:34:07 +0545 Subject: [PATCH 2/2] Export variables inside steps --- .github/workflows/Unit-Test.yml | 8 +++++--- .github/workflows/build.yml | 8 ++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/Unit-Test.yml b/.github/workflows/Unit-Test.yml index 00928eb8..b9504b0a 100644 --- a/.github/workflows/Unit-Test.yml +++ b/.github/workflows/Unit-Test.yml @@ -58,15 +58,17 @@ jobs: python -m pip install --upgrade pip pip install -r requirements.txt pip install -e . - - name: Export essential dummy env + + - name: Launch Worker run: | export OSM_CLIENT_ID=thisisfakeosmcliendid export OSM_CLIENT_SECRET=thisisclientosm export APP_SECRET_KEY=thisissecretkey - - name: Launch Worker - run: | celery --app API.api_worker worker --loglevel=INFO --queues='raw_default' & - name: Run Tests run: | + export OSM_CLIENT_ID=thisisfakeosmcliendid + export OSM_CLIENT_SECRET=thisisclientosm + export APP_SECRET_KEY=thisissecretkey py.test -v -s diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fd6f8d7e..b689ac9d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -67,19 +67,19 @@ jobs: pip install -r requirements.txt pip install -e . - - name: Export essential dummy env + - name: Run uvicorn server run: | export OSM_CLIENT_ID=thisisfakeosmcliendid export OSM_CLIENT_SECRET=thisisclientosm export APP_SECRET_KEY=thisissecretkey - - - name: Run uvicorn server - run: | uvicorn API.main:app &> uvicorn.log & env: PORT: 8000 - name: Run celery server run: | + export OSM_CLIENT_ID=thisisfakeosmcliendid + export OSM_CLIENT_SECRET=thisisclientosm + export APP_SECRET_KEY=thisissecretkey celery --app API.api_worker worker --loglevel=DEBUG &> worker.log & - name: Run flower dashboard run: |