Skip to content

Commit 37b997a

Browse files
author
Paul Amar
committed
Refactored the code, added some tests
1 parent 5368830 commit 37b997a

16 files changed

Lines changed: 2126 additions & 717 deletions

.github/workflows/publish.yml

Lines changed: 43 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,47 @@
1-
name: Publish Python 🐍 distributions 📦 to PyPI and TestPyPI
2-
on: push
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch: # Allow manual triggering
7+
38
jobs:
4-
build-n-publish:
5-
name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
9+
build-and-publish:
10+
name: Build and publish Python distributions to PyPI
611
runs-on: ubuntu-latest
12+
713
steps:
8-
- uses: actions/checkout@master
9-
- name: Set up Python 3.7
10-
uses: actions/setup-python@v1
14+
- uses: actions/checkout@v4
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@v5
1118
with:
12-
python-version: 3.7
13-
- name: Build and archive the lib
14-
run: python setup.py sdist
15-
# - name: Publish distribution 📦 to Test PyPI
16-
# uses: pypa/gh-action-pypi-publish@master
17-
# with:
18-
# password: ${{ secrets.TEST_PYPI_API_TOKEN }}
19-
# repository_url: https://test.pypi.org/legacy/
20-
- name: Publish distribution 📦 to PyPI
21-
if: startsWith(github.ref, 'refs/tags')
22-
uses: pypa/gh-action-pypi-publish@release/v1
23-
with:
24-
password: ${{ secrets.PYPI_API_TOKEN }}
19+
python-version: '3.11'
20+
21+
- name: Install dependencies
22+
run: |
23+
python -m pip install --upgrade pip
24+
pip install build twine
25+
pip install -r requirements.txt
26+
27+
- name: Build distribution packages
28+
run: python -m build
29+
30+
- name: Check distribution packages
31+
run: twine check dist/*
32+
33+
- name: Publish to Test PyPI
34+
if: github.event_name == 'workflow_dispatch'
35+
env:
36+
TWINE_USERNAME: __token__
37+
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
38+
run: |
39+
twine upload --repository testpypi dist/* --skip-existing || true
40+
41+
- name: Publish to PyPI
42+
if: github.event_name == 'release'
43+
env:
44+
TWINE_USERNAME: __token__
45+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
46+
run: |
47+
twine upload dist/*

.github/workflows/tests.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [ main, master, develop ]
6+
pull_request:
7+
branches: [ main, master, develop ]
8+
9+
jobs:
10+
test:
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
os: [ubuntu-latest, windows-latest, macos-latest]
16+
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Set up Python ${{ matrix.python-version }}
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
26+
- name: Install dependencies
27+
run: |
28+
python -m pip install --upgrade pip
29+
pip install -r requirements.txt
30+
pip install -r requirements-dev.txt
31+
32+
- name: Lint with flake8
33+
run: |
34+
# Stop the build if there are Python syntax errors or undefined names
35+
flake8 dnsdumpster --count --select=E9,F63,F7,F82 --show-source --statistics
36+
# Exit-zero treats all errors as warnings
37+
flake8 dnsdumpster --count --exit-zero --max-complexity=10 --max-line-length=120 --statistics
38+
39+
- name: Type check with mypy
40+
run: |
41+
mypy dnsdumpster --ignore-missing-imports || true
42+
43+
- name: Test with pytest
44+
run: |
45+
pytest tests/ -v --cov=dnsdumpster --cov-report=xml --cov-report=term
46+
47+
- name: Upload coverage to Codecov
48+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
49+
uses: codecov/codecov-action@v3
50+
with:
51+
file: ./coverage.xml
52+
flags: unittests
53+
name: codecov-umbrella
54+
fail_ci_if_error: false
55+
56+
code-quality:
57+
runs-on: ubuntu-latest
58+
59+
steps:
60+
- uses: actions/checkout@v4
61+
62+
- name: Set up Python
63+
uses: actions/setup-python@v5
64+
with:
65+
python-version: '3.11'
66+
67+
- name: Install dependencies
68+
run: |
69+
python -m pip install --upgrade pip
70+
pip install -r requirements-dev.txt
71+
72+
- name: Check code formatting with black
73+
run: |
74+
black --check dnsdumpster/ tests/
75+
76+
- name: Check import sorting with isort
77+
run: |
78+
isort --check-only dnsdumpster/ tests/

.gitignore

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,80 @@
1-
*.swp
1+
# Byte-compiled / optimized / DLL files
22
__pycache__/
33
*.py[cod]
4+
*$py.class
5+
*.so
6+
7+
# Distribution / packaging
8+
.Python
9+
build/
10+
develop-eggs/
11+
dist/
12+
downloads/
13+
eggs/
14+
.eggs/
15+
lib/
16+
lib64/
17+
parts/
18+
sdist/
19+
var/
20+
wheels/
21+
pip-wheel-metadata/
22+
share/python-wheels/
23+
*.egg-info/
24+
.installed.cfg
25+
*.egg
26+
MANIFEST
27+
28+
# PyInstaller
29+
*.manifest
30+
*.spec
431

32+
# Unit test / coverage reports
33+
htmlcov/
34+
.tox/
35+
.nox/
36+
.coverage
37+
.coverage.*
38+
.cache
39+
nosetests.xml
40+
coverage.xml
41+
*.cover
42+
*.log
43+
.pytest_cache/
44+
.hypothesis/
45+
46+
# Virtual environments
47+
venv/
48+
env/
49+
ENV/
50+
env.bak/
51+
venv.bak/
52+
53+
# IDEs
54+
.vscode/
55+
.idea/
56+
*.swp
57+
*.swo
58+
*~
59+
.DS_Store
60+
61+
# mypy
62+
.mypy_cache/
63+
.dmypy.json
64+
dmypy.json
65+
66+
# pyright
67+
.pyright/
68+
69+
# Tags
570
tags
71+
TAGS
72+
73+
# Local development
74+
*.local
75+
local/
76+
tmp/
77+
78+
# Documentation builds
79+
docs/_build/
80+
site/

0 commit comments

Comments
 (0)