Skip to content

Commit

Permalink
Add continuous integration using github actions (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-Sassoulas authored May 30, 2022
1 parent c3c91c7 commit be04374
Show file tree
Hide file tree
Showing 10 changed files with 229 additions and 38 deletions.
12 changes: 12 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# These are supported funding model platforms

github: [Pierre-Sassoulas]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: "pypi/black-disable-checker"
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: Pierre-Sassoulas
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
3 changes: 3 additions & 0 deletions .github/SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Coordinated Disclosure Plan

[Coordinated Disclosure Plan](https://tidelift.com/security)
101 changes: 101 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
on:
push:
branches:
- main
pull_request: ~

env:
CACHE_VERSION: 4
DEFAULT_PYTHON: 3.9
PRE_COMMIT_CACHE: ~/.cache/pre-commit

jobs:
pylint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
- name: Install dependencies
run: |
pip install -e ".[test]"
- name: Lint
run: |
# We need to run pylint as it can't be run with pre-commit-ci
pre-commit run pylint --all-files
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
- name: Install dependencies
run: |
pip install -e ".[test]"
- name: Coverage
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
coverage run -m pytest . --cov=black_disable_checker --cov-report html
coveralls debug --service=github
linux-tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9, "3.10"]
steps:
- uses: actions/checkout@v2
- name: Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install -e ".[test]"
- name: Test
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pytest .
windows-tests:
runs-on: windows-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9, "3.10"]
steps:
- uses: actions/checkout@v2
- name: Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install -e ".[test]"
- name: Test
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pytest .
mac-tests:
runs-on: macos-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9, "3.10"]
steps:
- uses: actions/checkout@v2
- name: Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install -e ".[test]"
- name: Test
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pytest .
37 changes: 37 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Release

on:
release:
types:
- published

env:
DEFAULT_PYTHON: 3.9

jobs:
release-pypi:
name: Upload release to PyPI
runs-on: ubuntu-latest
steps:
- name: Check out code from Github
uses: actions/[email protected]
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
id: python
uses: actions/[email protected]
with:
python-version: ${{ env.DEFAULT_PYTHON }}
- name: Install requirements
run: |
python -m pip install -U pip twine wheel
python -m pip install -U "setuptools>=56.0.0"
- name: Build distributions
run: |
python setup.py sdist bdist_wheel
- name: Upload to PyPI
if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags')
env:
TWINE_REPOSITORY: pypi
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
twine upload --verbose dist/*
29 changes: 23 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
ci:
skip: [pylint]

repos:
- repo: https://github.com/Pierre-Sassoulas/black-disable-checker/
- repo: https://github.com/Pierre-Sassoulas/black-disable-checker/
rev: 1.0.1
hooks:
- id: black-disable-checker
exclude: black_disable_checker/__main__.py|tests/*
- repo: https://github.com/psf/black
- id: black-disable-checker
exclude: black_disable_checker/__main__.py|tests/
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
args: [--safe, --quiet]
- id: black
args: [--safe, --quiet]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.5.1
hooks:
- id: prettier
args: [--prose-wrap=always, --print-width=88]
- repo: local
hooks:
- id: pylint
name: pylint
entry: pylint
language: system
exclude: tests
args: ["-sn", "-rn", "--disable=C0111,C0103"]
types: [python]
10 changes: 5 additions & 5 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- id: black-disable-checker
name: black-disable-checker
entry: black-disable-checker
language: python
'types': [python]
- id: black-disable-checker
name: black-disable-checker
entry: black-disable-checker
language: python
"types": [python]
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@
[![PyPI version](https://badge.fury.io/py/black-disable-checker.svg)](https://badge.fury.io/py/black-disable-checker)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)

> That little door knob on your blackened bike shed can also be any color you like; as long as it's black.
> That little door knob on your blackened bike shed can also be any color you like; as
> long as it's black.
`black-disable-checker` is an uncompromising black adoption checker.
By using it, you agree to really cede control over minutiae of hand-formatting.
In return, you will not have to argue about disabling black or not. You will save
time and mental energy for more important matters.
`black-disable-checker` is an uncompromising black adoption checker. By using it, you
agree to really cede control over minutiae of hand-formatting. In return, you will not
have to argue about disabling black or not. You will save time and mental energy for
more important matters.

## Installation

```yaml
- repo: https://github.com/Pierre-Sassoulas/black-disable-checker/
rev: 1.1.0
hooks:
- repo: https://github.com/Pierre-Sassoulas/black-disable-checker/
rev: 1.1.0
hooks:
- id: black-disable-checker
```
```
31 changes: 31 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[metadata]
author = Pierre Sassoulas
author_email = [email protected]
long_description = file: README.md
long_description_content_type = text/markdown
name = black-disable-checker
version = 1.1.0
description = That little door knob on your blackened bike shed can also be any color you like; as long as it's black.
classifiers =
Operating System :: OS Independent
Intended Audience :: Developers
License :: OSI Approved :: MIT License
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Development Status :: 5 - Production/Stable
url = https://github.com/Pierre-Sassoulas/black-disable-checker/
[options.entry_points]
console_scripts =
black-disable-checker=black_disable_checker.__main__:main

[options.extras_require]
test =
pytest-cov
pytest-vcr
coverage
python-coveralls
coveralls
pylint==2.13.9
pre-commit
15 changes: 0 additions & 15 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
from setuptools import setup

with open("README.md", "r", encoding="utf-8") as r:
README = r.read()

setup(
author="Pierre Sassoulas",
author_email="[email protected]",
long_description=README,
long_description_content_type="text/markdown",
name="black-disable-checker",
version="1.1.0",
packages=["black_disable_checker"],
entry_points={
"console_scripts": ["black-disable-checker=black_disable_checker.__main__:main"]
},
install_requires=[],
url="https://github.com/Pierre-Sassoulas/black-disable-checker/",
zip_safe=True,
)
10 changes: 7 additions & 3 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
TEST_DIRECTORY = Path(__file__).parent


def test_integration_no_args() -> None:
with patch("sys.argv", ["black-disable-checker"]):
with pytest.raises(SystemExit) as e:
main()
assert e.value.code == 0


@pytest.mark.parametrize(
"file_path,expected",
[
Expand All @@ -18,9 +25,6 @@
],
)
def test_integration(file_path: str, expected: str, capsys) -> None:
with pytest.raises(SystemExit) as e:
main()
assert e.value.code == 0
with patch(
"sys.argv",
["black-disable-checker", str(TEST_DIRECTORY / f"fixture_{file_path}.py")],
Expand Down

0 comments on commit be04374

Please sign in to comment.