The Walkability plugin, created in cooperation with PLANUM Fallast & Partner GmbH.
To run your plugin locally requires the following setup:
- Set up the infrastructure locally in
devel
mode - Copy your .env.base_template to
.env.base
and .env_template to.env
and update them - Run
poetry run python plugin_showcase/plugin.py
To contribute, install the dependencies
poetry install
and the pre-commit hooks:
poetry run pre-commit install
To run all tests:
poetry run pytest
Some tests are ApprovalTests. Approval tests capture the output (snapshot) of a piece of code and compare it with a previously approved version of the output.
Once the output has been approved then as long as the output stays the same the test will pass. A test fails if the received output is not identical to the approved version. In that case, the difference of the received and the approved output is reported to the tester. The representation of the report can take many forms: The default is a print out of the difference to the console. You can also choose to use a diff-tool instead:
# Meld
pytest \
--approvaltests-add-reporter="meld"
# PyCharm
pytest \
--approvaltests-add-reporter="pycharm-community" \
--approvaltests-add-reporter-args="diff"
# Nvim
pytest \
-s \
--approvaltests-add-reporter="nvim" \
--approvaltests-add-reporter-args="-d"
To get a coverage report of how much of your code is run during testing, execute
poetry run pytest --ignore test/core/ --cov
.
We ignore the test/core/
folder when assessing coverage because the core tests run the whole plugin to be sure
everything successfully runs with a very basic configuration.
Yet, they don't actually test functionality and therefore artificially inflate the test coverage results.
To get a more detailed report including which lines in each file are not tested,
run poetry run pytest --ignore test/core/ --cov --cov-report term-missing
If the infrastructure is reachable you can
copy .env.base_template to .env.base
and then run
docker build --secret id=CI_JOB_TOKEN . --tag heigit/ca-walkability:devel
docker run --env-file .env.base --network=host heigit/ca-walkability:devel
Make sure your git access token is copied to the text-file named CI_JOB_TOKEN
that is mounted to the container build
process as secret.
To deploy this plugin to the central docker repository run
docker build --secret id=CI_JOB_TOKEN . --tag heigit/ca-walkability:devel
docker image push heigit/ca-walkability:devel
To mimic the build behaviour of the CI you have to add --build-arg CI_COMMIT_SHORT_SHA=$(git rev-parse --short HEAD)
to the above command.