Skip to content

Commit

Permalink
Merge 9f6b094 into f05a7f8
Browse files Browse the repository at this point in the history
  • Loading branch information
mcarans committed Jun 26, 2023
2 parents f05a7f8 + 9f6b094 commit 403f3fa
Show file tree
Hide file tree
Showing 19 changed files with 344 additions and 203 deletions.
2 changes: 2 additions & 0 deletions .config/black.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[tool.black]
line-length = 79
17 changes: 17 additions & 0 deletions .config/coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[run]
source = src

omit = */_version.py

[report]
exclude_also =
from ._version
def __repr__
if self.debug:
if settings.DEBUG
raise AssertionError
raise NotImplementedError
if 0:
if __name__ == .__main__.:
if TYPE_CHECKING:
@(abc\.)?abstractmethod
20 changes: 20 additions & 0 deletions .config/pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
default_language_version:
python: python3.11
repos:
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
args: [--config, .config/black.toml]
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.267
hooks:
- id: ruff
args: [--config, .config/ruff.toml, --fix, --exit-non-zero-on-fix]
- repo: https://github.com/jazzband/pip-tools
rev: 6.13.0
hooks:
- id: pip-compile
name: pip-compile requirements.txt
files: pyproject.toml
args: [pyproject.toml, --resolver=backtracking, --all-extras, --upgrade, -q, -o, requirements.txt]
4 changes: 4 additions & 0 deletions .config/pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[pytest]
pythonpath = ../src
addopts = "--color=yes"
log_cli = 1
14 changes: 14 additions & 0 deletions .config/ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
line-length = 79
exclude = ["_version.py"]
ignore = [
"E501" # Line too long
]
# List of rules: https://beta.ruff.rs/docs/rules/
select = [
"E", # pycodestyle - default
"F", # pyflakes - default
"I" # isort
]

[isort]
known-local-folder = ["hdx"]
15 changes: 9 additions & 6 deletions .github/workflows/publish.yml → .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Get history and tags for SCM versioning to work
- name: Get history and tags for versioning to work
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
Expand All @@ -21,10 +21,13 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade tox-gh-actions
- name: Publish with tox and twine
pip install --upgrade hatch
- name: Build with hatch
run: |
hatch build
- name: Publish with hatch
env:
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
HATCH_INDEX_USER: ${{secrets.HATCH_INDEX_USER}}
HATCH_INDEX_AUTH: ${{secrets.HATCH_INDEX_AUTH}}
run: |
tox -e publish
hatch publish
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,23 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade tox-gh-actions
- name: Test with tox/pytest
pip install --upgrade hatch
- name: Test with hatch/pytest
run: |
tox
hatch run test:test
- name: Check styling
if: always()
run: |
hatch run lint:style
- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
junit_files: .tox/*.xml
- name: Upload Coverage Results
uses: codecov/codecov-action@v3
if: success()
junit_files: test-results.xml
- name: Publish in Coveralls
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: tests
format: lcov
61 changes: 61 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Development

## Environment

Development is currently done using Python 3.11. We recommend using a virtual
environment such as ``venv``:

python3.11 -m venv venv
source venv/bin/activate

In your virtual environment, please install all packages for
development by running:

pip install -r requirements.txt

## Pre-Commit

Also be sure to install `pre-commit`, which is run every time
you make a git commit:

pre-commit install

The configuration file for this project is in a
non-start location. Thus, you will need to edit your
`.git/hooks/pre-commit` file to reflect this. Change
the line that begins with `ARGS` to:

ARGS=(hook-impl --config=.config/pre-commit-config.yaml --hook-type=pre-commit)

With pre-commit, all code is formatted according to
[black]("https://github.com/psf/black") and
[ruff]("https://github.com/charliermarsh/ruff") guidelines.

To check if your changes pass pre-commit without committing, run:

pre-commit run --all-files --config=.config/pre-commit-config.yaml

## Testing

To run the tests and view coverage, execute:

pytest -c .config/pytest.ini --cov hdx --cov-config .config/coveragerc

Follow the example set out already in ``api.rst`` as you write the documentation.

## Packages

[pip-tools](https://github.com/jazzband/pip-tools) is used for
package management. If you’ve introduced a new package to the
source code (i.e.anywhere in `src/`), please add it to the
`project.dependencies` section of
`pyproject.toml` with any known version constraints.

For adding packages for testing or development, add them to
the `test` or `dev` sections under `[project.optional-dependencies]`.

Any changes to the dependencies will be automatically reflected in
`requirements.txt` with `pre-commit`, but you can re-generate
the file without committing by executing:

pre-commit run pip-compile --all-files --config=.config/pre-commit-config.yaml
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[![Build Status](https://github.com/OCHA-DAP/hdx-python-database/actions/workflows/run-python-tests.yml/badge.svg)](https://github.com/OCHA-DAP/hdx-python-database/actions/workflows/run-python-tests.yml)
[![Coverage Status](https://codecov.io/gh/OCHA-DAP/hdx-python-database/branch/main/graph/badge.svg?token=JpWZc5js4y)](https://codecov.io/gh/OCHA-DAP/hdx-python-database)
[![Build Status](https://github.com/OCHA-DAP/hdx-python-database/actions/workflows/run-python-tests.yaml/badge.svg)](https://github.com/OCHA-DAP/hdx-python-database/actions/workflows/run-python-tests.yaml)
[![Coverage Status](https://coveralls.io/repos/github/OCHA-DAP/hdx-python-database/badge.svg?branch=main&ts=1)](https://coveralls.io/github/OCHA-DAP/hdx-python-database?branch=main)[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)

Expand Down
4 changes: 2 additions & 2 deletions .readthedocs.yml → documentation/.readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ build:
jobs:
pre_build:
- pip install --upgrade mkdocs
- pip install --upgrade pydoc-markdown
- pydoc-markdown
- pip install pydoc-markdown
- pydoc-markdown documentation/pydoc-markdown.yaml
- mv docs/content/* docs
- rmdir docs/content
File renamed without changes.
29 changes: 29 additions & 0 deletions documentation/pydoc-markdown.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
loaders:
- type: python
search_path:
- ../src
packages:
- hdx.database
renderer:
type: mkdocs
output_directory: docs
mkdocs_config:
site_name: HDX Python Database
theme: readthedocs
repo_url: "https://github.com/OCHA-DAP/hdx-python-database"
markdown:
source_linker:
type: github
repo: OCHA-DAP/hdx-python-database
pages:
- title: Home
name: index
source: doc/main.md
- title: API Documentation
children:
- title: Database
contents:
- hdx.database.Database
- title: PostgreSQL specific
contents:
- hdx.database.postgresql.*

0 comments on commit 403f3fa

Please sign in to comment.