Skip to content

Commit c03fda1

Browse files
authored
Clean up cookie cutter and fix CI failures (#21)
1 parent b23da2f commit c03fda1

File tree

7 files changed

+106
-111
lines changed

7 files changed

+106
-111
lines changed

.github/workflows/main.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
matrix:
2020
os: [ubuntu-latest, macos-latest, windows-latest]
2121
# This will be used by the base setup action
22-
python-version: ["3.7", "3.10"]
22+
python-version: ["3.8", "3.11"]
2323

2424
steps:
2525
- name: Checkout
@@ -97,6 +97,16 @@ jobs:
9797
pip uninstall -y my_server_extension
9898
rm -rf my_server_extension
9999
100+
- name: Run the linters
101+
run: |
102+
# Trick to use custom parameters
103+
python -c "from cookiecutter.main import cookiecutter; import json; f=open('cookiecutter.json'); d=json.load(f); f.close(); d['author_name']='foo'; d['author_email']='[email protected]'; cookiecutter('.', extra_context=d, no_input=True)"
104+
cd my_server_extension
105+
bash ./.github/workflows/lint.sh
106+
cd ..
107+
pip uninstall -y my_server_extension
108+
rm -rf my_server_extension
109+
100110
- uses: actions/upload-artifact@v2
101111
if: startsWith(runner.os, 'Linux')
102112
with:
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
- package-ecosystem: "pip"
8+
directory: "/"
9+
schedule:
10+
interval: "weekly"

{{cookiecutter.package_name}}/.github/workflows/build.yml

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ defaults:
1414
jobs:
1515
build:
1616
runs-on: ubuntu-latest
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
os: [ubuntu-latest, macos-latest, windows-latest]
21+
python-version: [ '3.8', '3.9', '3.10', "3.11" ]
22+
1723
steps:
1824
- name: Checkout
1925
uses: actions/checkout@v2
@@ -47,12 +53,33 @@ jobs:
4753
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
4854
- uses: jupyterlab/maintainer-tools/.github/actions/check-links@v1
4955

50-
pre_commit:
56+
test_lint:
5157
runs-on: ubuntu-latest
5258
steps:
5359
- uses: actions/checkout@v2
5460
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
55-
- uses: jupyterlab/maintainer-tools/.github/actions/pre-commit@v1
61+
- name: Run Linters
62+
run: |
63+
bash ./.github/workflows/lint.sh
64+
65+
check_release:
66+
runs-on: ubuntu-latest
67+
steps:
68+
- uses: actions/checkout@v2
69+
- name: Base Setup
70+
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
71+
- name: Install Dependencies
72+
run: |
73+
pip install -e .
74+
- name: Check Release
75+
uses: jupyter-server/jupyter_releaser/.github/actions/check-release@v2
76+
with:
77+
token: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}
78+
- name: Upload Distributions
79+
uses: actions/upload-artifact@v2
80+
with:
81+
name: {{ cookiecutter.package_name }}-releaser-dist-${{ '{{ github.run_number }}' }}
82+
path: .jupyter_releaser_checkout/dist
5683

5784
test_sdist:
5885
needs: build

{{cookiecutter.package_name}}/.github/workflows/check-release.yml

Lines changed: 0 additions & 26 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
pip install -e ".[test,lint]"
3+
mypy --install-types --non-interactive .
4+
ruff .
5+
black --check --diff .
6+
mdformat --check *.md
7+
pipx run 'validate-pyproject[all]' pyproject.toml
Lines changed: 15 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
default_language_version:
2-
node: system
1+
ci:
2+
autoupdate_schedule: monthly
33

44
repos:
55
- repo: https://github.com/pre-commit/pre-commit-hooks
6-
rev: v4.3.0
6+
rev: v4.4.0
77
hooks:
88
- id: end-of-file-fixer
99
- id: check-case-conflict
@@ -18,63 +18,25 @@ repos:
1818
- id: check-builtin-literals
1919
- id: trailing-whitespace
2020

21-
- repo: https://github.com/psf/black
22-
rev: 22.10.0
23-
hooks:
24-
- id: black
25-
26-
- repo: https://github.com/PyCQA/isort
27-
rev: 5.10.1
28-
hooks:
29-
- id: isort
30-
files: \.py$
31-
32-
- repo: https://github.com/pre-commit/mirrors-mypy
33-
rev: v0.982
34-
hooks:
35-
- id: mypy
36-
additional_dependencies: [types-requests]
37-
38-
- repo: https://github.com/abravalheri/validate-pyproject
39-
rev: v0.10.1
21+
- repo: https://github.com/python-jsonschema/check-jsonschema
22+
rev: 0.19.2
4023
hooks:
41-
- id: validate-pyproject
42-
stages: [manual]
24+
- id: check-github-workflows
4325

4426
- repo: https://github.com/executablebooks/mdformat
4527
rev: 0.7.16
4628
hooks:
4729
- id: mdformat
30+
additional_dependencies:
31+
[mdformat-gfm, mdformat-frontmatter, mdformat-footnote]
4832

