-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* git ignore file * pip tools config for generating lock files * requirements for checkers and formatters * nox sessions to automate checks * add ci workflows * add docs for nox sessions and dependencies
- Loading branch information
Showing
14 changed files
with
420 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Forge Webhook Parser CI | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- "main" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
nox: | ||
uses: ./.github/workflows/reusable-nox.yaml | ||
|
||
check: | ||
if: always() | ||
|
||
needs: | ||
- nox | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Decide whether the needed jobs succeeded or failed | ||
uses: re-actors/alls-green@release/v1 | ||
with: | ||
jobs: ${{ toJSON(needs) }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
name: nox | ||
|
||
"on": | ||
workflow_call: | ||
|
||
jobs: | ||
nox: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- session: static | ||
python-versions: "3.12" | ||
- session: formatters_check | ||
python-versions: "3.12" | ||
- session: typing | ||
python-versions: "3.12" | ||
name: "Run nox ${{ matrix.session }} session" | ||
steps: | ||
- name: Check out repo | ||
uses: actions/checkout@v4 | ||
- name: Setup nox | ||
uses: wntrblm/[email protected] | ||
with: | ||
python-versions: "${{ matrix.python-versions }}" | ||
- name: "Run nox -e ${{ matrix.session }}" | ||
run: | | ||
nox -e "${{ matrix.session }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
.DS_Store | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
pip-wheel-metadata/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
*.py,cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
db.sqlite3-journal | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# pipenv | ||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
# However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
# having no cross-platform support, pipenv may install dependencies that don't work, or not | ||
# install all needed dependencies. | ||
#Pipfile.lock | ||
|
||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow | ||
__pypackages__/ | ||
|
||
# Celery stuff | ||
celerybeat-schedule | ||
celerybeat.pid | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
site/ | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# VScode stuff | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[tool.pip-tools] | ||
resolver = "backtracking" | ||
allow-unsafe = true | ||
strip-extras = true | ||
quiet = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
from pathlib import Path | ||
|
||
import nox | ||
|
||
LINT_FILES = ["forge-webhook-parser.py"] | ||
|
||
requirements_directory = Path("requirements") | ||
|
||
requirements_files = [ | ||
requirements_input_file_path.stem | ||
for requirements_input_file_path in requirements_directory.glob("*.in") | ||
] | ||
|
||
|
||
@nox.session(name="pip-compile", python=["3.12"]) | ||
@nox.parametrize(["req"], arg_values_list=requirements_files, ids=requirements_files) | ||
def pip_compile(session: nox.Session, req: str): | ||
"""Generate lock files from input files or upgrade packages in lock files.""" | ||
# fmt: off | ||
session.install( | ||
"-r", str(requirements_directory / "pip-tools.in"), | ||
"-c", str(requirements_directory / "pip-tools.txt"), | ||
) | ||
# fmt: on | ||
|
||
# Use --upgrade by default unless a user passes -P. | ||
upgrade_related_cli_flags = ("-P", "--upgrade-package", "--no-upgrade") | ||
has_upgrade_related_cli_flags = any( | ||
arg.startswith(upgrade_related_cli_flags) for arg in session.posargs | ||
) | ||
injected_extra_cli_args = () if has_upgrade_related_cli_flags else ("--upgrade",) | ||
|
||
session.run( | ||
"pip-compile", | ||
"--output-file", | ||
str(requirements_directory / f"{req}.txt"), | ||
*session.posargs, | ||
*injected_extra_cli_args, | ||
str(requirements_directory / f"{req}.in"), | ||
) | ||
|
||
|
||
def install(session: nox.Session, req: str): | ||
session.install( | ||
"-r", | ||
str(requirements_directory / f"{req}.in"), | ||
"-c", | ||
str(requirements_directory / f"{req}.txt"), | ||
) | ||
|
||
|
||
@nox.session | ||
def static(session: nox.Session): | ||
""" | ||
Run static checkers | ||
""" | ||
install(session, req="static") | ||
session.run("ruff", "check", *session.posargs, *LINT_FILES) | ||
|
||
|
||
@nox.session | ||
def formatters(session: nox.Session): | ||
""" | ||
Reformat code | ||
""" | ||
install(session, req="formatters") | ||
session.run("isort", *session.posargs, *LINT_FILES) | ||
session.run("black", *session.posargs, *LINT_FILES) | ||
|
||
|
||
@nox.session | ||
def formatters_check(session: nox.Session): | ||
""" | ||
Check code formatting without making changes | ||
""" | ||
install(session, req="formatters") | ||
session.run("isort", "--check", *session.posargs, *LINT_FILES) | ||
session.run("black", "--check", *session.posargs, *LINT_FILES) | ||
|
||
|
||
@nox.session | ||
def typing(session: nox.Session): | ||
""" | ||
Run static type checker | ||
""" | ||
install(session, req="typing") | ||
session.run("mypy", *session.posargs, *LINT_FILES) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
black | ||
isort |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# | ||
# This file is autogenerated by pip-compile with Python 3.12 | ||
# by the following command: | ||
# | ||
# pip-compile --allow-unsafe --output-file=requirements/formatters.txt --strip-extras requirements/formatters.in | ||
# | ||
black==24.8.0 | ||
# via -r requirements/formatters.in | ||
click==8.1.7 | ||
# via black | ||
isort==5.13.2 | ||
# via -r requirements/formatters.in | ||
mypy-extensions==1.0.0 | ||
# via black | ||
packaging==24.1 | ||
# via black | ||
pathspec==0.12.1 | ||
# via black | ||
platformdirs==4.3.6 | ||
# via black |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pip-tools >= 7 # .pip-tools.toml was introduced in v6.14 |
Oops, something went wrong.