Skip to content

Commit

Permalink
Merge develop into coreMIS (#169)
Browse files Browse the repository at this point in the history
* ONI-62: Add Nepali calendar dependency. (#163)

* Activate policy renewal task (#159)

* Rename pgsql to pgsql.yml (#136)

* OP-1512 Specified version of apscheduler (#167)

---------

Co-authored-by: wzglinieckisoldevelo <[email protected]>
Co-authored-by: Dragos DOBRE <[email protected]>
Co-authored-by: Patrick Delcroix <[email protected]>
  • Loading branch information
4 people authored Aug 17, 2023
1 parent 8a03a82 commit c01cb6b
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 73 deletions.
66 changes: 0 additions & 66 deletions .github/workflows/pgsql

This file was deleted.

92 changes: 92 additions & 0 deletions .github/workflows/pgsql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Automated CI PSQL testing
# This workflow run automatically for every commit on github it checks the syntax and launch the tests.
# | grep . | uniq -c filters out empty lines and then groups consecutive lines together with the number of occurrences
on:
push:
workflow_dispatch:
inputs:
comment:
description: Just a simple comment to know the purpose of the manual build
required: false

jobs:
build:
runs-on: ubuntu-20.04
services:
pgsql:
image: postgres
env:
DB_HOST: localhost
DB_PORT: 5432
POSTGRES_DB: imis
POSTGRES_USER: postgres
POSTGRES_PASSWORD: GitHub999
ports:
- 5432:5432
# needed because the mssql container does not provide a health check
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v2

- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8

- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
python modules-requirements.py openimis.json > modules-requirements.txt
pip install -r modules-requirements.txt
- name: Environment info
run: |
pip list
export DBBRANCH="$([ $GITHUB_REF == 'main' ] && echo "main" || echo "develop")"
if [ ${GITHUB_REF##*/} = "develop" ]; then export DBBRANCH="main"; else export DBBRANCH="develop"; fi
echo "Branch ${GITHUB_REF##*/}, usign ${DBBRANCH} branch for database"
git clone --depth 1 --branch $DBBRANCH https://github.com/openimis/database_postgresql.git ./sql
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" | sudo tee /etc/apt/sources.list.d/postgresql-pgdg.list > /dev/null
sudo apt-get install postgresql-client
- name: Initialize DB
run: |
echo 'set search_path to public' >> ~/.psqlrc
PGPASSWORD=GitHub999 psql -U postgres -h localhost -d imis -U postgres -f ./sql/database\ scripts/00_dump.sql | grep . | uniq -c
PGPASSWORD=GitHub999 psql -U postgres -h localhost -d imis -U postgres -f ./sql/database\ scripts/02_aux_functions.sql | grep . | uniq -c
PGPASSWORD=GitHub999 psql -U postgres -h localhost -d imis -U postgres -f ./sql/database\ scripts/03_views.sql | grep . | uniq -c
PGPASSWORD=GitHub999 psql -U postgres -h localhost -d imis -U postgres -f ./sql/database\ scripts/04_functions.sql | grep . | uniq -c
PGPASSWORD=GitHub999 psql -U postgres -h localhost -d imis -U postgres -f ./sql/database\ scripts/05_stored_procs.sql | grep . | uniq -c
PGPASSWORD=GitHub999 psql -U postgres -h localhost -d imis -U postgres -f ./sql/database\ scripts/demo_db.sql | grep . | uniq -c
- name: Django tests
run: |
python -V
ls -l
cd openIMIS
ls -l
python manage.py test --keepdb $(jq -r '(.modules[]|.name)' ../openimis.json)
env:
SECRET_KEY: secret
DEBUG: true
DB_ENGINE: django.db.backends.postgresql
#DJANGO_SETTINGS_MODULE: hat.settings
DB_HOST: localhost
DB_PORT: 5432
DB_NAME: imis
DB_USER: postgres
DB_PASSWORD: GitHub999
#DEV_SERVER: true
SITE_ROOT: api
12 changes: 6 additions & 6 deletions openIMIS/openIMIS/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def SITE_URL():
"unicode_results": True,
}
else:
DATABASE_OPTIONS = {}
DATABASE_OPTIONS = {'options': '-c search_path=django,public'}

if not os.environ.get("NO_DATABASE_ENGINE", "False") == "True":
DATABASES = {
Expand Down Expand Up @@ -344,11 +344,11 @@ def SITE_URL():
"args": ["cron"],
"kwargs": {"id": "openimis_test_batch", "minute": 16, "replace_existing": True},
},
# {
# "method": "policy.tasks.get_policies_for_renewal",
# "args": ["cron"],
# "kwargs": {"id": "openimis_renewal_batch", "hour": 8, "minute": 30, "replace_existing": True},
# },
{
"method": "policy.tasks.get_policies_for_renewal",
"args": ["cron"],
"kwargs": {"id": "openimis_renewal_batch", "hour": 8, "minute": 30, "replace_existing": True},
},
# {
# "method": "policy_notification.tasks.send_notification_messages",
# "args": ["cron"],
Expand Down
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ wheel
whitenoise
django-health-check
requests~=2.28.1
apscheduler
apscheduler==3.10.1
# As from v0.4, Django-apscheduler has a migration that is incompatible with SQL Server
# (autoincrement int => bigint) so we are using our own fork with a squashed migration
git+https://github.com/openimis/django-apscheduler.git#egg=django-apscheduler
Expand All @@ -45,4 +45,6 @@ drf-spectacular==0.25.1
django-cprofile-middleware==1.0.5
# flake8 and django-nose are needed for sonar scan in backend modules
flake8
# TODO remove to a separate file for implementations and change test workflows to reflect that
nepali_datetime

0 comments on commit c01cb6b

Please sign in to comment.