Skip to content

Commit

Permalink
new project structure
Browse files Browse the repository at this point in the history
  • Loading branch information
leon1995 committed Dec 23, 2023
1 parent 058607f commit 6805c46
Show file tree
Hide file tree
Showing 9 changed files with 189 additions and 70 deletions.
37 changes: 19 additions & 18 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,17 @@ name: Build package
on:
workflow_call:
pull_request:
branches:
- main
- "v[0-9]+.[0-9]+.x"
types: [ opened, synchronize, reopened, ready_for_review ]

jobs:
linters:
uses: ./.github/workflows/lint.yml

build:
name: Build
runs-on: ubuntu-latest
needs: linters
permissions:
contents: write
outputs:
WHL: ${{ steps.filenames.outputs.WHL }}
TARGZ: ${{ steps.filenames.outputs.TARGZ }}

steps:
- name: Check out Git repository
Expand All @@ -27,20 +24,24 @@ jobs:
with:
python-version: "3.11"

- name: Detect release version
- name: Setup hatch
run: python -m pip install hatch

- name: Set new version
if: startsWith(github.ref, 'refs/tags/v')
run: |
echo FACTORIALHR_VERSION=${GITHUB_REF/refs\/tags\//} >> $GITHUB_ENV
- name: Install build
run: pip install build

python -m hatch version ${GITHUB_REF/refs\/tags\/v/}
- name: Build package
run: python -m build
run: python -m hatch build

- name: Archive wheel
- name: Set filenames in output
id: filenames
run: |
echo WHL=$(echo dist/*.whl) >> $GITHUB_OUTPUT
echo TARGZ=$(echo dist/*.tar.gz) >> $GITHUB_OUTPUT
- name: Archive package
uses: actions/upload-artifact@v3
with:
name: dist
path: dist/*.whl
retention-days: 1
name: distributions
path: dist
retention-days: 5
25 changes: 11 additions & 14 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
name: Lint package

on: workflow_call
on:
workflow_call:
pull_request:
types: [ opened, synchronize, reopened, ready_for_review ]

jobs:
linters:
lint:
name: Run linters
runs-on: ubuntu-latest

Expand All @@ -20,17 +23,11 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install Python dependencies
run: pip install ".[lint]"

- name: Run Black
run: black --check factorialhr

- name: Run isort
run: isort factorialhr -c

- name: Run flake8
run: flake8 factorialhr
- uses: chartboost/ruff-action@v1

- name: Run mypy
run: mypy factorialhr
uses: sasanquaneuf/mypy-github-action@releases/v1
with:
checkName: 'lint' # NOTE: this needs to be the same as the job name
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62 changes: 51 additions & 11 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,72 @@
name: Publish package to pypi
name: Publish package

on:
workflow_call:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+[ab][0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+" # normal release
- "v[0-9]+.[0-9]+.[0-9]+rc[0-9]+" # release candidate
- "v[0-9]+.[0-9]+.[0-9]+[ab][0-9]+" # alpha or beta release

jobs:
build:
permissions:
contents: write
uses: ./.github/workflows/build.yml

publish:
name: Publish
upload:
name: Upload
runs-on: ubuntu-latest
needs: build
permissions:
contents: write
outputs:
DO_GITHUB_RELEASE: ${{ steps.detect-release.outputs.DO_GITHUB_RELEASE }}

steps:
- name: Download Artifact
uses: actions/download-artifact@v3
with:
name: dist
name: distributions
path: dist/

- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
password: ${{ secrets.PYPI_API_TOKEN }}

- name: Detect release version
id: detect-release
run: |
do_github_release=$((echo "${GITHUB_REF}" | grep -Eq "^refs\/tags\/v[0-9]+\.[0-9]+\.[0-9]+(rc[0-9]+)?$") && echo 1 || echo 0)
echo DO_GITHUB_RELEASE=$do_github_release >> $GITHUB_OUTPUT
echo DO_GITHUB_RELEASE=$do_github_release
release:
name: Release
runs-on: ubuntu-latest
needs: upload
if: needs.upload.outputs.DO_GITHUB_RELEASE == '1'
permissions:
contents: write

steps:
- name: Check out Git repository
uses: actions/checkout@v3

- name: Download Build
uses: actions/download-artifact@v3
with:
name: distributions
path: dist

- name: Detect prerelease
id: detect-prerelease
run: |
do_prerelease=$((echo "${GITHUB_REF}" | grep -Eq "^refs\/tags\/v[0-9]+\.[0-9]+\.[0-9]+rc[0-9]+$") && echo 1 || echo 0)
echo DO_PRERELEASE=$do_prerelease >> $GITHUB_ENV
echo DO_PRERELEASE=$do_prerelease
- name: Attach artifacts to github release
uses: softprops/action-gh-release@v1
with:
files: |
CHANGELOG.md
dist/*
prerelease: ${{ env.DO_PRERELEASE == '1' }}
body_path: CHANGELOG.md
11 changes: 0 additions & 11 deletions factorialhr/__init__.py

This file was deleted.

123 changes: 107 additions & 16 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[build-system]
requires = ["flit_core >=3.2"]
build-backend = "flit_core.buildapi"
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "factorialhr"
dynamic = ["version"]
authors = [
{ name = "Leon Budnick", email = "y6q6ea9w@mail-proxy.org" },
]
description = "Python package for the api of FactorialHR "
description = "Python package for the api of FactorialHR"
readme = "README.md"
requires-python = ">=3.11"
classifiers = [
Expand All @@ -34,23 +34,114 @@ dependencies = [
[project.urls]
"Homepage" = "https://github.com/leon1995/factorialhr"
"Bug Tracker" = "https://github.com/leon1995/factorialhr/issues"

[project.optional-dependencies]
lint = [
'black',
'flake8',
"ruff",
'mypy',
'isort'
]

[tool.pytest.ini_options]
testpaths = "tests/"
#addopts = "--cov=fwtv --cov-report term-missing --cov-fail-under=95"
[tool.hatch.build.targets.sdist]
include = [
"src/factorialhr/**/*",
"LICENSE",
"README.md",
"pyproject.toml",
"CHANGELOG.md"
]
support-legacy = false

[tool.hatch.build.targets.wheel]
packages = ["src/factorialhr"]

[tool.hatch.version]
path = "src/factorialhr/__init__.py"

[tool.ruff]
extend-select = [# https://beta.ruff.rs/docs/settings/#extend-select
"A", # https://beta.ruff.rs/docs/rules/#flake8-builtins-a
"ANN", # https://beta.ruff.rs/docs/rules/#flake8-annotations-ann
"ARG", # https://beta.ruff.rs/docs/rules/#flake8-unused-arguments-arg
"B", # https://beta.ruff.rs/docs/rules/#flake8-bugbear-b
"BLE", # https://beta.ruff.rs/docs/rules/#flake8-blind-except-ble
"C4", # https://beta.ruff.rs/docs/rules/#flake8-comprehensions-c4
"C90", # https://beta.ruff.rs/docs/rules/#mccabe-c90
"COM", # https://beta.ruff.rs/docs/rules/#flake8-commas-com
"D", # https://beta.ruff.rs/docs/rules/#pydocstyle-d
"ERA", # https://beta.ruff.rs/docs/rules/#eradicate-era
"G", # https://beta.ruff.rs/docs/rules/#flake8-logging-format-g
"I", # https://beta.ruff.rs/docs/rules/#isort-i
"ICN", # https://beta.ruff.rs/docs/rules/#flake8-import-conventions-icn
"INP", # https://beta.ruff.rs/docs/rules/#flake8-no-pep420-inp
"ISC", # https://beta.ruff.rs/docs/rules/#flake8-implicit-str-concat-isc
"ICN", # https://beta.ruff.rs/docs/rules/#flake8-import-conventions-icn
"N", # https://beta.ruff.rs/docs/rules/#pep8-naming-n
"PGH", # https://beta.ruff.rs/docs/rules/#pygrep-hooks-pgh
"PIE", # https://beta.ruff.rs/docs/rules/#flake8-pie-pie
"PL", # https://beta.ruff.rs/docs/rules/#pylint-pl
# "PT", # https://beta.ruff.rs/docs/rules/#flake8-pytest-style-pt
"PTH", # https://beta.ruff.rs/docs/rules/#flake8-use-pathlib-pth
"PYI", # https://beta.ruff.rs/docs/rules/#flake8-pyi-pyi
"Q", # https://beta.ruff.rs/docs/rules/#flake8-quotes-q
"RET", # https://beta.ruff.rs/docs/rules/#flake8-return-ret
"RSE", # https://beta.ruff.rs/docs/rules/#flake8-raise-rse
"RUF", # https://beta.ruff.rs/docs/rules/#ruff-specific-rules-ruf
"S", # https://beta.ruff.rs/docs/rules/#flake8-bandit-s
"SIM", # https://beta.ruff.rs/docs/rules/#flake8-simplify-sim
"SLF", # https://beta.ruff.rs/docs/rules/#flake8-self-slf
"T20", # https://beta.ruff.rs/docs/rules/#flake8-print-t20
"TCH", # https://beta.ruff.rs/docs/rules/#flake8-type-checking-tch
"TID", # https://beta.ruff.rs/docs/rules/#flake8-tidy-imports-tid
"UP", # https://beta.ruff.rs/docs/rules/#pyupgrade-up
"YTT" # https://beta.ruff.rs/docs/rules/#flake8-2020-ytt
]
extend-ignore = [# https://beta.ruff.rs/docs/settings/#extend-ignore
"ANN101", # https://beta.ruff.rs/docs/rules/missing-type-self/
"ANN102", # https://beta.ruff.rs/docs/rules/missing-type-cls/
"ANN204", # https://beta.ruff.rs/docs/rules/missing-return-type-special-method/
"ANN401", # https://beta.ruff.rs/docs/rules/any-type/
"C408", # https://beta.ruff.rs/docs/rules/unnecessary-collection-call/
"C409", # https://beta.ruff.rs/docs/rules/unnecessary-literal-within-tuple-call/
"D105", # undocumented-magic-method
"D107", # undocumented-public-init
"D203", # one-blank-line-before-class
"D213", # multi-line-summary-second-line
"Q000", # https://beta.ruff.rs/docs/rules/bad-quotes-inline-string/
"S101", # https://beta.ruff.rs/docs/rules/assert/
"S311", # https://beta.ruff.rs/docs/rules/suspicious-non-cryptographic-random-usage/
"SIM102", # collapsible-if
"T201", # https://beta.ruff.rs/docs/rules/print/

]
line-length = 120 # https://beta.ruff.rs/docs/settings/#line-length
target-version = "py311" # https://beta.ruff.rs/docs/settings/#target-version
# Allow imports relative to the "src" and "test" directories.
src = ["src", "test"] # https://beta.ruff.rs/docs/settings/#src
# In addition to the standard set of exclusions, omit all tutorials and examples
extend-exclude = ["examples", "tools", "tutorial"] # https://beta.ruff.rs/docs/settings/#extend-exclude

[tool.ruff.flake8-annotations]
allow-star-arg-any = true # https://beta.ruff.rs/docs/settings/#allow-star-arg-any
suppress-none-returning = true # https://beta.ruff.rs/docs/settings/#suppress-none-returning

[tool.ruff.flake8-comprehensions]
allow-dict-calls-with-keyword-arguments = true # https://beta.ruff.rs/docs/settings/#allow-dict-calls-with-keyword-arguments

[tool.ruff.pycodestyle]
max-doc-length = 120 # https://beta.ruff.rs/docs/settings/#max-doc-length

[tool.black]
line-length = 120
[tool.ruff.per-file-ignores]
"__init__.py" = ["D104"]

[isort]
force_single_line = 1
known_localfolder = "factorialhr"
force_alphabetical_sort_within_sections = 1
profile = "black"
[tool.mypy]
python_version = "3.9" # https://mypy.readthedocs.io/en/stable/config_file.html#confval-python_version
strict = true # https://mypy.readthedocs.io/en/stable/config_file.html#confval-strict
disallow_untyped_calls = true # https://mypy.readthedocs.io/en/stable/config_file.html#confval-disallow_untyped_calls
disallow_untyped_defs = true # https://mypy.readthedocs.io/en/stable/config_file.html#confval-disallow_untyped_defs
disallow_any_generics = true # https://mypy.readthedocs.io/en/stable/config_file.html#confval-disallow_any_generics
disallow_any_unimported = true # https://mypy.readthedocs.io/en/stable/config_file.html#confval-disallow_any_unimported
warn_redundant_casts = true # https://mypy.readthedocs.io/en/stable/config_file.html#confval-warn_redundant_casts
check_untyped_defs = true # https://mypy.readthedocs.io/en/stable/config_file.html#confval-check_untyped_defs
warn_return_any = true # https://mypy.readthedocs.io/en/stable/config_file.html#confval-warn_return_any
warn_unused_configs = true # https://mypy.readthedocs.io/en/stable/config_file.html#confval-warn_unused_configs
warn_unused_ignores = true # https://mypy.readthedocs.io/en/stable/config_file.html#confval-warn_unused_ignores
1 change: 1 addition & 0 deletions src/factorialhr/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.0.0"
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 6805c46

Please sign in to comment.