Skip to content

Commit

Permalink
Merge pull request #2 from bosenqu/update-readme
Browse files Browse the repository at this point in the history
Initialize contents in README.md and add config for isort and ruff formatter
  • Loading branch information
bosenqu authored Dec 28, 2023
2 parents a6fb5bc + 169a3bd commit 8be8993
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ test-ci:
# Run isort, ruff, and reformat-gherkin formatter
.PHONNY: format
format:
$(PYTHON) -m isort src tests
$(PYTHON) -m isort .
$(PYTHON) -m ruff format .
$(VENV)/bin/reformat-gherkin tests/features

Expand All @@ -67,9 +67,9 @@ lint:
# Run make lint with more verbose messages
.PHONNY: lint-ci
lint-ci:
$(PYTHON) -m mypy -v .
$(PYTHON) -m ruff check -v .
$(VENV)/bin/reformat-gherkin --check tests/features
$(PYTHON) -m mypy -v .

# Clean project
.PHONNY: clean
Expand Down
70 changes: 69 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,70 @@
[![Python 3.8](https://img.shields.io/badge/python-3.8-blue.svg)](https://www.python.org/downloads/release/python-380/)
[![Actions status](https://github.com/bosenqu/hello-world-python/actions/workflows/ci.yml/badge.svg)](https://github.com/bosenqu/hello-world-python/actions)
[![codecov](https://codecov.io/gh/bosenqu/hello-world-python/graph/badge.svg?token=4LJAVKJ4VM)](https://codecov.io/gh/bosenqu/hello-world-python)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)

# hello-world-python
Hello world python project
Template code for python project.

## Virtual Environment & Dependency Management

### Virtual environment
In order to setup python virtual environment, run:
```
make setup
```

### Dependency management
The code dependency is listed in `requirements.in` and dev dependency is specified under the `project.optional-dependencies` section in `pyproject.toml`. Note that `requirements.txt` and `reqruiements-dev.txt` are autogenerated by `pip-compile` with versions pinned. For more information, visit https://pypi.org/project/pip-tools/.

Configs for `pip-compile` can be found under the `tool.pip-tools` section in `pyproject.toml`.

In order to regenerate `requirements.txt` and `reqruiements-dev.txt`, run:
```
make compile-dependency
```

In order to install dependency, run:
```
make install # install only project dependency
make install-dev # install both project and dev dependency
```

## Testing
[pytest](https://pypi.org/project/pytest/) is used for unit testing and [behave](https://pypi.org/project/behave/) is used for intergration testing. All tests are located in the `tests/` folder.

For CI runs, [coverage](https://pypi.org/project/coverage/) is used to collect code coverage. [JUnit XML reports](https://www.ibm.com/docs/en/developer-for-zos/14.1?topic=formats-junit-xml-format) are also generated. All reports are located under the `reports/` folder.

Configs for pytest can be found under the `tool.pytest.ini_options` section in `pyproject.toml`. Configs for behave can be found in `behave.ini`. Configs for coverage can be found under the `tool.coverage.run` section in `pyproject.toml`.

In order to run all tests, run:
```
make test # run all tests
make test-ci # run all tests, and collect test (junit xml) and coverage (cobertura xml) reports
```

## Formatting & Linting

### Formatting
[isort](https://pypi.org/project/isort/) and [ruff](https://pypi.org/project/ruff/) is used to format code. [reformat-gherkin](https://pypi.org/project/reformat-gherkin/) is used to format `.feature` files.

Configs for isort can be found under the `tool.isort` section in `pyproject.toml`. Configs for ruff formatter can be found under the `tool.ruff.format` section in `pyproject.toml`.

In order to run all formatter, run:
```
make format
```

### Linting
[mypy](https://pypi.org/project/mypy/) is used to perform type checking.

[ruff](https://pypi.org/project/ruff/) is used to perform code format checks. [reformat-gherkin](https://pypi.org/project/reformat-gherkin/) is used to perform format checks on `.feature` files.

Configs for mypy can be found under the `tool.mypy` section in `pyproject.toml`. Configs for ruff linter can be found under the `tool.ruff` section in `pyproject.toml`.

In order to run all linting checks, run:
```
make lint # run all linting checks
make lint-ci # run all linting checks with more verbose messages
```
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ strict = true

[tool.isort]
profile = "black"
src_paths = ["src", "test"]

[tool.ruff]
line-length = 120
Expand All @@ -54,3 +55,5 @@ select = [
"Q", # flake8-quotes
"UP", # pyupgrade
]

[tool.ruff.format]

0 comments on commit 8be8993

Please sign in to comment.