-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CI Test Github Actions workflow (#2102)
* Add CI Test Github Actions workflow * Ignore warnings raised by Python Bandit * Add concurreny settings * Add `--parallel` arguement to Django test runner * Remove if statement on `Install pip requirements` step * Rename `.travis.yml` to `.travis.yml.disabled` * Remove migrate command * Rename `test` to `github-action-ci`
- Loading branch information
Showing
3 changed files
with
143 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
name: CI | ||
on: | ||
- push | ||
- pull_request | ||
concurrency: | ||
group: ${{ github.head_ref }}-${{ github.event }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
github-action-ci: | ||
runs-on: ubuntu-20.04 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- testfolder: "onadata/libs onadata/apps/main onadata/apps/restservice onadata/apps/sms_support onadata/apps/viewer onadata/apps/messaging" | ||
- testfolder: "onadata/apps/api onadata/apps/logger" | ||
services: | ||
postgres: | ||
image: postgis/postgis:9.6-3.1 | ||
env: | ||
POSTGRES_PASSWORD: onadata | ||
POSTGRES_DB: onadata | ||
POSTGRES_USER: onadata | ||
ports: | ||
- 5432:5432 | ||
# Set health checks to wait until postgres has started | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup Java | ||
uses: actions/setup-java@v2 | ||
with: | ||
distribution: 'adopt' | ||
java-version: '8' | ||
|
||
- name: Setup python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.6 | ||
architecture: 'x64' | ||
|
||
- name: Get pip cache dir | ||
id: pip-cache | ||
run: | | ||
echo "::set-output name=dir::$(pip cache dir)" | ||
- name: Cache pip | ||
uses: actions/cache@v2 | ||
id: cache-pip | ||
with: | ||
path: ${{ steps.pip-cache.outputs.dir }} | ||
key: ${{ runner.os }}-pip-${{ hashFiles('requirements/base.pip') }} | ||
|
||
- name: Install Pip requirements | ||
run: | | ||
pip install -U pip | ||
pip install -r requirements/base.pip | ||
pip install flake8 | ||
- name: Install APT requirements | ||
run: | | ||
sudo apt-get install -y --no-install-recommends libjpeg-dev zlib1g-dev software-properties-common ghostscript libxslt1-dev binutils libproj-dev gdal-bin memcached libmemcached-dev | ||
sudo rm -rf /var/lib/apt/lists/* | ||
- name: Run tests | ||
run: | | ||
python manage.py test ${{ matrix.testfolder }} --noinput --settings=onadata.settings.github_actions_test --verbosity=2 --parallel=4 |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# flake8: noqa | ||
# this preset is used for automated testing of onadata | ||
from __future__ import absolute_import | ||
|
||
from .common import * # nopep8 | ||
|
||
# database settings | ||
DATABASES = { | ||
'default': { | ||
'ENGINE': 'django.contrib.gis.db.backends.postgis', | ||
'NAME': 'onadata', | ||
'USER': 'onadata', | ||
'PASSWORD': 'onadata', | ||
'HOST': 'localhost' | ||
} | ||
} | ||
|
||
SLAVE_DATABASES = [] | ||
|
||
SECRET_KEY = 'mlfs33^s1l4xf6a36$0#j%dd*sisfoi&)&4s-v=91#^l01v)*j' # nosec | ||
|
||
JWT_SECRET_KEY = 'thesecretkey' # nosec | ||
JWT_ALGORITHM = 'HS256' | ||
|
||
if len(sys.argv) >= 2 and (sys.argv[1] == "test" or sys.argv[1] == "test_all"): | ||
# This trick works only when we run tests from the command line. | ||
TESTING_MODE = True | ||
else: | ||
TESTING_MODE = False | ||
|
||
if TESTING_MODE: | ||
MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'test_media/') | ||
subprocess.call(["rm", "-r", MEDIA_ROOT]) # nosec | ||
# need to have CELERY_TASK_ALWAYS_EAGER True and BROKER_BACKEND as memory | ||
# to run tasks immediately while testing | ||
CELERY_BROKER_URL = "memory://" | ||
CELERY_TASK_ALWAYS_EAGER = True | ||
CELERY_RESULT_BACKEND = 'cache' | ||
CELERY_CACHE_BACKEND = 'memory' | ||
ENKETO_API_TOKEN = 'abc' # nosec | ||
ENKETO_PROTOCOL = 'https' | ||
ENKETO_URL = 'https://enketo.ona.io/' | ||
ENKETO_API_ALL_SURVEY_LINKS_PATH = '/api_v2/survey/all' | ||
ENKETO_API_INSTANCE_PATH = '/api_v1/instance' | ||
ENKETO_SINGLE_SUBMIT_PATH = '/api/v2/survey/single/once' | ||
ENKETO_API_INSTANCE_IFRAME_URL = ENKETO_URL + "api_v1/instance/iframe" | ||
else: | ||
MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media/') | ||
|
||
PASSWORD_HASHERS = ( | ||
'django.contrib.auth.hashers.MD5PasswordHasher', | ||
) | ||
|
||
DEBUG = False | ||
TEMPLATES[0]['OPTIONS']['debug'] = DEBUG | ||
MIDDLEWARE_CLASSES = ( | ||
'django.middleware.common.CommonMiddleware', | ||
'django.contrib.sessions.middleware.SessionMiddleware', | ||
# 'django.middleware.locale.LocaleMiddleware', | ||
'django.middleware.csrf.CsrfViewMiddleware', | ||
'django.contrib.auth.middleware.AuthenticationMiddleware', | ||
'django.contrib.messages.middleware.MessageMiddleware', | ||
'onadata.libs.utils.middleware.HTTPResponseNotAllowedMiddleware', | ||
) | ||
|
||
VERIFIED_KEY_TEXT = 'ALREADY_ACTIVATED' | ||
|
||
ODK_TOKEN_FERNET_KEY = 'ROsB4T8s1rCJskAdgpTQEKfH2x2K_EX_YBi3UFyoYng=' # nosec | ||
OPENID_CONNECT_PROVIDERS = {} |