diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dd00555..81df359 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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 @@ -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: ./ diff --git a/.pylintrc b/.pylintrc index b846880..7b48d65 100644 --- a/.pylintrc +++ b/.pylintrc @@ -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. @@ -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 diff --git a/ci.env b/ci.env new file mode 100644 index 0000000..7f8c381 --- /dev/null +++ b/ci.env @@ -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 \ No newline at end of file