Skip to content

Commit

Permalink
EAS-579 Allow Makefile to build for local dev and ci pipeline (#19)
Browse files Browse the repository at this point in the history
* makefile can now build for local dev and ci pipeline

* add config switch for using RDS master creds

* formatting
  • Loading branch information
jonathan-owens-gds authored Mar 31, 2023
1 parent 77be931 commit 6870e86
Show file tree
Hide file tree
Showing 8 changed files with 159 additions and 85 deletions.
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,17 @@ PYTHON_EXECUTABLE_PREFIX := $(shell test -d "$${VIRTUALENV_ROOT}" && echo "$${VI

.PHONY: legacy-bootstrap
legacy-bootstrap: generate-version-file ## Set up everything to run the app
pip3 install -r requirements_for_test.txt
pip3 install -r requirements_for_ci.txt
createdb emergency_alerts || true
(. environment.sh && flask db upgrade) || true

.PHONY: bootstrap
bootstrap: generate-version-file ## Set up everything to run the app
pip3 install -r requirements_for_test.txt
pip3 install -r requirements_for_ci.txt

.PHONY: bootstrap-dev ## If running locally, run "source environment.sh"
bootstrap-dev: generate-version-file
pip3 install -r requirements_for_dev.txt

.PHONY: bootstrap-with-docker
bootstrap-with-docker: ## Build the image to run the app in Docker
Expand Down
25 changes: 17 additions & 8 deletions app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ class Config(object):
# app/celery/scheduled_tasks.py
"run-health-check": {
"task": "run-health-check",
"schedule": crontab(minute='*/1'),
"schedule": crontab(minute="*/1"),
"options": {"queue": QueueNames.PERIODIC},
},
"run-scheduled-jobs": {
Expand All @@ -223,12 +223,12 @@ class Config(object):
},
"switch-current-sms-provider-on-slow-delivery": {
"task": "switch-current-sms-provider-on-slow-delivery",
"schedule": crontab(minute='*/1'), # Every minute
"schedule": crontab(minute="*/1"), # Every minute
"options": {"queue": QueueNames.PERIODIC},
},
"check-job-status": {
"task": "check-job-status",
"schedule": crontab(minute='*/1'),
"schedule": crontab(minute="*/1"),
"options": {"queue": QueueNames.PERIODIC},
},
"tend-providers-back-to-middle": {
Expand Down Expand Up @@ -465,15 +465,24 @@ class Decoupled(Development):

class ServerlessDB(Decoupled):
NOTIFY_ENVIRONMENT = "serverlessdb"
SQLALCHEMY_DATABASE_URI = (
"postgresql://{user}:password@{host}:{port}/{database}?sslmode=verify-full&sslrootcert={cert}".format(
if os.getenv("MASTER_USERNAME"):
SQLALCHEMY_DATABASE_URI = "postgresql://{user}:{password}@{host}:{port}/{database}".format(
user=os.environ.get("MASTER_USERNAME"),
password=os.environ.get("MASTER_PASSWORD"),
host=os.environ.get("RDS_HOST"),
port=os.environ.get("RDS_PORT"),
database=os.environ.get("DATABASE"),
user=os.environ.get("RDS_USER"),
cert="/etc/ssl/certs/global-bundle.pem",
)
)
else:
SQLALCHEMY_DATABASE_URI = (
"postgresql://{user}:password@{host}:{port}/{database}?sslmode=verify-full&sslrootcert={cert}".format(
user=os.environ.get("RDS_USER"),
host=os.environ.get("RDS_HOST"),
port=os.environ.get("RDS_PORT"),
database=os.environ.get("DATABASE"),
cert="/etc/ssl/certs/global-bundle.pem",
)
)
CBC_PROXY_ENABLED = True
DEBUG = True

Expand Down
20 changes: 18 additions & 2 deletions requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,24 @@ lxml==4.9.1

notifications-python-client==8.0.0

-e file:../emergency-alerts-utils

# gds-metrics requires prometheseus 0.2.0, override that requirement as 0.7.1 brings significant performance gains
prometheus-client==0.14.1
git+https://github.com/alphagov/gds_metrics_python.git@6f1840a57b6fb1ee40b7e84f2f18ec229de8aa72

# Package for testing
black==22.8.0
flake8==5.0.4
flake8-bugbear==22.9.23
flaky==3.7.0
isort==5.10.1
moto==4.0.11
pytest==7.1.3
pytest-env==0.6.2
pytest-mock==3.9.0
pytest-cov==4.0.0
pytest-xdist==2.5.0
freezegun==1.2.2
requests-mock==1.10.0

# used for creating manifest file locally
jinja2-cli[yaml]==0.8.2
Loading

0 comments on commit 6870e86

Please sign in to comment.