Skip to content

Commit

Permalink
checkpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
moshez committed Jan 19, 2024
1 parent 1fb5e13 commit 5a401f3
Show file tree
Hide file tree
Showing 19 changed files with 454 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/pr-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@


on: [push, pull_request]
jobs:
tests:
strategy:
fail-fast: false
matrix:
include:
- { python: "3.11", os: ubuntu-latest, check: "tests-3.11" }
- { python: "3.12", os: ubuntu-latest, check: "tests-3.12" }
- { python: "3.12", os: ubuntu-latest, check: "lint" }
- { python: "3.12", os: ubuntu-latest, check: "docs" }
- { python: "3.12", os: ubuntu-latest, check: "mypy" }
- { python: "3.12", os: ubuntu-latest, check: "build" }
name: ${{ matrix.check }} on Python ${{ matrix.python }} (${{ matrix.os }})
runs-on: ${{ matrix.os }}

steps:
- name: Check out the repository
uses: actions/checkout@v3.0.2

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

- name: Upgrade pip
run: |
pip install --upgrade pip
pip --version
- name: Install Nox
run: |
pip install nox
nox --version
- name: Run Nox
run: |
nox --force-color --python=${{ matrix.python }} --session=${{ matrix.check }}
55 changes: 55 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Release

on:
push:
branches:
- trunk

permissions: # added using https://github.com/step-security/secure-workflows
contents: read

jobs:
build:
name: Build
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2

- uses: actions/setup-python@57ded4d7d5e986d7296eab16560982c6dd7c923b
with:
python-version: "3.x"
cache: "pip"
cache-dependency-path: pyproject.toml

- name: deps
run: python -m pip install -U build

- name: env
run: env

- name: build
run: python -m build

- name: Upload built packages
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: built-packages
path: ./dist/
if-no-files-found: warn

release-pypi:
needs: build
runs-on: ubuntu-latest
permissions:
# Used to authenticate to PyPI via OIDC.
id-token: write
steps:
- name: Download artifacts directories # goes to current working directory
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2

- name: publish
uses: pypa/gh-action-pypi-publish@0bf742be3ebe032c25dd15117957dc15d0cfc38d
with:
packages_dir: built-packages/
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.ipynb_checkpoints
*.egg-info
__pycache__
/dist
/build
/git-log-head
4 changes: 4 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
silly_pyproject_name
========================

Stuff
5 changes: 5 additions & 0 deletions doc/api-reference.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
API Reference
=============

.. automodule:: silly_pyproject_name
:members:
11 changes: 11 additions & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.viewcode',
]
master_doc = 'index'
project = 'silly_pyproject_name'
copyright = 'Copyright (c) Moshe Zadka'
author = 'Moshe Zadka'
version = ''

exclude_patterns = ['.ipynb_checkpoints/**']
11 changes: 11 additions & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
silly_pyproject_name
================


CLI tools for manipulating Python project's name. Example for Gather.

.. toctree::
:maxdepth: 2

quick-start
api-reference
2 changes: 2 additions & 0 deletions doc/quick-start.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Getting Started with silly_pyproject_name
=====================================
95 changes: 95 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import functools
import os

import nox

nox.options.envdir = "build/nox"
nox.options.sessions = ["lint", "tests", "mypy", "docs", "build"]

VERSIONS = ["3.11", "3.12"]


@nox.session(python=VERSIONS)
def tests(session):
tmpdir = session.create_tmp()
session.install("-r", "requirements-tests.txt")
session.install("-e", ".")
tests = session.posargs or ["silly_pyproject_name.tests"]
session.run(
"coverage",
"run",
"--branch",
"--source=silly_pyproject_name",
"--omit=**/__main__.py",
"-m",
"virtue",
*tests,
env=dict(COVERAGE_FILE=os.path.join(tmpdir, "coverage"), TMPDIR=tmpdir),
)
fail_under = "--fail-under=100"
session.run(
"coverage",
"report",
fail_under,
"--show-missing",
"--skip-covered",
env=dict(COVERAGE_FILE=os.path.join(tmpdir, "coverage")),
)


@nox.session(python=VERSIONS[-1])
def build(session):
session.install("build")
session.run("python", "-m", "build", "--wheel")


@nox.session(python=VERSIONS[-1])
def lint(session):
files = ["src/", "noxfile.py"]
session.install("-r", "requirements-lint.txt")
session.install("-e", ".")
session.run("black", "--check", "--diff", *files)
black_compat = ["--max-line-length=88", "--ignore=E203,E503"]
session.run("flake8", *black_compat, "src/")


