Skip to content

Commit

Permalink
Update envfile_testing Make command #520
Browse files Browse the repository at this point in the history
Signed-off-by: Jono Yang <[email protected]>
  • Loading branch information
JonoYang committed Aug 8, 2024
1 parent ccb6e1c commit 9cd5394
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
13 changes: 6 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,11 @@ envfile:
@mkdir -p $(shell dirname ${ENV_FILE}) && touch ${ENV_FILE}
@echo SECRET_KEY=\"${GET_SECRET_KEY}\" > ${ENV_FILE}

envfile_testing:
@echo "-> Create the .env file and generate a secret key"
@if test -f ${ENV_FILE}; then echo ".env file exists already"; exit 1; fi
@mkdir -p $(shell dirname ${ENV_FILE}) && touch ${ENV_FILE}
@echo SECRET_KEY=\"${GET_SECRET_KEY}\" >> ${ENV_FILE}
@echo SCANCODEIO_DB_PORT=\"5433\" >> ${ENV_FILE}
envfile_testing: envfile
@echo PACKAGEDB_DB_USER=\"postgres\" >> ${ENV_FILE}
@echo PACKAGEDB_DB_PASSWORD=\"postgres\" >> ${ENV_FILE}
@echo SCANCODEIO_DB_USER=\"postgres\" >> ${ENV_FILE}
@echo SCANCODEIO_DB_PASSWORD=\"postgres\" >> ${ENV_FILE}

isort:
@echo "-> Apply isort changes to ensure proper imports ordering"
Expand Down Expand Up @@ -126,7 +125,7 @@ run_map:

test:
@echo "-> Run the test suite"
${ACTIVATE} DJANGO_SETTINGS_MODULE=purldb_project.settings ${PYTHON_EXE} -m pytest -vvs --ignore matchcode_pipeline --ignore matchcode_project --ignore purldb-toolkit --ignore packagedb/tests/test_throttling.py
${ACTIVATE} DJANGO_SETTINGS_MODULE=purldb_project.settings ${PYTHON_EXE} -m pytest -x -vvs --ignore matchcode_pipeline --ignore matchcode_project --ignore purldb-toolkit --ignore packagedb/tests/test_throttling.py
${ACTIVATE} DJANGO_SETTINGS_MODULE=purldb_project.settings ${PYTHON_EXE} -m pytest -vvs packagedb/tests/test_throttling.py
${ACTIVATE} DJANGO_SETTINGS_MODULE=matchcode_project.settings ${PYTHON_EXE} -m pytest -vvs matchcode_pipeline
${ACTIVATE} ${PYTHON_EXE} -m pytest -vvs purldb-toolkit/
Expand Down
16 changes: 7 additions & 9 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@

resources:
containers:
- container: postgres
image: postgres
env:
POSTGRES_DB: packagedb
POSTGRES_USER: packagedb
POSTGRES_PASSWORD: packagedb
POSTGRES_INITDB_ARGS: "--encoding=UTF-8 --lc-collate=en_US.UTF-8 --lc-ctype=en_US.UTF-8"
ports:
- 5432:5432
- container: postgres
image: postgres:13
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432

jobs:

Expand Down
5 changes: 4 additions & 1 deletion etc/ci/azure-posix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ jobs:
test_suite_label: ${{ tsuite.key }}
test_suite: ${{ tsuite.value }}

services:
postgres: postgres

steps:
- checkout: self
fetchDepth: 10
Expand All @@ -31,7 +34,7 @@ jobs:

- script: |
make dev
make envfile_testing
make envfile
sudo mkdir /etc/scancodeio
sudo cp .env /etc/scancodeio
displayName: '${{ pyver }} - Configure'
Expand Down
4 changes: 3 additions & 1 deletion purldb_project/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
ENV_FILE = "/etc/purldb/.env"
if not Path(ENV_FILE).exists():
ENV_FILE = ROOT_DIR / ".env"
print(ENV_FILE)

env = environ.Env()
environ.Env.read_env(str(ENV_FILE))
Expand Down Expand Up @@ -107,7 +108,8 @@
)

# Database

print(env.str('PACKAGEDB_DB_USER', 'packagedb'))
print(env.str('PACKAGEDB_DB_PASSWORD', 'packagedb'))
DATABASES = {
'default': {
'ENGINE': env.str('PACKAGEDB_DB_ENGINE', 'django.db.backends.postgresql'),
Expand Down

0 comments on commit 9cd5394

Please sign in to comment.