Skip to content

Commit

Permalink
temp
Browse files Browse the repository at this point in the history
  • Loading branch information
malinowskikam committed Aug 24, 2023
1 parent e0b9741 commit 812b8bc
Showing 1 changed file with 37 additions and 31 deletions.
68 changes: 37 additions & 31 deletions .github/workflows/ci.yml → .github/workflows/ci_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
required: false

jobs:
ci:
ci_main:
runs-on: ubuntu-20.04

services:
Expand Down Expand Up @@ -48,77 +48,84 @@ jobs:
- uses: actions/checkout@v2

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

- 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
export MODULES=$(jq -r '(.modules[].name)' ../openimis.json | xargs)
export MODULES=$(jq -r '(.modules[].name)' openimis.json | xargs)
echo $modules
- 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"
sudo apt-get update
sudo apt-get install jq
- name: Init PSQL
run: |
git clone --depth 1 --branch $DBBRANCH https://github.com/openimis/database_postgresql.git ./sql_psql
export DB_NAME_TEST="test_$DB_NAME"
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_psql
cd sql_psql/ && bash concatenate_files.sh && cd ..
echo 'set search_path to public' >> ~/.psqlrc
PGPASSWORD=GitHub999 psql -U postgres -h localhost -d imis -U postgres -f ./sql_psql/database\ scripts/00_dump.sql | grep . | uniq -c
PGPASSWORD=GitHub999 psql -U postgres -h localhost -d imis -U postgres -f ./sql_psql/database\ scripts/02_aux_functions.sql | grep . | uniq -c
PGPASSWORD=GitHub999 psql -U postgres -h localhost -d imis -U postgres -f ./sql_psql/database\ scripts/03_views.sql | grep . | uniq -c
PGPASSWORD=GitHub999 psql -U postgres -h localhost -d imis -U postgres -f ./sql_psql/database\ scripts/04_functions.sql | grep . | uniq -c
PGPASSWORD=GitHub999 psql -U postgres -h localhost -d imis -U postgres -f ./sql_psql/database\ scripts/05_stored_procs.sql | grep . | uniq -c
PGPASSWORD=GitHub999 psql -U postgres -h localhost -d imis -U postgres -f ./sql_psql/database\ scripts/demo_db.sql | grep . | uniq -c
PGPASSWORD=GitHub999 psql -U $DB_USER -h $DB_HOST -c "DROP DATABASE IF EXISTS \"$DB_NAME_TEST\";"
PGPASSWORD=GitHub999 psql -U $DB_USER -h $DB_HOST -c "CREATE DATABASE \"$DB_NAME_TEST\";"
PGPASSWORD=GitHub999 psql -U $DB_USER -h $DB_HOST -d $DB_NAME_TEST -f ./sql_psql/output/fullDemoDatabase.sql | grep . | uniq -c
env:
DB_HOST: localhost
DB_PORT: 5432
DB_NAME: imis
DB_USER: postgres
DB_PASSWORD: GitHub999

- name: Initialize MSSQL
run: |
git clone --depth 1 --branch $DBBRANCH https://github.com/openimis/database_ms_sqlserver.git ./sql_mssql
cd sql/ && bash concatenate_files.sh && cd ..
export DB_NAME_TEST="test_$DB_NAME"
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_ms_sqlserver.git ./sql_mssql
cd sql_mssql/ && bash concatenate_files.sh && cd ..
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list
sudo apt-get update
sudo apt-get install mssql-tools unixodbc-dev
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P $SA_PASSWORD -Q 'DROP DATABASE IF EXISTS imis'
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P $SA_PASSWORD -Q 'CREATE DATABASE imis'
/opt/mssql-tools/bin/sqlcmd -S localhost,1433 -U SA -P $SA_PASSWORD -d imis -i ./sql_mssql/output/fullDemoDatabase.sql | grep . | uniq -c
/opt/mssql-tools/bin/sqlcmd -S localhost,1433 -U SA -P $SA_PASSWORD -Q 'DROP DATABASE IF EXISTS imis'
/opt/mssql-tools/bin/sqlcmd -S localhost,1433 -U SA -P $SA_PASSWORD -Q 'CREATE DATABASE imis'
/opt/mssql-tools/bin/sqlcmd -S localhost,1433 -U SA -P $SA_PASSWORD -Q imis -i ./sql_mssql/output/fullDemoDatabase.sql | grep . | uniq -c
python init_test_db.py | grep . | uniq -c
#We don't need to migrate the main database, `python manage.py test` migrates the test database
env:
SECRET_KEY: secret
DEBUG: true
#DJANGO_SETTINGS_MODULE: hat.settings
DB_HOST: localhost
DB_PORT: 1433
DB_NAME: imis
DB_USER: sa
DB_PASSWORD: GitHub999
#DEV_SERVER: true
SITE_ROOT: api
#REMOTE_USER_AUTHENTICATION: True

- name: Django tests PSQL
- name: Switch to backend
run: |
python -V
python3 -V
cd openIMIS
coverage run python manage.py test --keepdb $MODULES
- name: Django tests PSQL
if: success() || failure()
run: |
coverage run manage.py test --keepdb $MODULES
coverage report
env:
SECRET_KEY: secret
Expand All @@ -134,9 +141,8 @@ jobs:
SITE_ROOT: api

- name: Django tests MSSQL
if: success() || failure()
run: |
python -V
cd openIMIS
coverage run manage.py test --keepdb $MODULES
coverage report
env:
Expand Down

0 comments on commit 812b8bc

Please sign in to comment.