Skip to content

Commit

Permalink
Add github actions to lint and run tests (catalyst#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rhys Davies authored Jun 10, 2020
1 parent 55253f4 commit 1ed4cdc
Show file tree
Hide file tree
Showing 9 changed files with 573 additions and 210 deletions.
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
max-complexity = 18

ignore = E203, E266, E501, W503, E722
39 changes: 39 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Lint & Test

on:
- push
- pull_request

jobs:
test:

runs-on: ubuntu-16.04

steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: |
sudo apt-get update && DEBIAN_FRONTEND=noninteractive sudo apt-get install --yes --quiet pdns-server pdns-backend-sqlite3 python3 python3-pip
pip3 install setuptools
pip3 install . -r requirements-dev.txt
- name: Test with pytest
run: |
python3 -m pytest -v
lint:

runs-on: ubuntu-18.04

steps:
- uses: actions/checkout@v2
- name: Install linters
run: |
pip3 install setuptools flake8 black isort
- name: Lint with flake8
run: |
python3 -m flake8 .
- name: Lint with isort
run: |
python3 -m isort --check-only -rc .
- name: Lint with black
run: |
python3 -m black --check --diff .
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,5 @@ ENV/

# mypy
.mypy_cache/

.vscode/
10 changes: 10 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

[settings]
multi_line_output=3
include_trailing_comma=true
force_grid_wrap=0
use_parentheses=true
line_length=88
default_section=THIRDPARTY
known_first_party=powerdns_auth_proxy
no_lines_before=LOCALFOLDER
28 changes: 14 additions & 14 deletions powerdns_auth_proxy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,30 @@
Michael Fincham <[email protected]>
"""

import configparser

from flask import Flask

import configparser

def split_config_values(config, section_pattern):
"""
This turns:
[user:foo]
key=bar
baz=qux thud
In to:
{'foo': {'key': 'bar', 'baz': ['qux', 'thud']}}
"""

return {
section[len(section_pattern):] : {
key.lower(): (value.split() if " " in value else value)
section[len(section_pattern) :]: {
key.lower(): (value.split() if " " in value else value)
for key, value in config.items(section)
}
for section in config.sections()
}
for section in config.sections()
if section.startswith(section_pattern)
}

Expand All @@ -59,15 +60,14 @@ def create_app(configuration=None):
else:
config.read("proxy.ini")

users = split_config_values(config, 'user:')
pdns = split_config_values(config, 'pdns')['']
users = split_config_values(config, "user:")
pdns = split_config_values(config, "pdns")[""]
app.config.from_mapping(
PDNS=pdns,
USERS=users,
PDNS=pdns, USERS=users,
)

from . import proxy

app.register_blueprint(proxy.bp)

return app

Loading

0 comments on commit 1ed4cdc

Please sign in to comment.