Skip to content

Commit bb95b61

Browse files
committed
Add commit-hook, Github actions, etc
1 parent 8a4d1cd commit bb95b61

File tree

7 files changed

+99
-5
lines changed

7 files changed

+99
-5
lines changed

.github/workflows/syntax.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Runs the unit tests for the svg.path package
2+
# Based on https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
name: Syntax and style check
5+
6+
on: [pull_request, push]
7+
8+
jobs:
9+
build:
10+
name: Run Syntax and style checks
11+
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v2
17+
- name: Set up Python 3.9
18+
uses: actions/setup-python@v2
19+
with:
20+
python-version: '3.9'
21+
- name: Upgrade pip
22+
run: python -m pip install --upgrade pip
23+
- name: Install tools
24+
run: pip install flake8 black
25+
- name: Run black
26+
run: black --quiet --check .
27+
- name: Run flake8
28+
run: flake8 .

.github/workflows/test.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Runs the unit tests for the svg.path package
2+
# Based on https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
name: Test package
5+
6+
on: [pull_request, push]
7+
8+
jobs:
9+
build:
10+
name: Run package tests
11+
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
matrix:
15+
os: [ubuntu-latest, macos-latest, windows-latest]
16+
python-version: ['3.7', '3.10']
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v2
21+
- name: Set up Python ${{ matrix.python-version }}
22+
uses: actions/setup-python@v2
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
- name: Upgrade pip
26+
run: python -m pip install --upgrade pip
27+
- name: Install package
28+
run: pip install -e ".[test]"
29+
- name: Run tests
30+
run: pytest

.pre-commit-config.yaml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.1.0
4+
hooks:
5+
- id: check-yaml
6+
- id: end-of-file-fixer
7+
- id: trailing-whitespace
8+
- repo: https://github.com/psf/black
9+
rev: 22.1.0
10+
hooks:
11+
- id: black
12+
- repo: https://github.com/pycqa/flake8
13+
rev: 4.0.1
14+
hooks:
15+
- id: flake8
16+
- repo: https://github.com/regebro/pyroma
17+
rev: '3.2'
18+
hooks:
19+
- id: pyroma

hovercraft/generate.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,11 @@ def generate(args):
208208
for image in tree.iterdescendants("img"):
209209
filename = image.attrib["src"]
210210
source_files.add(copy_resource(filename, sourcedir, args.targetdir))
211-
for source in tree.iterdescendants('source'):
212-
filename = source.attrib['src']
211+
for source in tree.iterdescendants("source"):
212+
filename = source.attrib["src"]
213213
source_files.add(copy_resource(filename, sourcedir, args.targetdir))
214214

215-
RE_CSS_URL = re.compile(br"""url\(['"]?(.*?)['"]?[\)\?\#]""")
215+
RE_CSS_URL = re.compile(rb"""url\(['"]?(.*?)['"]?[\)\?\#]""")
216216

217217
# Copy any files referenced by url() in the css-files:
218218
for resource in template_info.resources:

hovercraft/parse.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,10 @@ def __init__(self, intree, skip_notes=False):
115115
def _newstep(self, level):
116116
step = etree.Element(
117117
"step",
118-
attrib={"step": str(self.steps), "class": "step step-level-%s" % level,},
118+
attrib={
119+
"step": str(self.steps),
120+
"class": "step step-level-%s" % level,
121+
},
119122
)
120123
self.steps += 1
121124
return step

setup.cfg

+14
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,19 @@ exclude =
4646
console_scripts =
4747
hovercraft = hovercraft:main
4848

49+
[options.extras_require]
50+
test =
51+
pytest
52+
pytest-cov
53+
manuel
54+
4955
[flake8]
5056
max-line-length=120
57+
ignore = E203
58+
59+
[bdist_wheel]
60+
universal=1
61+
62+
[tool:pytest]
63+
testpaths =
64+
tests

tests/test_data/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122
b'<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head>'
123123
b"<title>Presentation title</title>"
124124
b'<meta charset="UTF-8"></meta><meta name="generator" content='
125-
b'"Hovercraft! 1.0 http://regebro.github.com/hovercraft"></meta>'
125+
b'"Hovercraft! 1.0 http://regebro.github.io/hovercraft"></meta>'
126126
b'<link rel="stylesheet" href="css/hovercraft.css" media="all"></link>'
127127
b'<link rel="stylesheet" href="css/highlight.css" media="all"></link>'
128128
b'<link rel="stylesheet" href="extra.css" media="screen"></link>'

0 commit comments

Comments
 (0)