Skip to content

Commit

Permalink
init commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Friskes committed Jan 18, 2025
0 parents commit 9f42855
Show file tree
Hide file tree
Showing 8 changed files with 627 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# http://editorconfig.org

# EditorConfig помогает поддерживать согласованные стили кодирования для нескольких разработчиков,
# работающих над одним проектом в различных редакторах и IDE.

root = true

[*]
charset = utf-8 # Кодировка файлов по умолчанию
# end_of_line = lf # Последовательность конца строки для файлов по умолчанию
indent_style = space # Стиль отступов в файлах по умолчанию
insert_final_newline = true # Автоматически добавлять пустую строку в конце файла
trim_trailing_whitespace = true # Автоматически убирать не используемые пробелы в конце строк

[*.py]
profile = black
indent_size = 4
max_line_length = 105

[*.{yml,yaml}]
indent_size = 2

[*.json]
indent_size = 4
insert_final_newline = ignore

[*.{html,md}]
indent_size = 4

[*.md]
trim_trailing_whitespace = false

[Makefile]
indent_style = tab
151 changes: 151 additions & 0 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
# For more information see: https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/

name: Publish Python 🐍 distribution 📦 to PyPI

# Build on every branch push, tag push, and pull request change
on:
push:
branches:
- main
tags:
- v*
pull_request:

jobs:
test:
name: Test (💻 ${{ matrix.platform }}, 🐍 ${{ matrix.python-version }})
strategy:
fail-fast: false
# max-parallel: 5
matrix:
python-version: ['3.10', '3.11', '3.12', '3.13']
platform: [
ubuntu-latest,
macos-latest,
windows-latest,
]

