Skip to content

Commit

Permalink
Add commit-hook, Github actions, etc
Browse files Browse the repository at this point in the history
  • Loading branch information
regebro committed Apr 14, 2022
1 parent 8a4d1cd commit bb95b61
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 5 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/syntax.yml
@@ -0,0 +1,28 @@
# Runs the unit tests for the svg.path package
# Based on https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Syntax and style check

on: [pull_request, push]

jobs:
build:
name: Run Syntax and style checks

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Upgrade pip
run: python -m pip install --upgrade pip
- name: Install tools
run: pip install flake8 black
- name: Run black
run: black --quiet --check .
- name: Run flake8
run: flake8 .
30 changes: 30 additions & 0 deletions .github/workflows/test.yml
@@ -0,0 +1,30 @@
# Runs the unit tests for the svg.path package
# Based on https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Test package

on: [pull_request, push]

jobs:
build:
name: Run package tests

runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.7', '3.10']

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Upgrade pip
run: python -m pip install --upgrade pip
- name: Install package
run: pip install -e ".[test]"
- name: Run tests
run: pytest
19 changes: 19 additions & 0 deletions .pre-commit-config.yaml
@@ -0,0 +1,19 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 22.1.0
hooks:
- id: black
- repo: https://github.com/pycqa/flake8
rev: 4.0.1
hooks:
- id: flake8
- repo: https://github.com/regebro/pyroma
rev: '3.2'
hooks:
- id: pyroma
6 changes: 3 additions & 3 deletions hovercraft/generate.py
Expand Up @@ -208,11 +208,11 @@ def generate(args):
for image in tree.iterdescendants("img"):
filename = image.attrib["src"]
source_files.add(copy_resource(filename, sourcedir, args.targetdir))
for source in tree.iterdescendants('source'):
filename = source.attrib['src']
for source in tree.iterdescendants("source"):
filename = source.attrib["src"]
source_files.add(copy_resource(filename, sourcedir, args.targetdir))

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

# Copy any files referenced by url() in the css-files:
for resource in template_info.resources:
Expand Down
5 changes: 4 additions & 1 deletion hovercraft/parse.py
Expand Up @@ -115,7 +115,10 @@ def __init__(self, intree, skip_notes=False):
def _newstep(self, level):
step = etree.Element(
"step",
attrib={"step": str(self.steps), "class": "step step-level-%s" % level,},
attrib={
"step": str(self.steps),
"class": "step step-level-%s" % level,
},
)
self.steps += 1
return step
Expand Down
14 changes: 14 additions & 0 deletions setup.cfg
Expand Up @@ -46,5 +46,19 @@ exclude =
console_scripts =
hovercraft = hovercraft:main

[options.extras_require]
test =
pytest
pytest-cov
manuel

[flake8]
max-line-length=120
ignore = E203

[bdist_wheel]
universal=1

[tool:pytest]
testpaths =
tests
2 changes: 1 addition & 1 deletion tests/test_data/__init__.py
Expand Up @@ -122,7 +122,7 @@
b'<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head>'
b"<title>Presentation title</title>"
b'<meta charset="UTF-8"></meta><meta name="generator" content='
b'"Hovercraft! 1.0 http://regebro.github.com/hovercraft"></meta>'
b'"Hovercraft! 1.0 http://regebro.github.io/hovercraft"></meta>'
b'<link rel="stylesheet" href="css/hovercraft.css" media="all"></link>'
b'<link rel="stylesheet" href="css/highlight.css" media="all"></link>'
b'<link rel="stylesheet" href="extra.css" media="screen"></link>'
Expand Down

0 comments on commit bb95b61

Please sign in to comment.