Skip to content

Commit

Permalink
🎉 Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ddelange committed Oct 26, 2020
0 parents commit d8e9134
Show file tree
Hide file tree
Showing 18 changed files with 573 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @ddelange
36 changes: 36 additions & 0 deletions .github/workflows/CD.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This workflows will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

name: CD

on:
release:
types: [released]

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.x

- name: Install dependencies
run: |
pip install -U pip setuptools wheel
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel --universal
twine upload dist/*
71 changes: 71 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# 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
on:
pull_request:
push:
branches: master

jobs:
autocancel:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: n1hility/cancel-previous-runs@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}

build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [2.7, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9]

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

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

- name: Pip cache
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements/*.txt') }}

- name: Pre-commit cache
uses: actions/cache@v2
with:
path: ~/.cache/pre-commit
key: ${{ runner.os }}-pre-commit-${{ matrix.python-version }}-${{ hashFiles('**/requirements/ci.txt') }}-${{ hashFiles('.pre-commit-config.yaml') }}

- name: Install (ci)
run: |
pip install --upgrade pip setuptools wheel
pip install -r requirements/ci.txt
pip install -r requirements/docs.txt
pip install codecov
- name: Lint
if: matrix.python-version != 2.7
run: make lint

- name: Install (self)
run: pip install -e .

- name: Test
run: make test

- name: Docs
if: matrix.python-version != 2.7
run: SPHINXOPTS=-W make builddocs

- name: Codecov
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
run: codecov
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# setuptools_scm
_version.py
68 changes: 68 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
repos:
- repo: https://github.com/Yelp/detect-secrets
rev: v0.14.3
hooks:
- id: detect-secrets
args: ['--baseline', '.secrets.baseline']
exclude: .*/tests/.*

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

- repo: https://github.com/timothycrosley/isort
rev: 5.5.4
hooks:
- id: isort

- repo: local
hooks:
- id: mypy
name: Run mypy
entry: python -m mypy src/
language: system
types: [python]
pass_filenames: false

- repo: https://github.com/PyCQA/flake8
rev: 3.8.3
hooks:
- id: flake8
additional_dependencies: [
'darglint~=1.5.4',
'flake8-absolute-import~=1.0',
'flake8-blind-except~=0.1.1',
'flake8-builtins~=1.5.3',
'flake8-cognitive-complexity==0.1.0',
'flake8-comprehensions~=3.2.3',
'flake8-docstrings~=1.5.0',
'flake8-logging-format~=0.6.0',
'flake8-mutable~=1.2.0',
'flake8-print~=3.1.4',
'flake8-printf-formatting~=1.1.0',
'flake8-pytest-style~=1.2.3',
'flake8-quotes~=3.2.0',
'flake8-tuple~=0.4.1',
'pep8-naming~=0.11.1'
]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: mixed-line-ending
args: ['--fix=lf']
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-merge-conflict
- id: check-json
- id: check-toml
- id: check-xml
- id: check-yaml
- id: debug-statements

- repo: https://github.com/econchick/interrogate
rev: 1.3.1
hooks:
- id: interrogate
pass_filenames: false
25 changes: 25 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# .readthedocs.yml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/source/conf.py

# Build documentation with MkDocs
#mkdocs:
# configuration: mkdocs.yml

# Optionally build your docs in additional formats such as PDF and ePub
formats: all

# Optionally set the version of Python and requirements required to build your docs
python:
version: 3.8
install:
- method: pip
path: .
- requirements: requirements/docs.txt
8 changes: 8 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
global-exclude *
include setup.py
include README*
include LICENSE*
graft src
graft requirements
exclude requirements/ci.txt
recursive-exclude * __pycache__
37 changes: 37 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
.PHONY: lint
## Run linting
lint:
pre-commit run --all-files

.PHONY: test
## Run tests
test:
python -m pytest

.PHONY: showcov
## Open the test coverage overview using the default HTML viewer
showcov:
xdg-open htmlcov/index.html || open htmlcov/index.html

