mirror of
https://github.com/oskar456/dzonegit.git
synced 2024-05-11 05:55:41 +00:00
Compare commits
18 Commits
v0.11
...
whitespace
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
17cbd099de | ||
|
|
d809e24172 | ||
|
|
35d01a796e | ||
|
|
2f7776c0d1 | ||
|
|
498d4a8b82 | ||
|
|
a96597decb | ||
|
|
8f952086aa | ||
|
|
83a4049821 | ||
|
|
15cdae67ee | ||
|
|
12fb932711 | ||
|
|
cb543514ac | ||
|
|
f9c6a52357 | ||
|
|
24d992d999 | ||
|
|
7cb7c42d76 | ||
|
|
3dd346294a | ||
|
|
03fde74ede | ||
|
|
3769dd22fb | ||
|
|
8d15bb531c |
42
.github/workflows/python-test.yml
vendored
Normal file
42
.github/workflows/python-test.yml
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
|
||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
|
||||
|
||||
name: Python package
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
python-version: [3.6, 3.7, 3.8, 3.9]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Instal BIND 9 utils
|
||||
run: sudo apt-get install -y bind9utils
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install flake8 pytest
|
||||
python -m pip install -e .
|
||||
- name: Lint with flake8
|
||||
run: |
|
||||
# stop the build if there are Python syntax errors or undefined names
|
||||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
||||
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
|
||||
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
||||
- name: Test with pytest
|
||||
run: |
|
||||
pytest
|
||||
16
.travis.yml
16
.travis.yml
@@ -1,16 +0,0 @@
|
||||
before_install:
|
||||
- sudo apt-get install -y bind9utils
|
||||
language: python
|
||||
python:
|
||||
- "3.5"
|
||||
- "3.6"
|
||||
- "nightly"
|
||||
matrix:
|
||||
allow_failures:
|
||||
- python: "nightly"
|
||||
install:
|
||||
- pip install -e .
|
||||
- pip install pytest
|
||||
script:
|
||||
- pytest
|
||||
sudo: false
|
||||
@@ -1,3 +1,6 @@
|
||||
.. image:: https://travis-ci.org/oskar456/dzonegit.svg?branch=master
|
||||
:target: https://travis-ci.org/oskar456/dzonegit
|
||||
|
||||
Git hooks to manage a repository of DNS zones
|
||||
=============================================
|
||||
|
||||
@@ -180,6 +183,9 @@ In the template strings, these placeholders are supported:
|
||||
``$zonefile``
|
||||
Full path to the zone file
|
||||
|
||||
``$zonerelfile``
|
||||
Path to the zone file, relative to checkout path (useful for chroot environments)
|
||||
|
||||
``$zonevar``
|
||||
Per-zone specific variable, see above
|
||||
|
||||
|
||||
@@ -56,9 +56,9 @@ def get_head(empty=False):
|
||||
|
||||
def check_whitespace_errors(against, revision=None):
|
||||
if revision:
|
||||
cmd = ["git", "diff-tree", "--check", against, revision]
|
||||
cmd = ["git", "diff-tree", "--check", against, revision, "*.zone"]
|
||||
else:
|
||||
cmd = ["git", "diff-index", "--check", "--cached", against]
|
||||
cmd = ["git", "diff-index", "--check", "--cached", against, "*.zone"]
|
||||
r = subprocess.run(
|
||||
cmd,
|
||||
stdout=subprocess.PIPE,
|
||||
@@ -119,7 +119,7 @@ def compile_zone(zonename, zonedata, unixtime=None, missing_dot=False):
|
||||
"CompileResults", "success, serial, zonehash, stderr",
|
||||
)
|
||||
r = subprocess.run(
|
||||
["/usr/sbin/named-compilezone", "-o", "-", zonename, "/dev/stdin"],
|
||||
["/usr/bin/env", "named-compilezone", "-o", "-", zonename, "/dev/stdin"],
|
||||
input=unixtime_directive(zonedata, unixtime),
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
@@ -395,7 +395,7 @@ def template_config(checkoutpath, template, blacklist=set(), whitelist=set()):
|
||||
zonevar = defaultvar
|
||||
out.append(itemtpl.substitute(
|
||||
mapping, zonename=zonename,
|
||||
zonefile=str(f), zonevar=zonevar,
|
||||
zonefile=str(f), zonerelfile=str(f.relative_to(checkoutpath)), zonevar=zonevar,
|
||||
))
|
||||
if footertpl.template:
|
||||
out.append(footertpl.substitute(mapping))
|
||||
|
||||
2
setup.py
2
setup.py
@@ -5,7 +5,7 @@ readme = Path(__file__).with_name("README.rst").read_text()
|
||||
|
||||
setup(
|
||||
name="dzonegit",
|
||||
version="0.11",
|
||||
version="0.15",
|
||||
description="Git hooks to manage a repository of DNS zones",
|
||||
long_description=readme,
|
||||
long_description_content_type="text/x-rst",
|
||||
|
||||
@@ -15,6 +15,8 @@ def git_dir(tmpdir_factory):
|
||||
d = tmpdir_factory.getbasetemp()
|
||||
d.chdir()
|
||||
subprocess.call(["git", "init"])
|
||||
subprocess.call(["git", "config", "user.name", "dzonegit pytest"])
|
||||
subprocess.call(["git", "config", "user.email", "nonexistent@example.com"])
|
||||
return d
|
||||
|
||||
|
||||
@@ -25,18 +27,22 @@ def test_get_head(git_dir):
|
||||
subprocess.call(["git", "add", "dummy"])
|
||||
subprocess.call(["git", "commit", "-m", "dummy"])
|
||||
assert dzonegit.get_head() != "4b825dc642cb6eb9a060e54bf8d69288fbee4904"
|
||||
subprocess.call(["git", "update-ref", "-d", "HEAD"])
|
||||
|
||||
|
||||
def test_check_whitespace_errors(git_dir):
|
||||
git_dir.chdir()
|
||||
git_dir.join("whitespace").write(" ")
|
||||
subprocess.call(["git", "add", "whitespace"])
|
||||
dzonegit.check_whitespace_errors(dzonegit.get_head())
|
||||
git_dir.join("whitespace.zone").write(" ")
|
||||
subprocess.call(["git", "add", "whitespace.zone"])
|
||||
with pytest.raises(ValueError):
|
||||
dzonegit.check_whitespace_errors(dzonegit.get_head())
|
||||
subprocess.call(["git", "commit", "-m", "whitespace"])
|
||||
with pytest.raises(ValueError):
|
||||
dzonegit.check_whitespace_errors("HEAD~", dzonegit.get_head())
|
||||
subprocess.call(["git", "rm", "-f", "whitespace"])
|
||||
subprocess.call(["git", "rm", "-f", "whitespace*"])
|
||||
subprocess.call(["git", "commit", "-m", "rm whitespace"])
|
||||
dzonegit.check_whitespace_errors(dzonegit.get_head())
|
||||
dzonegit.check_whitespace_errors("HEAD~", dzonegit.get_head())
|
||||
@@ -122,7 +128,7 @@ def test_get_altered_files(git_dir):
|
||||
assert files == {Path("dummy"), Path("new")}
|
||||
# Refers to test_check_whitespace_errors
|
||||
files = set(dzonegit.get_altered_files("HEAD~", "D", "HEAD"))
|
||||
assert files == {Path("whitespace")}
|
||||
assert files == {Path("whitespace"), Path("whitespace.zone")}
|
||||
subprocess.call(["git", "checkout", "-f", "HEAD"])
|
||||
assert set(dzonegit.get_altered_files("HEAD", "AM")) == set()
|
||||
|
||||
@@ -154,6 +160,7 @@ $ORIGIN eXample.com. ;coment
|
||||
60 IN NS ns
|
||||
ns.example.com. 60 IN A 192.0.2.1
|
||||
"""
|
||||
subprocess.call(["git", "config", "dzonegit.allowfancynames", "FALSE"])
|
||||
assert "example.com" == dzonegit.get_zone_name(
|
||||
"zones/example.com.zone", "",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user