49-
- repo: https://github.com/asottile/pyupgrade
50-
rev: v3.0.0
51-
hooks:
52-
- id: pyupgrade
53-
args: [--py37-plus]
54-
55-
- repo: https://github.com/PyCQA/doc8
56-
rev: v1.0.0
57-
hooks:
58-
- id: doc8
59-
args: [--max-line-length=200]
60-
exclude: docs/source/other/full-config.rst
61-
stages: [manual]
62-
63-
- repo: https://github.com/john-hen/Flake8-pyproject
64-
rev: 1.0.1
33+
- repo: https://github.com/psf/black
34+
rev: 22.10.0
6535
hooks:
66-
- id: Flake8-pyproject
67-
alias: flake8
68-
additional_dependencies:
69-
["flake8-bugbear==22.6.22", "flake8-implicit-str-concat==0.2.0"]
70-
stages: [manual]
36+
- id: black
7137

72-
- repo: https://github.com/sirosen/check-jsonschema
73-
rev: 0.18.3
38+
- repo: https://github.com/charliermarsh/ruff-pre-commit
39+
rev: v0.0.165
7440
hooks:
75-
- id: check-jsonschema
76-
name: "Check GitHub Workflows"
77-
files: ^\.github/workflows/
78-
types: [yaml]
79-
args: ["--schemafile", "https://json.schemastore.org/github-workflow"]
80-
stages: [manual]
41+
- id: ruff
42+
args: ["--fix"]
Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,38 @@
11
[build-system]
2-
requires = ["hatchling>=1.0"]
2+
requires = ["hatchling>=1.5"]
33
build-backend = "hatchling.build"
44

55
[project]
66
name = "{{cookiecutter.package_name}}"
77
authors = [{name = "{{cookiecutter.author_name}}", email = "{{cookiecutter.author_email}}"}]
88
dynamic = ["version"]
99
readme = "README.md"
10-
requires-python = ">=3.7"
10+
requires-python = ">=3.8"
1111
keywords = ["Jupyter", "Extension"]
1212
classifiers = [
1313
"License :: OSI Approved :: BSD License",
1414
"Programming Language :: Python",
1515
"Programming Language :: Python :: 3",
16-
"Programming Language :: Python :: 3.7",
1716
"Programming Language :: Python :: 3.8",
1817
"Programming Language :: Python :: 3.9",
1918
"Programming Language :: Python :: 3.10",
19+
"Programming Language :: Python :: 3.11",
2020
"Framework :: Jupyter",
2121
]
22-
dependencies = ["jupyter_server>=1.6,<2"]
22+
dependencies = ["jupyter_server>=1.6,<3"]
2323

2424
[project.optional-dependencies]
2525
test = [
2626
"pytest>=7.0",
27-
"jupyter_server[test]"
27+
"pytest-jupyter[server]>=0.6"
2828
]
29+
lint = [
30+
"black>=22.6.0",
31+
"mdformat>0.7",
32+
"mdformat-gfm>=0.3.5",
33+
"ruff>=0.0.156"
34+
]
35+
typing = ["mypy>=0.990"]
2936

3037
[project.license]
3138
file="LICENSE"
@@ -39,12 +46,6 @@ path = "{{ cookiecutter.package_name }}/__init__.py"
3946
[tool.hatch.build.targets.wheel.shared-data]
4047
"jupyter-config" = "etc/jupyter"
4148

42-
[tool.black]
43-
line_length = 100
44-
45-
[tool.isort]
46-
profile = "black"
47-
4849
[tool.pytest.ini_options]
4950
filterwarnings = [
5051
"error",
@@ -66,23 +67,27 @@ warn_unused_configs = true
6667
warn_unused_ignores = true
6768
warn_redundant_casts = true
6869

69-
[tool.flake8]
70-
ignore = "E501, W503, E402"
71-
builtins = "c, get_config"
72-
exclude = [
73-
".cache",
74-
".github",
75-
"docs",
76-
"setup.py",
77-
]
78-
enable-extensions = "G"
79-
extend-ignore = [
80-
"G001", "G002", "G004", "G200", "G201", "G202",
81-
# black adds spaces around ':'
82-
"E203",
70+
[tool.black]
71+
line-length = 100
72+
target-version = ["py38"]
73+
skip-string-normalization = true
74+
75+
[tool.ruff]
76+
target-version = "py38"
77+
line-length = 100
78+
select = [
79+
"A", "B", "C", "E", "F", "FBT", "I", "N", "Q", "RUF", "S", "T",
80+
"UP", "W", "YTT",
8381
]
84-
per-file-ignores = [
85-
# B011: Do not call assert False since python -O removes these calls
86-
# F841 local variable 'foo' is assigned to but never used
87-
"tests/*: B011", "F841",
82+
ignore = [
83+
# Q000 Single quotes found but double quotes preferred
84+
"Q000",
85+
# FBT001 Boolean positional arg in function definition
86+
"FBT001", "FBT002", "FBT003",
87+
# C901 `foo` is too complex (12)
88+
"C901",
8889
]
90+
91+
[tool.ruff.per-file-ignores]
92+
# S101 Use of `assert` detected
93+
"{{cookiecutter.package_name}}/tests/*" = ["S101"]

0 commit comments

Comments
 (0)