runs-on: ${{ matrix.platform }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Upgrade pip
run: |
python -m pip install --upgrade pip
- name: Install dependencies with optional
run: |
python -m pip install .[ci]
- name: Run lint
run: |
python -m ruff check --fix
- name: Run format
run: |
python -m ruff format
- name: Run mypy
run: |
python -m mypy
- name: Run pytest with coverage
run: |
python -m pytest --cov
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4.0.1
with:
token: ${{ secrets.CODECOV_TOKEN }}

build:
name: Build distribution 📦
needs:
- test
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"

- name: Install pypa/build
run: >-
python3 -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: python3 -m build

- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/

publish-to-pypi:
name: >-
Publish Python 🐍 distribution 📦 to PyPI
# only publish to PyPI on release with tag by repo owner
if: github.repository_owner == 'Friskes' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')

needs:
- build
runs-on: ubuntu-latest

environment:
name: pypi
url: https://pypi.org/p/loadnsi

permissions:
id-token: write

steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/

- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

# publish-to-testpypi:
# name: Publish Python 🐍 distribution 📦 to TestPyPI

# if: github.repository_owner == 'Friskes' && github.event_name == 'push'

# needs:
# - build
# runs-on: ubuntu-latest

# environment:
# name: testpypi
# url: https://test.pypi.org/p/loadnsi

# permissions:
# id-token: write

# steps:
# - name: Download all the dists
# uses: actions/download-artifact@v4
# with:
# name: python-package-distributions
# path: dist/

# - name: Publish distribution 📦 to TestPyPI
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# repository-url: https://test.pypi.org/legacy/
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
*.pyc
*.db
*~

build/
dist/
venv/
*.egg-info/

!.gitignore

__pycache__
.git
trash
.pytest_cache
.ruff_cache
.mypy_cache
.coverage
htmlcov
.vscode
.env
43 changes: 43 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# https://githooks.com/
# https://verdantfox.com/blog/how-to-use-git-pre-commit-hooks-the-hard-way-and-the-easy-way
# https://docs.astral.sh/ruff/integrations/
# https://pre-commit.com/

# How to use it?
# pre-commit run # Run the pre-commit check manually.
# pre-commit install # Create a file in the directory to run automatically on commit: .git/hooks/pre-commit
# pre-commit uninstall # Delete a file in the directory to disable automatic startup on commit.
# git commit --no-verify -m "msg" # Disable startup for this commit (--no-verify OR -n)

repos:
- repo: /~https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-merge-conflict
- id: check-case-conflict
- id: check-toml
- id: debug-statements
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace

- repo: /~https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
- id: codespell
additional_dependencies:
- tomli

- repo: /~https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.8.0'
hooks:
- id: ruff
name: Check the codebase using the ruff linter.
args: [
--fix,
--quiet,
# --silent,
]

- id: ruff-format
name: Check the codebase using the ruff formatter.
90 changes: 90 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Contribution Guide 📖

> First off, thanks for taking the time to contribute! 😇
Contributions include but are not restricted to:
- Reporting bugs
- Contributing to code
- Writing tests
- Writing documentation

## A recommended flow of contributing to an Open Source project

1. First, [fork](/~https://github.com/Friskes/loadnsi/fork) this [project](/~https://github.com/Friskes/loadnsi) to your own namespace using the fork button at the top right of the repository page.

2. Clone your fork repository to local:
```bash
git clone /~https://github.com/YOURNAME/loadnsi.git
```

3. Add the fork as a new remote:
```bash
git remote add fork /~https://github.com/YOURNAME/loadnsi.git
git fetch fork
```

## Local development

> We recommend working in a [virtual environment](https://docs.python.org/3/tutorial/venv.html). Feel free to create a virtual environment with either the venv module or the virtualenv tool. For example:

1. Create virtual environment
```bash
python -m venv venv
. venv/bin/activate # linux
venv/Scripts/activate # windows
```

2. Install development dependencies
```bash
pip install ."[dev]" # linux
pip install .[dev] # windows
```

3. Install [pre-commit](https://pre-commit.com/)
```bash
pre-commit install
```

4. (Optional) Run `pre-commit run --all-files` to run linters and formatters.
> This step is optional and will be executed automatically by git before you make a commit, but you may want to run it manually in order to apply fixes.

#### Now, all dependencies are installed into the Python environment you chose, which will be used for development after this point 🎉.

## Making changes to the project

> Don't modify code on the main branch, the main branch should always keep track of origin/main 💡.
1. (Optional) To update main branch to date:
```bash
git pull origin main
# In rare cases that your local main branch diverges from the remote main:
git fetch origin && git reset --hard main
```
2. Create a new branch based on the up-to-date main branch for new patches.
> Code should be [Pythonic and zen](https://peps.python.org/pep-0020/)
- All functions, methods, classes, and attributes should be documented with a docstring. We use the [Google docstring style](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html).
> If you come across a function or method that doesn't conform to this standard, please update it as you go

- Writing and running tests
- Tests are contained within the `tests` directory, and follow the same directory structure as the `loadnsi` module. If you are adding a test case, it should be located within the correct submodule of `tests`. E.g., tests for `loadnsi/core.py` reside in `tests/test_core.py`.

3. Make your changes

4. Make sure that nothing is broken after making changes and all tests are checked.
```bash
pytest
```
> The test suite is still simple and needs expansion! Please help write more test cases.

5. Commit your changes to git 📝. We follow [conventional commits](https://www.conventionalcommits.org/) which are enforced using a pre-commit hook.

6. Push the changes to your fork

7. Open a [pull request](https://docs.github.com/en/pull-requests) 📥. *(using the `pull request` button at the top right of the repository page)*. Give the pull request a descriptive title indicating what it changes. The style of the PR title should also follow [conventional commits](https://www.conventionalcommits.org/).

8. Go to the [Release Action](/~https://github.com/Friskes/loadnsi/actions/workflows/publish-to-pypi.yml) and make sure that the workflow was successful ✅.

9. Wait until the pull request is accepted by the repository owner ⏳.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2025 Friskes

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading

0 comments on commit 9f42855

Please sign in to comment.