Skip to content

Commit

Permalink
Merge pull request #20 from niro1987:v2
Browse files Browse the repository at this point in the history
V2
  • Loading branch information
niro1987 authored Sep 11, 2024
2 parents 5732221 + 0d8fada commit d59b822
Show file tree
Hide file tree
Showing 53 changed files with 4,021 additions and 6,489 deletions.
13 changes: 13 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM mcr.microsoft.com/devcontainers/python:1-3.12

# Uninstall pre-installed formatting and linting tools
# They would conflict with our pinned versions
RUN pipx uninstall pydocstyle \
&& pipx uninstall pycodestyle \
&& pipx uninstall mypy \
&& pipx uninstall pylint

# Install Python dependencies from requirements
WORKDIR /usr/src
COPY . .
RUN pip install -r requirements.txt -r .devcontainer/requirements-dev.txt
46 changes: 46 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"name": "Python Package Devcontainer",
"build": {
"context": "..",
"dockerfile": "./Dockerfile"
},
"customizations": {
"vscode": {
"settings": {
"python.defaultInterpreterPath": "/usr/local/bin/python",
"python.testing.pytestEnabled": false,
"python.testing.unittestEnabled": false,
"python.testing.pytestArgs": ["--no-cov"],
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"files.trimTrailingWhitespace": true,
"terminal.integrated.profiles.linux": {
"zsh": {
"path": "/usr/bin/zsh"
}
},
"terminal.integrated.defaultProfile.linux": "zsh",
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff"
}
},
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance",
"visualstudioexptteam.vscodeintellicode",
"charliermarsh.ruff",
"ms-python.pylint",
"matangover.mypy",
"redhat.vscode-yaml",
"esbenp.prettier-vscode",
"GitHub.vscode-pull-request-github",
"eamodio.gitlens",
"tamasfe.even-better-toml",
"github.vscode-github-actions"
]
}
},
"postCreateCommand": "git config --global --add safe.directory /workspaces/python-sapcommissions && pre-commit install --install-hooks",
"postStartCommand": "pip install -e ."
}
22 changes: 22 additions & 0 deletions .devcontainer/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Use this file to list development requirements for your project.

# build
setuptools>=61.0
setuptools_scm>=6.2

# pre-commit
pre-commit==3.7.0
ruff==0.3.5
codespell==2.2.6
yamllint==1.35.1

# dev
pylint==3.1.0
mypy==1.9.0

# test
coverage==7.4.4
pytest==8.1.1
pytest-cov==5.0.0
pytest-asyncio==0.23.6
aioresponses>=0.7.6
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* text eol=lf
*.py whitespace=error
18 changes: 0 additions & 18 deletions .github/labeler.yml

This file was deleted.

48 changes: 0 additions & 48 deletions .github/scripts/release.py

This file was deleted.

23 changes: 0 additions & 23 deletions .github/workflows/lint.yml

This file was deleted.

13 changes: 0 additions & 13 deletions .github/workflows/pr-labeler.yml

This file was deleted.

78 changes: 62 additions & 16 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,81 @@
name: Publish to PyPI.org
---
# This workflow will upload a Python Package using Twine
# when a release is created. 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 and TestPyPI

on:
release:
types: [published]

jobs:
pypi:
build:
name: Build distribution 📦
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/') # only publish on tag pushes
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
fetch-depth: 0
python-version: "3.11"
- name: Install pypa/build
run: >-
python3 -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: >-
python3 -m
build
--sdist
--wheel
--outdir dist/
- name: Publish distribution 📦 to Test PyPI
run: python3 -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/

publish-to-testpypi:
name: Publish Python 🐍 distribution 📦 to TestPyPI
needs:
- build
runs-on: ubuntu-latest

environment:
name: testpypi
url: https://test.pypi.org/p/python-sapcommissions

permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

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:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/

publish-to-pypi:
name: >-
Publish Python 🐍 distribution 📦 to PyPI
needs:
- publish-to-testpypi
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/python-sapcommissions
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
12 changes: 0 additions & 12 deletions .github/workflows/release.yml

This file was deleted.

4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ __pycache__/
.venv/
dist/
build/
main.py
.env
*.log
tests/deploy/
56 changes: 30 additions & 26 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
default_language_version:
python: python3.10
python: python3.12
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.5
hooks:
- id: ruff
args:
- --fix
- id: ruff-format
files: ^((src|tests)/.+)?[^/]+\.py$
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
- id: codespell
args:
- --ignore-words-list=perfors
- --skip="./.*,*.csv,*.json,*.txt,*.xml"
- --quiet-level=2
exclude_types: [csv, json, text, xml]
exclude: ^tests/fixtures/.*$
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: check-ast
Expand All @@ -17,30 +35,16 @@ repos:
args:
- --pytest-test-first
- id: no-commit-to-branch
- id: trailing-whitespace

- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
args:
- --config=tox.ini

- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
- --branch=main
- id: trailing-whitespace
- id: check-json
exclude: (.vscode|.devcontainer)
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.35.1
hooks:
- id: isort

- repo: local
- id: yamllint
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0
hooks:
- id: pylint
name: pylint
entry: .venv/Scripts/pylint.exe
language: system
types: [python]
require_serial: true
- id: prettier
10 changes: 10 additions & 0 deletions .pypirc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[distutils]
index-servers =
pypi
testpypi

[pypi]
repository = https://upload.pypi.org/legacy/

[testpypi]
repository = https://test.pypi.org/legacy/
Loading

0 comments on commit d59b822

Please sign in to comment.