Skip to content

Commit 418f65e

Browse files
committed
🎨 add black, prettier, isort, flake8, pre-commit
1 parent 8f72dce commit 418f65e

File tree

9 files changed

+231
-64
lines changed

9 files changed

+231
-64
lines changed

.editorconfig

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,17 @@ end_of_line = lf
88
charset = utf-8
99
insert_final_newline = true
1010
trim_trailing_whitespace = true
11+
indent_style = space
12+
max_line_length = 90
1113

1214
[**.py]
13-
indent_style = tab
15+
indent_size = 4
1416

1517
[**.js]
16-
indent_style = space
1718
indent_size = 4
19+
20+
[**.yaml]
21+
indent_size = 2
22+
23+
[**.less]
24+
indent_size = 2

.git-blame-ignore-revs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# refs to ignore during git blame, use with --ignore-revs-file

.github/workflows/build.yml

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
name: CI/CD pipeline
2+
on:
3+
push:
4+
branches:
5+
- master
6+
release:
7+
types: [published, prereleased]
8+
9+
jobs:
10+
build:
11+
name: 🔨 Build distribution
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: 🏗 Set up Python 3.7
16+
uses: actions/setup-python@v1
17+
with:
18+
python-version: 3.7
19+
- name: 🏗 Install build dependencies
20+
run: >-
21+
python -m pip install wheel --user
22+
- name: 🔨 Build a binary wheel and a source tarball
23+
run: >-
24+
python setup.py sdist bdist_wheel
25+
- name: ⬆ Upload build result
26+
uses: actions/upload-artifact@v1
27+
with:
28+
name: dist
29+
path: dist
30+
31+
lint-black:
32+
name: 🧹 black
33+
runs-on: ubuntu-latest
34+
steps:
35+
- uses: actions/checkout@v2
36+
- name: 🏗 Set up Python 3.7
37+
uses: actions/setup-python@v1
38+
with:
39+
python-version: 3.7
40+
- name: 🏗 Set up dev dependencies
41+
run: |
42+
pip install -e .[develop]
43+
- name: 🚀 Run black
44+
run: |
45+
pre-commit run --hook-stage manual black --all-files --show-diff-on-failure
46+
47+
lint-prettier:
48+
name: 🧹 prettier
49+
runs-on: ubuntu-latest
50+
steps:
51+
- uses: actions/checkout@v2
52+
- name: 🏗 Set up Python 3.7
53+
uses: actions/setup-python@v1
54+
with:
55+
python-version: 3.7
56+
- name: 🏗 Set up dev dependencies
57+
run: |
58+
pip install -e .[develop]
59+
- name: 🚀 Run prettier
60+
run: |
61+
pre-commit run --hook-stage manual prettier --all-files --show-diff-on-failure
62+
63+
lint-isort:
64+
name: 🧹 isort
65+
runs-on: ubuntu-latest
66+
steps:
67+
- uses: actions/checkout@v2
68+
- name: 🏗 Set up Python 3.7
69+
uses: actions/setup-python@v1
70+
with:
71+
python-version: 3.7
72+
- name: 🏗 Set up dev dependencies
73+
run: |
74+
pip install -e .[develop]
75+
- name: 🚀 Run isort
76+
run: |
77+
pre-commit run --hook-stage manual isort --all-files --show-diff-on-failure
78+
79+
lint-flake8:
80+
name: 🧹 Flake8
81+
runs-on: ubuntu-latest
82+
steps:
83+
- uses: actions/checkout@v2
84+
- name: 🏗 Set up Python 3.7
85+
uses: actions/setup-python@v1
86+
with:
87+
python-version: 3.7
88+
- name: 🏗 Set up dev dependencies
89+
run: |
90+
pip install -e .[develop]
91+
- name: 🚀 Run flake8
92+
run: |
93+
pre-commit run --hook-stage manual flake8 --all-files
94+
95+
publish-on-testpypi:
96+
name: 📦 Publish on TestPyPI
97+
if: github.event_name == 'release'
98+
needs:
99+
- build
100+
- lint-black
101+
- lint-prettier
102+
- lint-isort
103+
- lint-flake8
104+
runs-on: ubuntu-latest
105+
steps:
106+
- name: ⬇ Download build result
107+
uses: actions/download-artifact@v1
108+
with:
109+
name: dist
110+
path: dist
111+
- name: 📦 Publish to index
112+
uses: pypa/gh-action-pypi-publish@master
113+
with:
114+
password: ${{ secrets.testpypi_password }}
115+
repository_url: https://test.pypi.org/legacy/
116+
117+
publish-on-pypi:
118+
name: 📦 Publish tagged releases to PyPI
119+
if: github.event_name == 'release'
120+
needs: publish-on-testpypi
121+
runs-on: ubuntu-latest
122+
steps:
123+
- name: ⬇ Download build result
124+
uses: actions/download-artifact@v1
125+
with:
126+
name: dist
127+
path: dist
128+
- name: 📦 Publish to index
129+
uses: pypa/gh-action-pypi-publish@master
130+
with:
131+
password: ${{ secrets.pypi_password }}

