Skip to content

Commit

Permalink
Update template
Browse files Browse the repository at this point in the history
  • Loading branch information
nx10 committed Dec 21, 2023
1 parent 74edf15 commit 27dc906
Show file tree
Hide file tree
Showing 6 changed files with 164 additions and 106 deletions.
13 changes: 13 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: pip
directory: /
schedule:
interval: monthly
- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly
37 changes: 19 additions & 18 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,30 @@ permissions:

on:
workflow_run:
workflows: ["Python Tests"]
workflows: [Python Tests]
types:
- completed
- completed
branches:
- main
- main

jobs:
build-and-publish-docs:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install poetry
poetry install -E docs
- name: Build docs
run: |
poetry run pdoc src/llama_runner -o docs_build -t docs/pdoc-theme --docformat google
touch docs_build/.nojekyll
- uses: JamesIves/github-pages-deploy-action@v4
with:
folder: docs_build
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version-file: pyproject.toml
- name: Install dependencies
run: |
python -m pip install poetry
poetry install -E docs
- name: Build docs
run: |
APP_MODULE_NAME=$(ls src -U | head -1) # Get the first module name in the src directory
poetry run pdoc src/"$APP_MODULE_NAME" -o docs_build -t docs/pdoc-theme --docformat google
touch docs_build/.nojekyll
- uses: JamesIves/github-pages-deploy-action@v4
with:
folder: docs_build
79 changes: 36 additions & 43 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,59 +3,52 @@ name: Python Tests
on:
push:
branches:
- main
- main
pull_request:

jobs:
unit:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install poetry
poetry install
- name: Run tests
run: poetry run pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered --cov-report=xml:coverage.xml --cov=src tests | tee pytest-coverage.txt
- name: Pytest coverage comment
if: github.event_name == 'pull_request'
uses: MishaKav/pytest-coverage-comment@main
with:
pytest-coverage-path: ./pytest-coverage.txt
junitxml-path: ./pytest.xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry
- uses: actions/setup-python@v5
with:
python-version-file: pyproject.toml
cache: poetry
- name: Install dependencies
run: |
poetry install
- name: Run tests
id: run-tests
run: >
poetry run pytest \
--junitxml=pytest.xml \
--cov-report=term-missing:skip-covered \
--cov-report=xml:coverage.xml \
--cov=src tests \
--log-level=DEBUG \
--verbose
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3

black:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: psf/black@stable
- uses: actions/checkout@v4
- uses: chartboost/ruff-action@v1

mypy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.11"
- run: |
pip install poetry
poetry install
poetry run mypy .
isort:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: isort/isort-action@v1
with:
configuration: --profile black
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry
- uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: poetry
- run: |
poetry install
poetry run mypy .
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.ruff_cache

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
55 changes: 28 additions & 27 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,38 +1,31 @@
fail_fast: false

repos:
- repo: https://github.com/ambv/black
rev: 23.3.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.8
hooks:
- id: black
args: [--diff, --check]

- id: ruff
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.3.0
rev: v1.7.1
hooks:
- id: mypy
args: [--ignore-missing-imports]

- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
name: isort (python)
args: [--profile black]

- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
args:
- --ignore-missing-imports
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.11.0
hooks:
- id: python-check-blanket-noqa
- id: python-check-blanket-type-ignore
- id: python-check-mock-methods
- id: python-no-eval
- id: python-no-log-warn
- id: python-use-type-annotations
- id: text-unicode-replacement-char

- id: pretty-format-yaml
args:
- --autofix
- --indent=2
- id: pretty-format-toml
exclude: ^poetry.lock$
args:
- --autofix
- --indent=2
- --no-sort
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-case-conflict
- id: end-of-file-fixer
Expand All @@ -48,3 +41,11 @@ repos:
- id: check-merge-conflict
- id: check-yaml
- id: check-json
- id: check-toml
- repo: local
hooks:
- id: yaml-file-extension
name: Prefer .yaml over .yml.
entry: YAML files must have .yaml extension.
language: fail
files: \.yml$
84 changes: 66 additions & 18 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,87 @@
name = "llama_runner"
version = "0.1.0"
description = "A beautiful description."
authors = ["Reinder Vos de Wael <[email protected]>"]
authors = [ "Reinder Vos de Wael <[email protected]>" ]
license = "LGPL-2.1"
readme = "README.md"
packages = [{include = "llama_runner", from = "src"}]

[tool.poetry.dependencies]
python = "^3.10"
fire = "^0.5.0"
llama = {git = "https://github.com/facebookresearch/llama.git"}
[[tool.poetry.packages]]
include = "llama_runner"
from = "src"

[tool.poetry.dependencies]
python = "^3.10"
fire = "^0.5.0"

[tool.poetry.dependencies.llama]
git = "https://github.com/facebookresearch/llama.git"

[tool.poetry.group.dev.dependencies]
pytest = "^7.3.2"
mypy = "^1.4.0"
black = "^23.3.0"
isort = "^5.12.0"
pre-commit = "^3.3.3"
pytest-cov = "^4.1.0"


[tool.poetry.group.docs.dependencies]
pdoc = "^14.0.0"

[tool.poetry.extras]
docs = ["pdoc"]

[build-system]
requires = ["poetry-core>=1.2.0"]
build-backend = "poetry.core.masonry.api"
[tool.poetry.extras]
docs = [ "pdoc" ]

[tool.pytest.ini_options]
pythonpath = [
"src"
]
pythonpath = [ "src" ]

[tool.mypy]
ignore_missing_imports = true

[tool.ruff]
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".git-rewrite",
".hg",
".mypy_cache",
".nox",
".pants.d",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"venv"
]
line-length = 88
indent-width = 4
src = [ "src" ]
target-version = "py311"

[tool.ruff.lint]
select = [ "ANN", "D", "E", "F", "I" ]
ignore = [ "ANN101", "ANN102" ]
fixable = [ "ALL" ]
unfixable = [ ]
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

[tool.ruff.format]
quote-style = "double"
indent-style = "space"
skip-magic-trailing-comma = false
line-ending = "auto"

[tool.ruff.pydocstyle]
convention = "google"

[tool.ruff.per-file-ignores]
"tests/**/*.py" = [ ]

[build-system]
requires = [ "poetry-core>=1.2.0" ]
build-backend = "poetry.core.masonry.api"

0 comments on commit 27dc906

Please sign in to comment.