Skip to content

Commit

Permalink
gh-60: Add postgresql setup to CI
Browse files Browse the repository at this point in the history
  • Loading branch information
BharathKumarRavichandran committed Oct 31, 2023
1 parent 7ff518b commit a7cc679
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 3 deletions.
36 changes: 35 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ on:
pull_request:

jobs:
setup-postgresql:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up PostgreSQL
run: |
source ci.env
docker run -d --name postgres -e POSTGRES_PASSWORD=$POSTGRES_PASSWORD -p $POSTGRES_PORT:5432 postgres:latest
lint:
name: lint
runs-on: ubuntu-latest
Expand All @@ -17,8 +27,10 @@ jobs:
- run: pip install pylint
- run: pylint ./app

tests:
unit-test:
name: Unit Tests
runs-on: ubuntu-latest
needs: setup-postgresql
steps:
- name: Checkout code
uses: actions/checkout@v2
Expand All @@ -32,10 +44,32 @@ jobs:
working-directory: ./
- name: Run unit tests with code coverage
run: |
source ci.env
export DATABASE_URL_TEST="postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}"
echo $DATABASE_URL_TEST
coverage run -m unittest discover -s tests
coverage report -m --fail-under=90
working-directory: ./

integration-test:
name: Behave Tests
runs-on: ubuntu-latest
needs: setup-postgresql
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: 3.10.12
- name: Install dependencies
run: |
pip install -r requirements.txt
working-directory: ./
- name: Run behave tests
run: |
source ci.env
export DATABASE_URL_TEST="postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}"
echo $DATABASE_URL_TEST
behave
working-directory: ./
4 changes: 2 additions & 2 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ extension-pkg-whitelist=flask
fail-on=

# Specify a score threshold under which the program will exit with error.
fail-under=10
fail-under=7

# Interpret the stdin as a python script, whose filename needs to be passed as
# the module_or_package argument.
Expand Down Expand Up @@ -67,7 +67,7 @@ ignored-modules=

# Python code to execute, usually for sys.path manipulation such as
# pygtk.require().
#init-hook=
init-hook='import sys; sys.path.append("your_project_directory")'

# Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the
# number of processors available to use, and will cap the count on Windows to
Expand Down
9 changes: 9 additions & 0 deletions ci.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FLASK_APP=main
FLASK_ENV=test
FLASK_DEBUG=0
FLASK_SECRET_KEY=5cbda80a3828da43d9eaaf3728d9801d32e468038cccf3d7d911a24d30f80570
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_DB=ccems-test
POSTGRES_USER=postgres
POSTGRES_PASSWORD=zJc2B%SDoUz%Uvrrg

0 comments on commit a7cc679

Please sign in to comment.