Skip to content

Commit

Permalink
Merge pull request #1249 from gboeing/tests
Browse files Browse the repository at this point in the history
streamline tests
  • Loading branch information
gboeing authored Dec 10, 2024
2 parents bffcba2 + 6c46a34 commit 4ac5752
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 103 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ jobs:
SKIP: no-commit-to-branch

- name: Test docs build
run: make -C ./docs html SPHINXOPTS="-E -W --keep-going"
run: python -m sphinx -E -W --keep-going -b html ./docs/source ./docs/build/html

- name: Test code and coverage
run: pytest --verbose --maxfail=1 --typeguard-packages=osmnx --cov=osmnx --cov-report=xml
run: python -m pytest --verbose --maxfail=1 --typeguard-packages=osmnx --cov=osmnx --cov-report=xml

- name: Upload coverage report
uses: codecov/codecov-action@v5
Expand Down
27 changes: 8 additions & 19 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,27 @@
# OSMnx tests

First, ensure that you have installed the necessary [dependencies](../environments/tests/env-ci.yml) for the test suite. Then use the repository's [pre-commit hooks](../.pre-commit-config.yaml) and the scripts in this folder to:

- format the code and docstrings per the project's style
- lint the code and docstrings
- type check the code
- run tests and coverage

Read more about the project's standards in the [contributing guidelines](../CONTRIBUTING.md).
Read more about the project's standards in the [contributing guidelines](../CONTRIBUTING.md) and ensure that you have installed the necessary [dependencies](../environments/tests/env-ci.yml) for the test suite.

## Code format

Format the code and sort imports per the project's style by running (from the repository root):
Format the code per the project's style by running the pre-commit hooks:

```shell
bash ./tests/format.sh
pre-commit install
pre-commit run -a
```

## Run tests

Lint, type check, and test the code/docstrings by running (from the repository root):
Run the test suite locally by running (from the repository root):

```shell
pre-commit install
bash ./tests/lint_test.sh
```

## Continuous integration

Pull requests trigger continuous integration tests via GitHub Actions. See the [configuration](../.github/workflows/ci.yml). This includes the following steps:
Pull requests trigger continuous integration tests via GitHub Actions (see [workflow](../.github/workflows/ci.yml)), including the following steps:

- build the docs
- check code formatting
Expand All @@ -38,10 +31,6 @@ Pull requests trigger continuous integration tests via GitHub Actions. See the [

## Releases

To package and release a new version, update `CHANGELOG.md` and edit the version number in `osmnx/_version.py`. If necessary, update the dates in `LICENSE.txt` and `docs/source/conf.py` and the dependency versions in `pyproject.toml`. Then change directories to the repository's root and run:

```shell
bash -i ./tests/release.sh
```
To publish a new version, update `CHANGELOG.md` and edit the version number in `osmnx/_version.py`. If necessary, update the dates in `LICENSE.txt` and `docs/source/conf.py` and the dependency versions in `pyproject.toml`. Then tag the repository with its new semantic version, like `v1.2.3`.

This will tag the repository with the new version number, upload the PyPI distribution, and update the conda-forge feedstock. Then, open a pull request at the [feedstock](https://github.com/conda-forge/osmnx-feedstock) to release on conda-forge. Finally, when the new version is available on conda-forge, update the [Docker image](../environments/docker) and the OSMnx [Examples Gallery](https://github.com/gboeing/osmnx-examples) to use the new version.
Pushing the tags will trigger Github Actions to publish the distribution to PyPI (see [workflow](../.github/workflows/build-publish-pypi.yml)) and publish a new image to Docker Hub (see [workflow](../.github/workflows/build-publish-docker.yml)). The `regro-cf-autotick-bot` will open a pull request to update the conda-forge [feedstock](https://github.com/conda-forge/osmnx-feedstock): merge that PR to publish the distribution on conda-forge. Finally, update the [Examples Gallery](https://github.com/gboeing/osmnx-examples) to use the new version.
3 changes: 0 additions & 3 deletions tests/format.sh

This file was deleted.

25 changes: 14 additions & 11 deletions tests/lint_test.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
#!/bin/bash
set -e # exit on error
set -e

# delete temp files and folders
rm -r -f .pytest_cache .temp ./dist/ ./docs/build osmnx/__pycache__ tests/__pycache__
find . -type f -name "*.vrt" -delete
find . -type f -name ".coverage*" -delete
rm -r -f ./.coverage* ./.pytest_cache ./.temp ./dist ./docs/build ./*/__pycache__

# lint
# run the pre-commit hooks for linting/formatting
pre-commit run --all-files

# build the docs
make -C ./docs html SPHINXOPTS="-E -W --keep-going"
# build and validate the package
python -m validate_pyproject ./pyproject.toml
python -m hatch build --clean
python -m twine check --strict ./dist/*

# build the docs and test that links are alive
python -m sphinx -E -W --keep-going -b html ./docs/source ./docs/build/html
python -m sphinx -E -W --keep-going -b linkcheck ./docs/source ./docs/build/linkcheck

# run the tests and report the test coverage
pytest --verbose --maxfail=1 --typeguard-packages=osmnx --cov=osmnx --cov-report=term-missing:skip-covered
python -m pytest --verbose --maxfail=1 --typeguard-packages=osmnx --cov=osmnx --cov-report=term-missing:skip-covered

# delete temp files and folders
rm -r -f .pytest_cache .temp ./dist/ ./docs/build osmnx/__pycache__ tests/__pycache__
find . -type f -name "*.vrt" -delete
find . -type f -name ".coverage*" -delete
sleep 1
rm -r -f ./.coverage* ./.pytest_cache ./.temp ./dist ./docs/build ./*/__pycache__
5 changes: 5 additions & 0 deletions tests/git_repack.sh → tests/prune.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#!/bin/bash
# prune conda, docker, and git
set -e
eval "$(conda shell.bash hook)"
conda activate base
conda clean --all --yes
docker image prune -af && docker system prune -af && docker volume prune -af
git remote prune origin
git repack -a -d -f --depth=250 --window=250
Expand Down
68 changes: 0 additions & 68 deletions tests/release.sh

This file was deleted.

0 comments on commit 4ac5752

Please sign in to comment.