This repo is a template for Python applications
pyenv updatepyenv install <python version number>pyenv virtualenv <python version number> <virtual environment name>pyenv activate <virtual environment name>pyenv deactivatepyenv local <python version number>/envs/<virtual environment name>to create.python-version- Use
.python-versioncontaining your virtual environment name to automatically load your python virtual environment
- Install packages from
pyproject.toml:poetry install --no-root - Add new packages:
poetry add <python package>- Use
--group devconfig to add to dev group
- Use
- Update to latest packages:
poetry update
- Uncomment
sonar-project.properties - Adjust config values for your repo
- Make sure
SONAR_TOKENenvironment variable is set - Make sure
docker-compose.yamlfile contains the correct paths to the code- Run sonar-scanner docker image locally:
docker-compose run sonar-scanner-cloud
- Run sonar-scanner docker image locally:
- The
./bin/sonarscript will run thesonar-scannertool locally
- Install pre-commit hooks:
pre-commit install --hook-type pre-commit --hook-type pre-push - Make any updates to
.pre-commit-config.yaml- Make sure the
INSTALL_PYTHONvariable is correct which contains the path to your python virtual environment - Run
pre-commit autoupdateto update all the package library versions
- Make sure the
- Update
bin/testfor running tests and report generation- Especially the workaround for resolving report paths for sonar-scanner docker image
- Alternatively, run reports manually
- HTML report:
pytest -v --cov=. --cov-branch --cov-report html ./tests - XML report (for SonarCloud):
pytest -v cov=. --cov-branch=xml:coverage/coverage.xml ./tests
- HTML report:
- If no unit tests are found, pytest will return an exit code status of
5- Use
--no-verifyif pushing changes and we have no unit tests to run yet
- Use
- Make sure paths in
.github/dependabot.ymlare correct - Check config in repo settings
- Update
.github/workflows/build.yamlas needed - You can also disable the workflow in the Actions tab