@nox.session(python=VERSIONS[-1])
def mypy(session):
session.install("-r", "requirements-mypy.txt")
session.install("-e", ".")
session.run(
"mypy",
"--warn-unused-ignores",
"--ignore-missing-imports",
"src/",
)


@nox.session(python=VERSIONS[-1])
def docs(session):
"""Build the documentation."""
output_dir = os.path.abspath(os.path.join(session.create_tmp(), "output"))
doctrees, html = map(
functools.partial(os.path.join, output_dir), ["doctrees", "html"]
)
session.run("rm", "-rf", output_dir, external=True)
session.install("-r", "requirements-docs.txt")
session.install("-e", ".")
sphinx = ["sphinx-build", "-b", "html", "-W", "-d", doctrees, ".", html]
session.cd("doc")
session.run(*sphinx)


@nox.session(python=VERSIONS[-1])
def refresh_deps(session):
"""Refresh the requirements-*.txt files"""
session.install("pip-tools")
for deps in ["tests", "docs", "lint", "mypy"]:
session.run(
"pip-compile",
"--extra",
deps,
"pyproject.toml",
"--output-file",
f"requirements-{deps}.txt",
)
52 changes: 52 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
[build-system]
requires = [
"setuptools",
"autocalver",
]
build-backend = "setuptools.build_meta"

[project]
name = "silly_pyproject_name"
dynamic = ["version"]
description = "CLI tools for manipulating Python project's name. Example for Gather."
readme = "README.rst"
authors = [{name = "Moshe Zadka", email = "moshez@zadka.club"}]

[project.optional-dependencies]
tests = ["virtue", "pyhamcrest", "coverage"]
mypy = ["mypy"]
lint = ["flake8", "black"]
docs = ["sphinx"]

[project.license]
text = """
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.
"""

[project.urls]
Homepage = "https://github.com/elcaminoreal/silly_pyproject_name"

[tool.autocalver]
use = true
log = "git-log-head"
log_command = "git log -n 1 --date=iso"
is_main_var = "GITHUB_REF"
is_main_match = ".*/trunk$"

[project.entry-points.gather]
placeholder = "silly_pyproject_name"
48 changes: 48 additions & 0 deletions requirements-docs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#
# This file is autogenerated by pip-compile with Python 3.12
# by the following command:
#
# pip-compile --output-file=- -
#
alabaster==0.7.16
# via sphinx
babel==2.14.0
# via sphinx
certifi==2023.11.17
# via requests
charset-normalizer==3.3.2
# via requests
docutils==0.20.1
# via sphinx
idna==3.6
# via requests
imagesize==1.4.1
# via sphinx
jinja2==3.1.3
# via sphinx
markupsafe==2.1.3
# via jinja2
packaging==23.2
# via sphinx
pygments==2.17.2
# via sphinx
requests==2.31.0
# via sphinx
snowballstemmer==2.2.0
# via sphinx
sphinx==7.2.6
# via -r -
sphinxcontrib-applehelp==1.0.8
# via sphinx
sphinxcontrib-devhelp==1.0.6
# via sphinx
sphinxcontrib-htmlhelp==2.0.5
# via sphinx
sphinxcontrib-jsmath==1.0.1
# via sphinx
sphinxcontrib-qthelp==1.0.7
# via sphinx
sphinxcontrib-serializinghtml==1.1.10
# via sphinx
urllib3==2.1.0
# via requests
26 changes: 26 additions & 0 deletions requirements-lint.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#
# This file is autogenerated by pip-compile with Python 3.12
# by the following command:
#
# pip-compile --output-file=- -
#
black==23.12.1
# via -r -
click==8.1.7
# via black
flake8==7.0.0
# via -r -
mccabe==0.7.0
# via flake8
mypy-extensions==1.0.0
# via black
packaging==23.2
# via black
pathspec==0.12.1
# via black
platformdirs==4.1.0
# via black
pycodestyle==2.11.1
# via flake8
pyflakes==3.2.0
# via flake8
12 changes: 12 additions & 0 deletions requirements-mypy.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#
# This file is autogenerated by pip-compile with Python 3.12
# by the following command:
#
# pip-compile --output-file=- -
#
mypy==1.8.0
# via -r -
mypy-extensions==1.0.0
# via mypy
typing-extensions==4.9.0
# via mypy
Loading

0 comments on commit 5a401f3

Please sign in to comment.