Skip to content

Commit 3d5f617

Browse files
Merge pull request #2 from python-discord/global-actions
Global Actions
2 parents 6563dbb + c04c75f commit 3d5f617

5 files changed

Lines changed: 66 additions & 61 deletions

File tree

.github/workflows/lint.yaml

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -31,44 +31,5 @@ jobs:
3131
with:
3232
python-version: ${{ env.PYTHON_VERSION }}
3333

34-
# This step caches our Python dependencies. To make sure we
35-
# only restore a cache when the dependencies, the python version and
36-
# the runner operating system we create a cache key
37-
# that is a composite of those states.
38-
# Only when the context is exactly the same, we will restore the cache.
39-
- name: Restore pip cache
40-
uses: actions/cache@v2
41-
with:
42-
path: ${{ env.PIP_CACHE_DIR }}
43-
key: "python-pip-${{ runner.os }}-\
44-
${{ steps.python.outputs.python-version }}-\
45-
${{ hashFiles('./Pipfile', './Pipfile.lock') }}"
46-
47-
# Uncomment the step that matches your setup.
48-
49-
# Default Env setup
50-
- name: Run hooks through our requirement file
51-
run: |
52-
pip install -r dev-requirements.txt
53-
pre-commit run --all-files
54-
env:
55-
# Force pre-commit to do a system install.
56-
PIP_USER: 0
57-
58-
# Pipenv setup
59-
# - name: Run hooks through our Pipenv environment.
60-
# run: |
61-
# pipenv install --system --dev
62-
# pipenv run python -m pre-commit run --all-files
63-
# env:
64-
# # Force pre-commit to do a system install.
65-
# PIP_USER: 0
66-
67-
# Poetry setup
68-
# - name: Run hooks through our Poetry environment.
69-
# run: |
70-
# poetry install
71-
# poetry run python -m pre-commit run --all-files
72-
# env:
73-
# # Force pre-commit to do a system install.
74-
# PIP_USER: 0
34+
- name: Run pre-commit hooks.
35+
uses: pre-commit/action@v2.0.3

.pre-commit-config.yaml

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
## Pre-commit setup
22
# See https://github.com/python-discord/code-jam-template/tree/main#pre-commit-run-linting-before-committing
3-
#
4-
# Please uncomment the right lines depending on your setup.
3+
4+
# Make sure to edit the `additional_dependencies` list if you want to add plugins
55

66
repos:
77
- repo: https://github.com/pre-commit/pre-commit-hooks
@@ -12,25 +12,23 @@ repos:
1212
- id: end-of-file-fixer
1313
- id: trailing-whitespace
1414
args: [--markdown-linebreak-ext=md]
15+
1516
- repo: https://github.com/pre-commit/pygrep-hooks
1617
rev: v1.5.1
1718
hooks:
1819
- id: python-check-blanket-noqa
19-
- repo: local
20+
21+
- repo: https://github.com/pre-commit/mirrors-isort
22+
rev: v5.9.2
2023
hooks:
2124
- id: isort
22-
name: ISort
23-
entry: python -m isort . # Default Env setup
24-
# entry: pipenv run python -m isort . # Pipenv setup
25-
# entry: poetry run python -m isort . # Poetry setup
26-
language: system
27-
types: [python]
28-
require_serial: true
25+
26+
- repo: https://github.com/pycqa/flake8
27+
rev: 3.9.2
28+
hooks:
2929
- id: flake8
30-
name: Flake8
31-
entry: python -m flake8 # Default Env setup
32-
# entry: pipenv run python -m flake8 # Pipenv setup
33-
# entry: poetry run python -m flake8 # Poetry setup
34-
language: system
35-
types: [python]
36-
require_serial: true
30+
additional_dependencies:
31+
- flake8-annotations~=2.0
32+
- flake8-bandit~=2.1
33+
- flake8-docstrings~=1.5
34+
- flake8-isort~=4.0

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,6 @@ It is *installed* by running `pre-commit install` and can be run manually by cal
8585
- `isort`: Runs ISort.
8686
- `flake8`: Runs flake8.
8787

88-
The last two hooks won't ship with their own environment but will rather run shell commands. You will have to modify them if you change your dependency manager.
89-
9088
## How do I use it?
9189

9290
### Creating your Team Repository
@@ -168,7 +166,8 @@ Once the environment is activated, all the commands listed previously should wor
168166

169167
If you wish to use Pipenv or Poetry, you will have to move the dependencies in `dev-requirements.txt` to the development dependencies of your tool.
170168

171-
Additionally, you will have to open `.pre-commit-config.yaml` and `.github/workflows/lint.yaml` and uncomment the right section.
169+
We've included a porting of `dev-requirements.txt` to both [poetry](./samples/pyproject.toml) and [pipenv](./samples/Pipfile) in the [samples folder](./samples).
170+
If you use the poetry setup, make sure to change the project name, description, and authors at the top of the file.
172171

173172
When installing new dependencies, don't forget to [pin them](https://pip.pypa.io/en/stable/user_guide/#pinned-version-numbers) by adding a version tag at the end.
174173
For example, if I wish to install `Click`, a quick look at [PyPI](https://pypi.org/project/click/) tells me that 8.0.1 is the latest version.

samples/Pipfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[[source]]
2+
url = "https://pypi.org/simple"
3+
verify_ssl = true
4+
name = "pypi"
5+
6+
[packages]
7+
8+
[dev-packages]
9+
# Base tools
10+
flake8 = "~=3.7"
11+
isort = "~=5.9"
12+
pre-commit = "~=2.13.0"
13+
14+
# Flake8 plugins, see https://github.com/python-discord/code-jam-template/tree/main#plugin-list
15+
flake8-annotations = "~=2.0"
16+
flake8-bandit = "~=2.1"
17+
flake8-docstrings = "~=1.5"
18+
flake8-isort = "~=4.0"
19+
20+
[requires]
21+
python_version = "3.9"

samples/pyproject.toml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[tool.poetry]
2+
name = "Name"
3+
version = "0.1.0"
4+
description = ""
5+
authors = ["Author 1 <email@mail.com>"]
6+
license = "MIT"
7+
8+
[tool.poetry.dependencies]
9+
python = "3.9.*"
10+
11+
[tool.poetry.dev-dependencies]
12+
# Base tools
13+
flake8 = "~3.7"
14+
isort = "~5.9"
15+
pre-commit = "~2.13.0"
16+
17+
# Flake8 plugins, see https://github.com/python-discord/code-jam-template/tree/main#plugin-list
18+
flake8-annotations = "~2.0"
19+
flake8-bandit = "~2.1"
20+
flake8-docstrings = "~1.5"
21+
flake8-isort = "~4.0"
22+
23+
24+
[build-system]
25+
requires = ["poetry-core>=1.0.0"]
26+
build-backend = "poetry.core.masonry.api"

0 commit comments

Comments
 (0)