Skip to content

Commit

Permalink
Merge pull request #8 from tillahoffmann/update
Browse files Browse the repository at this point in the history
Maintenance updates.
  • Loading branch information
tillahoffmann authored Feb 16, 2024
2 parents 3f757ed + e02ffc1 commit d0c0ea2
Show file tree
Hide file tree
Showing 12 changed files with 358 additions and 237 deletions.
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.coverage
.git
.pytest_cache
*.egg-info
*/__pycache__
docs
htmlcov
venv
44 changes: 21 additions & 23 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: CI
name: localscope

on:
push:
Expand All @@ -13,30 +10,31 @@ on:

jobs:
build:

name: Build
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]
python-version:
- '3.8'
- '3.9'
- '3.10'
- '3.11'
- '3.12'

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}.
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
cache: pip
- name: Install dependencies.
run: pip install -r requirements.txt
- name: Build docs, lint, and test
run: make build
- name: Publish package
# Only publish with one python version
# (cf. https://github.com/pypa/gh-action-pypi-publish/issues/16#issuecomment-557827529)
if: >-
matrix.python-version == '3.8'
&& github.event_name == 'push'
&& startsWith(github.event.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.pypi_password }}
- name: Lint code.
run: make lint
- name: Build documentation.
run: make docs
- name: Run doctests.
run: make doctests
- name: Run tests.
run: make tests
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ARG version
FROM python:${version}
WORKDIR /workdir
COPY README.rst requirements.txt setup.py ./
RUN pip install -r requirements.txt
COPY . .
32 changes: 23 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,39 @@
.PHONY : clean dist docs lint tests
.PHONY : dist docs doctests docker-image lint tests

# Build documentation, lint the code, and run tests
build : setup.py docs lint tests
# Build documentation, lint the code, and run tests.
build : setup.py docs doctests lint tests
python setup.py sdist
twine check dist/*.tar.gz

lint :
flake8
black --check .

docs :
sphinx-build -b doctest . docs/_build
sphinx-build -b html . docs/_build
# Always build from scratch because of dodgy Sphinx caching.
rm -rf docs/_build
sphinx-build -nW -b html . docs/_build

clean :
doctests :
# Always build from scratch because of dodgy Sphinx caching.
rm -rf docs/_build
sphinx-build -nW -b doctest . docs/_build

tests :
pytest -v --cov localscope --cov-report=html --cov-report=term-missing \
--cov-fail-under=100 tests
--cov-fail-under=100

# Build pinned requirements file
# Build pinned requirements file.
requirements.txt : requirements.in setup.py
pip-compile -v $<
pip-sync $@

# Docker versions.
VERSIONS = 3.8 3.9 3.10 3.11 3.12
IMAGES = ${addprefix docker-image/,${VERSIONS}}

docker-images : ${IMAGES}
${IMAGES} : docker-image/% :
docker build --build-arg version=$* -t localscope:$* .

$(addprefix docker-shell/,${VERSIONS}) : docker-shell/% : docker-image/%
docker run --rm -it localscope:$* bash
67 changes: 12 additions & 55 deletions conf.py
Original file line number Diff line number Diff line change
@@ -1,58 +1,15 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))


# -- Project information -----------------------------------------------------

project = 'localscope'
copyright = '2020, Till Hoffmann'
author = 'Till Hoffmann'
master_doc = 'README'


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
project = "localscope"
copyright = "2020, Till Hoffmann"
author = "Till Hoffmann"
extensions = [
'sphinx.ext.napoleon',
'sphinx.ext.doctest',
'sphinx.ext.autodoc',
"sphinx.ext.autodoc",
"sphinx.ext.doctest",
"sphinx.ext.napoleon",
]
exclude_patterns = [
"_build",
"*.egg-info",
"README.rst",
"venv",
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'alabaster'

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = []

doctest_global_setup = "from localscope import localscope"
1 change: 1 addition & 0 deletions index.rst
Loading

0 comments on commit d0c0ea2

Please sign in to comment.