forked from catalyst/powerdns-auth-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add github actions to lint and run tests (catalyst#16)
- Loading branch information
Rhys Davies
authored
Jun 10, 2020
1 parent
55253f4
commit 1ed4cdc
Showing
9 changed files
with
573 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[flake8] | ||
max-complexity = 18 | ||
|
||
ignore = E203, E266, E501, W503, E722 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,3 +101,5 @@ ENV/ | |
|
||
# mypy | ||
.mypy_cache/ | ||
|
||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
} | ||
|
||
|
@@ -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 | ||
|
Oops, something went wrong.