Skip to content

Commit

Permalink
Merge pull request #38 from Zuehlke/dev_tools
Browse files Browse the repository at this point in the history
Dev tools
  • Loading branch information
silvanmelchior authored Jan 7, 2022
2 parents ac0aead + ecdef0e commit 90993f8
Show file tree
Hide file tree
Showing 38 changed files with 1,440 additions and 440 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: coverage
on: [ pull_request ]
jobs:
run-coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ./.github/workflows/setup-env
with:
python-version: "3.10"
- name: run coverage
run: |
coverage run -m pytest
coverage report --fail-under=100
13 changes: 13 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: format
on: [ pull_request ]
jobs:
run-format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ./.github/workflows/setup-env
with:
python-version: "3.10"
- name: run black
run: |
black --check .
13 changes: 13 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: lint
on: [ pull_request ]
jobs:
run-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ./.github/workflows/setup-env
with:
python-version: "3.10"
- name: run pylint
run: |
pylint confz
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: ./.github/workflows/setup-env
with:
python-version: "3.10"
- name: install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
poetry config virtualenvs.create false
poetry install
- name: build and publish
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/setup-env/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: "Setup environment"
description: "Sets up python and installs all dependencies."
inputs:
python-version:
description: "Version of python"
required: true
runs:
using: "composite"
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ inputs.python-version }}
- name: install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
poetry config virtualenvs.create false
poetry install
shell: bash
16 changes: 16 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: test
on: [ pull_request ]
jobs:
run-test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]
steps:
- uses: actions/checkout@v2
- uses: ./.github/workflows/setup-env
with:
python-version: ${{ matrix.python-version }}
- name: run pytest
run: |
pytest
22 changes: 0 additions & 22 deletions .github/workflows/tests.yaml

This file was deleted.

13 changes: 13 additions & 0 deletions .github/workflows/typecheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: typecheck
on: [ pull_request ]
jobs:
run-typecheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ./.github/workflows/setup-env
with:
python-version: "3.10"
- name: run mypy
run: |
mypy confz
74 changes: 52 additions & 22 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Contribution Instruction & Guidelines

Any kind of contribution to ConfZ is most welcome!