.github/workflows/ci-cd-pipeline.yml

Lines changed: 0 additions & 62 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
exclude: ^(src/octoprint/vendor/|src/octoprint/static/js/lib|src/octoprint/static/vendor|tests/static/js/lib|tests/util/_files|docs/|scripts/|translations/|.*\.css|.*\.svg)
2+
repos:
3+
- repo: https://github.com/pre-commit/pre-commit-hooks
4+
rev: v2.3.0
5+
hooks:
6+
- id: end-of-file-fixer
7+
- id: trailing-whitespace
8+
- id: check-case-conflict
9+
- id: check-json
10+
- id: check-yaml
11+
- id: check-toml
12+
- id: check-merge-conflict
13+
- id: fix-encoding-pragma
14+
- repo: https://github.com/OctoPrint/codemods
15+
rev: devel
16+
hooks:
17+
- id: codemod_dict_to_literal
18+
stages: ["manual"]
19+
- id: codemod_set_to_literal
20+
stages: ["manual"]
21+
- id: codemod_not_in
22+
stages: ["manual"]
23+
- repo: https://github.com/pre-commit/mirrors-isort
24+
rev: v5.5.4
25+
hooks:
26+
- id: isort
27+
- repo: https://github.com/psf/black
28+
rev: 20.8b1
29+
hooks:
30+
- id: black
31+
args: ["--config", "black.toml"]
32+
- repo: https://gitlab.com/pycqa/flake8
33+
rev: 3.8.1
34+
hooks:
35+
- id: flake8
36+
additional_dependencies:
37+
- flake8-bugbear
38+
- repo: https://github.com/pre-commit/mirrors-prettier
39+
rev: v2.1.2
40+
hooks:
41+
- id: prettier

.prettierignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*.md
2+
*.css
3+
**/*.min.js
4+
build
5+
dist
6+
venv
7+
venv2
8+
venv3

.prettierrc.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
printWidth: 90
2+
tabWidth: 4
3+
semi: true
4+
trailingComma: "none"
5+
singleQuote: false
6+
quoteProps: consistent
7+
bracketSpacing: false
8+
overrides:
9+
- files: ["*.yaml", "*.yml", "*.json", "*.less"]
10+
options:
11+
tabWidth: 2

black.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[tool.black]
2+
line-length = 90
3+
include = '''
4+
5+
(
6+
(
7+
src
8+
).*\.pyi?$
9+
)|(
10+
setup\.py
11+
)
12+
'''
13+
exclude = '''
14+
15+
(
16+
)
17+
'''

setup.cfg

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,16 @@ license_file = LICENSE
33

44
[bdist_wheel]
55
universal = 1
6+
7+
[flake8]
8+
max-line-length = 90
9+
extend-ignore = E203, E231, E265, E266, E402, E501, E731
10+
select = B,C,E,F,W,T4,B9
11+
12+
[isort]
13+
multi_line_output = 3
14+
include_trailing_comma = True
15+
force_grid_wrap = 0
16+
use_parentheses = True
17+
ensure_newline_before_comments = True
18+
line_length = 90

0 commit comments

Comments
 (0)