Skip to content

Commit

Permalink
feat(test): add test on GitHub actions
Browse files Browse the repository at this point in the history
feat(test): test with 172.17.0.1 postgres host

feat(test): call pytest with python

feat(test): test with GitHub action for coverage
  • Loading branch information
jmkerloch committed Feb 22, 2023
1 parent d52058d commit 86f7fed
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 0 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@

name: Unit tests

on:
pull_request:
paths:
- ".github/workflows/unit-test.yml"
- "**/*.py"

permissions:
contents: read
pull-requests: write

env:
POSTGRES_VERSION: "15"
POSTGIS_VERSION: "3.0"
POSTGRES_DB: ign
POSTGRES_USER: ign
POSTGRES_PASSWORD: ign
POSTGRES_HOST: "172.17.0.1"

jobs:
test:
name: Run unit tests
runs-on: ubuntu-latest

container: 'ghcr.io/ignf/route-graph-generator:develop'

services:
postgis:
image: postgis/postgis # unable to handle var in image name. Was: "postgis/postgis:${POSTGRES_VERSION}-${POSTGIS_VERSION}-alpine"
env:
POSTGRES_DB: ign # mandatory duplicate
POSTGRES_USER: ign # mandatory duplicate
POSTGRES_PASSWORD: ign # mandatory duplicate
ports:
# Maps tcp port 5555 on service container to the host
- 5555:5432

steps:

- uses: actions/checkout@v3

- name: Install test dependencies
run: |
pip install -r requirements/testing.txt
- name: Run test
run: |
python -m pytest
- name: Get Coverage
uses: orgoro/coverage@v3
with:
coverageFile: coverage.xml
token: ${{ secrets.GITHUB_TOKEN }}

3 changes: 3 additions & 0 deletions requirements/testing.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Testing dependencies
# --------------------
pytest-cov>=4,<5
31 changes: 31 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# -- Tests ----------------------------------------------
[tool:pytest]
addopts =
--junitxml=junit/test-results.xml
--cov-config=setup.cfg
--cov=r2gg
--cov-report=html
--cov-report=term
--cov-report=xml
--ignore=tests/_wip/
junit_family = xunit2
norecursedirs = .* build dev development dist docs CVS fixtures _darcs {arch} *.egg venv _wip
python_files = test_*.py
testpaths = tests

[coverage:run]
branch = True
omit =
.venv/*
docs/*
*tests*

[coverage:report]
exclude_lines =
if self.debug:
pragma: no cover
raise NotImplementedError
if __name__ == .__main__.:

ignore_errors = True
show_missing = True

0 comments on commit 86f7fed

Please sign in to comment.