-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(test): add test on GitHub actions
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
Showing
3 changed files
with
91 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,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 }} | ||
|
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,3 @@ | ||
# Testing dependencies | ||
# -------------------- | ||
pytest-cov>=4,<5 |
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,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 |