|
| 1 | +name: Automated CI testing |
| 2 | +# This workflow run automatically for every commit on github it checks the syntax and launch the tests. |
| 3 | +# | grep . | uniq -c filters out empty lines and then groups consecutive lines together with the number of occurrences |
| 4 | +on: |
| 5 | + pull_request: |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + comment: |
| 9 | + description: Just a simple comment to know the purpose of the manual build |
| 10 | + required: false |
| 11 | + |
| 12 | +jobs: |
| 13 | + run_test: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + services: |
| 16 | + mssql: |
| 17 | + image: mcr.microsoft.com/mssql/server:2017-latest |
| 18 | + env: |
| 19 | + ACCEPT_EULA: Y |
| 20 | + SA_PASSWORD: GitHub999 |
| 21 | + ports: |
| 22 | + - 1433:1433 |
| 23 | + # needed because the mssql container does not provide a health check |
| 24 | + options: --health-interval=10s --health-timeout=3s --health-start-period=10s --health-retries=10 --health-cmd="/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P ${SA_PASSWORD} -Q 'SELECT 1' || exit 1" |
| 25 | + |
| 26 | + steps: |
| 27 | + - name: Set up Python 3.8 |
| 28 | + uses: actions/setup-python@v2 |
| 29 | + with: |
| 30 | + python-version: 3.8 |
| 31 | + - name: copy current branch |
| 32 | + uses: actions/checkout@v2 |
| 33 | + with: |
| 34 | + path: './new' |
| 35 | + - name: install linux packages |
| 36 | + run: | |
| 37 | + mkdir ./oldMain |
| 38 | + wget https://raw.githubusercontent.com/openimis/database_ms_sqlserver/main/Empty%20databases/openIMIS_ONLINE.sql -O oldMain/openIMIS_ONLINE.sql |
| 39 | + wget https://raw.githubusercontent.com/openimis/database_ms_sqlserver/main/Demo%20database/openIMIS_demo_ONLINE.sql -O oldMain/openIMIS_demo_ONLINE.sql |
| 40 | + mkdir ./1.42 |
| 41 | + wget https://raw.githubusercontent.com/openimis/database_ms_sqlserver/v1.4.2/Empty%20databases/openIMIS_ONLINE.sql -O 1.42/openIMIS_ONLINE.sql |
| 42 | + curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - |
| 43 | + curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list |
| 44 | + sudo apt-get update |
| 45 | + sudo ACCEPT_EULA=Y apt-get install -y mssql-tools build-essential dialog apt-utils unixodbc-dev jq -y |
| 46 | + python -m pip install --upgrade pip |
| 47 | + - name: DB migration 1.42 |
| 48 | + run: | |
| 49 | + /opt/mssql-tools/bin/sqlcmd -S localhost,1433 -U SA -P $SA_PASSWORD -Q 'DROP DATABASE IF EXISTS imis_1_4_2' |
| 50 | + /opt/mssql-tools/bin/sqlcmd -S localhost,1433 -U SA -P $SA_PASSWORD -Q 'CREATE DATABASE imis_1_4_2' |
| 51 | + /opt/mssql-tools/bin/sqlcmd -S localhost,1433 -U SA -P $SA_PASSWORD -d imis_1_4_2 -i 1.42/openIMIS_ONLINE.sql | grep . | uniq -c |
| 52 | + /opt/mssql-tools/bin/sqlcmd -S localhost,1433 -U SA -P $SA_PASSWORD -d imis_1_4_2 -i "new/Migration script/openIMIS migration latest.sql" | grep . | uniq -c |
| 53 | + /opt/mssql-tools/bin/sqlcmd -S localhost,1433 -U SA -P $SA_PASSWORD -d imis_1_4_2 -i "new/Demo database/openIMIS_demo_ONLINE.sql" | grep . | uniq -c |
| 54 | + env: |
| 55 | + SA_PASSWORD: GitHub999 |
| 56 | + ACCEPT_EULA: Y |
| 57 | + - name: Initialize DB latest |
| 58 | + run: | |
| 59 | + /opt/mssql-tools/bin/sqlcmd -S localhost,1433 -U SA -P $SA_PASSWORD -Q 'DROP DATABASE IF EXISTS imis' |
| 60 | + /opt/mssql-tools/bin/sqlcmd -S localhost,1433 -U SA -P $SA_PASSWORD -Q 'CREATE DATABASE imis' |
| 61 | + /opt/mssql-tools/bin/sqlcmd -S localhost,1433 -U SA -P $SA_PASSWORD -d imis -i "new/Empty databases/openIMIS_ONLINE.sql" | grep . | uniq -c |
| 62 | + /opt/mssql-tools/bin/sqlcmd -S localhost,1433 -U SA -P $SA_PASSWORD -d imis -i "new/Demo database/openIMIS_demo_ONLINE.sql" | grep . | uniq -c |
| 63 | +
|
| 64 | + env: |
| 65 | + SA_PASSWORD: GitHub999 |
| 66 | + ACCEPT_EULA: Y |
| 67 | + - name: DB migration prev main |
| 68 | + run: | |
| 69 | + /opt/mssql-tools/bin/sqlcmd -S localhost,1433 -U SA -P $SA_PASSWORD -Q 'DROP DATABASE IF EXISTS imis_main' |
| 70 | + /opt/mssql-tools/bin/sqlcmd -S localhost,1433 -U SA -P $SA_PASSWORD -Q 'CREATE DATABASE imis_main' |
| 71 | + /opt/mssql-tools/bin/sqlcmd -S localhost,1433 -U SA -P $SA_PASSWORD -d imis_main -i oldMain/openIMIS_ONLINE.sql | grep . | uniq -c |
| 72 | + /opt/mssql-tools/bin/sqlcmd -S localhost,1433 -U SA -P $SA_PASSWORD -d imis_main -i oldMain/openIMIS_demo_ONLINE.sql | grep . | uniq -c |
| 73 | + /opt/mssql-tools/bin/sqlcmd -S localhost,1433 -U SA -P $SA_PASSWORD -d imis_main -i "new/Migration script/openIMIS migration latest.sql" | grep . | uniq -c |
| 74 | +
|
| 75 | +
|
| 76 | + env: |
| 77 | + SA_PASSWORD: GitHub999 |
| 78 | + ACCEPT_EULA: Y |
| 79 | + - name: pull openimis backend |
| 80 | + run: | |
| 81 | + rm ./openimis -rf |
| 82 | + git clone --depth 1 --branch develop https://github.com/openimis/openimis-be_py.git ./openimis |
| 83 | + - name: Install openIMIS Python dependencies |
| 84 | + working-directory: ./openimis |
| 85 | + run: | |
| 86 | + python -m pip install --upgrade pip |
| 87 | + pip install -r requirements.txt |
| 88 | + python modules-requirements.py openimis.json > modules-requirements.txt |
| 89 | + cat modules-requirements.txt |
| 90 | + pip install -r modules-requirements.txt |
| 91 | + - name: Django tests latest |
| 92 | + working-directory: ./openimis |
| 93 | + run: | |
| 94 | + python -V |
| 95 | + ls -l |
| 96 | + cd openIMIS |
| 97 | + mkdir staticfiles |
| 98 | + python manage.py migrate |
| 99 | + python init_test_db.py | grep . | uniq -c |
| 100 | + python manage.py test --keepdb $(jq -r '(.modules[]|.name)' ../openimis.json) |
| 101 | + env: |
| 102 | + SECRET_KEY: secret |
| 103 | + DEBUG: true |
| 104 | + #DJANGO_SETTINGS_MODULE: hat.settings |
| 105 | + DB_HOST: localhost |
| 106 | + DB_PORT: 1433 |
| 107 | + DB_NAME: imis |
| 108 | + DB_USER: sa |
| 109 | + DB_PASSWORD: GitHub999 |
| 110 | + #DEV_SERVER: true |
| 111 | + SITE_ROOT: api |
| 112 | + REMOTE_USER_AUTHENTICATION: True |
| 113 | + - name: Django tests 1.4.2 |
| 114 | + working-directory: ./openimis |
| 115 | + run: | |
| 116 | + python -V |
| 117 | + ls -l |
| 118 | + cd openIMIS |
| 119 | + python manage.py migrate |
| 120 | + python init_test_db.py | grep . | uniq -c |
| 121 | + python manage.py test --keepdb $(jq -r '(.modules[]|.name)' ../openimis.json) |
| 122 | + env: |
| 123 | + SECRET_KEY: secret |
| 124 | + DEBUG: true |
| 125 | + #DJANGO_SETTINGS_MODULE: hat.settings |
| 126 | + DB_HOST: localhost |
| 127 | + DB_PORT: 1433 |
| 128 | + DB_NAME: imis_1_4_2 |
| 129 | + DB_USER: sa |
| 130 | + DB_PASSWORD: GitHub999 |
| 131 | + #DEV_SERVER: true |
| 132 | + SITE_ROOT: api |
| 133 | + REMOTE_USER_AUTHENTICATION: True |
| 134 | + - name: Django tests last main |
| 135 | + working-directory: ./openimis |
| 136 | + run: | |
| 137 | + python -V |
| 138 | + ls -l |
| 139 | + cd openIMIS |
| 140 | + python manage.py migrate |
| 141 | + python init_test_db.py | grep . | uniq -c |
| 142 | + python manage.py test --keepdb $(jq -r '(.modules[]|.name)' ../openimis.json) |
| 143 | + env: |
| 144 | + SECRET_KEY: secret |
| 145 | + DEBUG: true |
| 146 | + #DJANGO_SETTINGS_MODULE: hat.settings |
| 147 | + DB_HOST: localhost |
| 148 | + DB_PORT: 1433 |
| 149 | + DB_NAME: imis_main |
| 150 | + DB_USER: sa |
| 151 | + DB_PASSWORD: GitHub999 |
| 152 | + #DEV_SERVER: true |
| 153 | + SITE_ROOT: api |
| 154 | + REMOTE_USER_AUTHENTICATION: True |
0 commit comments