- If you have a question, please use GitHub
[discussions](https://github.com/Zuehlke/ConfZ/discussions).
- If you found a bug or have a feature request, please use GitHub
[issues](https://github.com/Zuehlke/ConfZ/issues).
- If you fixed a bug or implemented a new feature, please do a pull request. If it
is a larger change or addition, it would be great to first discuss thorugh an
[issue](https://github.com/Zuehlke/ConfZ/issues).

## Setup Repo

This repository uses [poetry](https://python-poetry.org/) for dependency management.
Expand All @@ -12,37 +22,59 @@ poetry install
in this folder.

Poetry is also used for building and publishing the library.
This is normally handled by the corresponding [github action](.github/workflows/publish.yaml),
but can also be done manually with
This is normally handled by the corresponding
[github action](github/workflows/publish.yml), but can also be done manually with

```
poetry publish --build
```

in this folder. The built package is hosted on [PyPI](https://pypi.org/project/confz/).

## Run Tests
## Development Tools

[Pytest](https://pytest.org) is used for testing the code, just run

```
pytest
```

in this folder. We strive for a coverage of 100%. To check this, run the following:

```
coverage run -m pytest
coverage report --fail-under=100
```

This repository furthermore uses [mypy](https://mypy.readthedocs.io/en/stable/) for
type checking, which can be run with the following:

```
mypy confz
```

[Pytest](https://pytest.org) is used for testing the code, together with [coverage](https://coverage.readthedocs.io).
To run all tests and build a coverage report, run
For linting, we use [pylint](https://pylint.org/), which can be run with:

```
pytest --cov=confz
pylint confz
```

in this folder. To get an in-depth analysis of the coverage, generate a report, e.g. in HTML format, with
Last but not least, we use [black](https://black.readthedocs.io/en/stable/) for
formatting. You can reformat all files with:

```
coverage html
black .
```

in this folder. This will read the _.coverage_ file and generate a report out of it.
There are GitHub actions in place for all these tools which make sure that no pull
request will be merged if any of them shows an error.

## Build Docs
## Documentation

[Sphinx](https://sphinx-doc.org/) is used for documentation, together with reST docstrings.
A corresponding github webhook triggers builds on [readthedocs](https://readthedocs.org/).
The documentation can also be built locally with
[Sphinx](https://sphinx-doc.org/) is used for documentation, together with reST
docstrings. A corresponding github webhook triggers builds on
[readthedocs](https://readthedocs.org/). The documentation can also be built locally
by running

```
make html
Expand All @@ -52,16 +84,14 @@ in the [docs](docs) folder.

## Branching & Release Strategy

The default branch is called _main_.
It contains the latest features, which would be ready for deployment.
It is not possible to push to it directly.
Instead, for every feature, a branch should be created, which will then be merged back into _main_ with a pull request.
Github is configured to run all tests when a PR is created.
The default branch is called _main_. It contains the latest features, which would be
ready for deployment. It is not possible to push to it directly. Instead, for every
feature, a branch should be created, which will then be merged back into _main_ with
a pull request. GitHub is configured to run all tests when a PR is created.

At some point, a new version can be released.
To do so, a separate PR should be opened, which increases the version number.
After merging, a release with corresponding release notes can then be generated on Github.
This also automatically triggers a deployment to PyPI.
To do so, a release with corresponding release notes can then be generated on GitHub.
This also automatically triggers a deployment to PyPI. The tag of the release should
match the version specified in [pyproject.toml](pyproject.toml).

Semantic versioning is used for releases.
Branches should be prefixed with _feature/_, _bugfix/_ or _release/_ accordingly.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# ConfZ – Pydantic Config Management

[![tests](https://github.com/Zuehlke/ConfZ/actions/workflows/tests.yaml/badge.svg)](https://github.com/Zuehlke/ConfZ/actions/workflows/tests.yaml)
[![Documentation Status](https://readthedocs.org/projects/confz/badge/?version=latest)](https://confz.readthedocs.io/en/latest/?badge=latest)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/confz)
![PyPI](https://img.shields.io/pypi/v/confz)
![PyPI - License](https://img.shields.io/pypi/l/confz)
[![test](https://github.com/Zuehlke/ConfZ/actions/workflows/test.yml/badge.svg)](https://github.com/Zuehlke/ConfZ/actions/workflows/test.yml)
[![documentation](https://readthedocs.org/projects/confz/badge/?version=latest)](https://confz.readthedocs.io/en/latest/)
[![coverage](https://img.shields.io/badge/coverage-100%25-brightgreen)](https://github.com/Zuehlke/ConfZ/actions/workflows/coverage.yml) <!-- hard-code because can not merge if below 100 -->
[![python](https://img.shields.io/pypi/pyversions/confz)](https://pypi.org/project/confz/)
[![pypi](https://img.shields.io/pypi/v/confz)](https://pypi.org/project/confz/)

`ConfZ` is a configuration management library for Python based on [pydantic](https://pydantic-docs.helpmanual.io/).
It easily allows you to
Expand Down
11 changes: 9 additions & 2 deletions confz/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
from .change import depends_on
from .confz import ConfZ
from .confz_source import ConfZSources, ConfZSource, ConfZFileSource, ConfZEnvSource, ConfZCLArgSource, FileFormat, \
ConfZDataSource
from .confz_source import (
ConfZSources,
ConfZSource,
ConfZFileSource,
ConfZEnvSource,
ConfZCLArgSource,
FileFormat,
ConfZDataSource,
)
from .validate import validate_all_configs
Loading

0 comments on commit 90993f8

Please sign in to comment.