1
0
mirror of https://github.com/oskar456/dzonegit.git synced 2024-05-11 05:55:41 +00:00

18 Commits

Author SHA1 Message Date
Ondřej Caletka
17cbd099de Version 0.15 2021-12-21 22:28:45 +01:00
Ondřej Caletka
d809e24172 Fixup tests for whitespace error handling 2021-12-21 22:24:17 +01:00
Dominik Pantůček
35d01a796e Apply whitespace check only on *.zone files. 2021-12-21 22:23:09 +01:00
sturmianseq
2f7776c0d1 Reverting the latest commit to avoid state pollution 2021-08-16 23:08:58 +02:00
sturmianseq
498d4a8b82 setup the correct pre-state for test_get_zone_name 2021-08-02 14:32:18 +02:00
Ondřej Caletka
a96597decb Migrate to GitHub Actions (#18)
* Migrate to GitHub Actions

* Drop Python 3.5 test

* Delete .travis.yml
2021-08-02 14:28:07 +02:00
Ondřej Caletka
8f952086aa Version 0.14 2020-05-26 11:12:38 +02:00
Ondřej Caletka
83a4049821 Fix tests when user.name and user.email are not defined
Fixes #15
2020-05-26 11:11:23 +02:00
Ondřej Caletka
15cdae67ee Merge pull request #14 from oskar456/zonerelfile 2020-05-17 11:27:54 +02:00
Ondřej Caletka
12fb932711 Version 0.13
Signed-off-by: Ondřej Caletka <ondrej@caletka.cz>
2020-05-17 11:24:29 +02:00
Ondřej Caletka
cb543514ac Document $zonerelfile template macro
Signed-off-by: Ondřej Caletka <ondrej@caletka.cz>
2020-05-17 11:23:51 +02:00
Przemyslaw Sztoch
f9c6a52357 New macro $zonerelfile in template file. 2020-05-17 11:18:06 +02:00
Ondřej Caletka
24d992d999 Version 0.12 2020-04-13 22:28:24 +02:00
Rob Seastrom
7cb7c42d76 change named-compilezone to use /usr/bin/env rather than absolute path 2020-04-13 22:20:54 +02:00
Ondřej Caletka
3dd346294a Merge pull request #9 from oskar456/travis
Use travis-ci.org as .com was not enabled yet
2019-08-19 15:34:31 +02:00
Ondřej Caletka
03fde74ede Use travis-ci.org as .com was not enabled yet 2019-08-19 15:30:34 +02:00
Michal Halenka
3769dd22fb Include Travis CI status in README 2019-08-19 15:00:49 +02:00
Michal Halenka
8d15bb531c Update .travis.yml
Add new python 3.7 release
Fix indentation
2019-08-19 15:00:26 +02:00
6 changed files with 62 additions and 23 deletions

42
.github/workflows/python-test.yml vendored Normal file
View 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

View File

@@ -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

View File

@@ -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

View File

@@ -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))

View File

@@ -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",

View File

@@ -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", "",
)