.PHONY: install
## Install this repo, plus dev requirements, in editable mode
install:
pip install -r requirements/ci.txt -r requirements/docs.txt
pip install -e .
pre-commit install

.PHONY: builddocs
## Build documentation using Sphinx
builddocs:
cd docs && make docs

.PHONY: showdocs
## Open the docs using the default HTML viewer
showdocs:
xdg-open docs/_build/html/index.html || open docs/_build/html/index.html

.PHONY: help
## Print Makefile documentation
help:
@perl -0 -nle 'printf("%-25s - %s\n", "$$2", "$$1") while m/^##\s*([^\r\n]+)\n^([\w-]+):[^=]/gm' $(MAKEFILE_LIST) | sort
.DEFAULT_GOAL := help
60 changes: 60 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# mapply

[![build](https://img.shields.io/github/workflow/status/ddelange/mapply/GH/master?logo=github&cacheSeconds=86400)](https://github.com/ddelange/mapply/actions?query=branch%3Amaster)
[![codecov](https://img.shields.io/codecov/c/github/ddelange/mapply/master?logo=codecov&logoColor=white)](https://codecov.io/gh/ddelange/mapply)
[![pypi Version](https://img.shields.io/pypi/v/mapply.svg?logo=pypi&logoColor=white)](https://pypi.org/project/mapply/)
[![python](https://img.shields.io/pypi/pyversions/mapply.svg?logo=python&logoColor=white)](https://pypi.org/project/mapply/)
[![downloads](https://pepy.tech/badge/mapply)](https://pypistats.org/packages/mapply)
[![black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black)


## Initial setup of this repo

Add this repo to Github:

- [Create a new repository](https://github.com/new) on GitHub. Only fill in `mapply` and an optional description and click `Create repository`. Do not initialize the new repository with README, license, or gitignore files.

- Now push this repo to Github (`__version__` is populated based on tags, so tag the initial commit):

```sh
cd mapply
git init .
git add .
git commit -m ':tada: Initial commit'
git tag -a "0.1.0-rc.1" -m 'Initial release candidate. Bump version on GitHub and it will be reflected on the next `git pull; pip install -e .`'
git remote add origin https://github.com/ddelange/mapply.git
git push --set-upstream origin master
```

- This repo contains GitHub Actions to to run `linting`, `tests`, `codecov`, and `PyPi` deploys for all GitHub releases.

- This requires `$PYPI_USER` and `$PYPI_PASSWORD` and `$CODECOV_TOKEN` (found under `Repository Upload Token` at https://codecov.io/gh/ddelange/mapply/settings)

- Add these variables to the repo's secrets here: https://github.com/ddelange/mapply/settings/secrets

- It is also recommended to make `master` a protected branch. The first two ticks should be enough (`Require branches to be up to date before merging` is also nice, and `Include administrators` will avoid accidental pushes to `master`): https://github.com/ddelange/mapply/settings/branch_protection_rules/new

- If you'd like, add a LICENSE.md file manually or via GitHub GUI (don't forget to pull afterwards), and add an appropriate keyword to [`setup()`](setup.py), e.g. `license="MIT"`, and the appropriate [classifier](https://pypi.org/classifiers/), e.g. `"License :: OSI Approved :: MIT License"`.

- You can remove this (now unnecessary) section.

## Installation

This pure-Python, OS independent package is available on [PyPI](https://pypi.org/project/mapply):

```sh
$ pip install mapply
```

## Usage

```py
# TODO
```

## Development

[![gitmoji](https://img.shields.io/badge/gitmoji-%20%F0%9F%98%9C%20%F0%9F%98%8D-ffdd67)](https://github.com/carloscuesta/gitmoji-cli)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)

Run `make help` for options like installing for development, linting, testing, and building docs.
29 changes: 29 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

show:
xdg-open docs/_build/html/index.html || open docs/_build/html/index.html

docs:
rm -rf source/_code_reference
make clean
make html
Loading

0 comments on commit d8e9134

Please sign in to comment.