Skip to content

Commit

Permalink
Import skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
ross committed Aug 20, 2023
0 parents commit 5b83fb6
Show file tree
Hide file tree
Showing 26 changed files with 831 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .git_hooks_pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh

set -e

HOOKS=$(dirname "$0")
GIT=$(dirname "$HOOKS")
ROOT=$(dirname "$GIT")

. "$ROOT/env/bin/activate"
"$ROOT/script/lint"
"$ROOT/script/format" --check --quiet || (echo "Formatting check failed, run ./script/format" && exit 1)
"$ROOT/script/coverage"
33 changes: 33 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: octoDNS SpfSource
on: [pull_request, workflow_dispatch]

jobs:
ci:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# Tested versions based on dates in https://devguide.python.org/versions/#versions
python-version: ['3.8', '3.9', '3.10', '3.11']
steps:
- uses: actions/checkout@v2
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- name: CI Build
run: |
./script/cibuild
setup-py:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: '3.11'
architecture: x64
- name: CI setup.py
run: |
./script/cibuild-setup-py
13 changes: 13 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: 'Close stale issues and PRs'
on:
schedule:
- cron: '42 4 * * *'
jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v4
with:
stale-issue-message: 'This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 7 days.'
days-before-stale: 90
days-before-close: 7
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
*.pyc
.coverage
.eggs/
.env
/build/
/config/
coverage.xml
dist/
env/
htmlcov/
nosetests.xml
octodns_*.egg-info/
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## TODO: v0.0.1 - 20??-??-?? - Moving

#### Nothworthy Changes

* Initial extraction of SpfSource from octoDNS core

TODO: anything else

#### Stuff

TODO: anything else
58 changes: 58 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
TODO: Review this README and add or modify as necessary.

## SPF Value Management provider for octoDNS

An [octoDNS](https://github.com/octodns/octodns/) provider that targets [SPF Value Management](https://github.com/octodns/octodns-spf).

### Installation

#### Command line

```
pip install octodns-spf
```

#### requirements.txt/setup.py

Pinning specific versions or SHAs is recommended to avoid unplanned upgrades.

##### Versions

```
# Start with the latest versions and don't just copy what's here
octodns==0.9.14
octodns-spf==0.0.1
```

##### SHAs

```
# Start with the latest/specific versions and don't just copy what's here
-e git+https://git@github.com/octodns/octodns.git@9da19749e28f68407a1c246dfdf65663cdc1c422#egg=octodns
-e git+https://git@github.com/octodns/octodns-spf.git@ec9661f8b335241ae4746eea467a8509205e6a30#egg=octodns_spf
```

### Configuration

```yaml
providers:
spf:
class: octodns_spf.SpfSource
# TODO
```

### Support Information

#### Records

TODO: All octoDNS record types are supported.

#### Dynamic

TODO: SpfSource does not support dynamic records.

### Development

See the [/script/](/script/) directory for some tools to help with the development process. They generally follow the [Script to rule them all](https://github.com/github/scripts-to-rule-them-all) pattern. Most useful is `./script/bootstrap` which will create a venv and install both the runtime and development related requirements. It will also hook up a pre-commit hook that covers most of what's run by CI.

TODO: any provider specific setup, a docker compose to run things locally etc?
12 changes: 12 additions & 0 deletions octodns_spf/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#
#
#

from octodns.provider.base import BaseProvider

__VERSION__ = '0.0.1'


class SpfSource(BaseProvider):
# TODO: implement things
pass
15 changes: 15 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[tool.black]
line-length=80
skip-string-normalization=true
skip-magic-trailing-comma=true

[tool.isort]
profile = "black"
known_first_party="octodns_spf"
known_octodns="octodns"
line_length=80
sections="FUTURE,STDLIB,THIRDPARTY,OCTODNS,FIRSTPARTY,LOCALFOLDER"

[tool.pytest.ini_options]
log_level = 'DEBUG'
pythonpath = "."
44 changes: 44 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# DO NOT EDIT THIS FILE DIRECTLY - use ./script/update-requirements to update
Pygments==2.15.1
black==23.3.0
bleach==6.0.0
build==0.10.0
certifi==2023.5.7
cffi==1.15.1
charset-normalizer==3.1.0
click==8.1.3
cmarkgfm==2022.10.27
coverage==7.2.7
docutils==0.20.1
exceptiongroup==1.1.1
importlib-metadata==6.7.0
iniconfig==2.0.0
isort==5.12.0
jaraco.classes==3.2.3
keyring==24.2.0
markdown-it-py==3.0.0
mdurl==0.1.2
more-itertools==9.1.0
mypy-extensions==1.0.0
packaging==23.1
pathspec==0.11.1
pkginfo==1.9.6
platformdirs==3.8.0
pluggy==1.2.0
pycparser==2.21
pyflakes==3.0.1
pyproject_hooks==1.0.0
pytest-cov==4.1.0
pytest-network==0.0.1
pytest==7.4.0
readme-renderer==40.0
requests-toolbelt==1.0.0
requests==2.31.0
rfc3986==2.0.0
rich==13.4.2
tomli==2.0.1
twine==4.0.2
typing_extensions==4.7.0
urllib3==2.0.3
webencodings==0.5.1
zipp==3.15.0
10 changes: 10 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# TODO: run ./script/update-requirements to fill this and requirements-dev.txt out
# DO NOT EDIT THIS FILE DIRECTLY - use ./script/update-requirements to update
PyYAML==6.0
dnspython==2.3.0
fqdn==1.5.1
idna==3.4
natsort==8.4.0
octodns==0.9.21
python-dateutil==2.8.2
six==1.16.0
58 changes: 58 additions & 0 deletions script/automations/do-patch-and-update-requirements.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash
# patches for use with the script can likely be created with the following
# git format-patch -1 [sha]

set -e

PATCH="$HOME/octodns/octodns-template/tmp/0001-Update-CI-python-versions-remove-3.7.patch"
BRANCH="python-versions"

# make sure we're on main to start
(test $(git rev-parse --abbrev-ref HEAD) != "main" && echo "on branch" && exit 1 || exit 0)

# make sure we're completely up to date with origin
git pull

# create our branch
git checkout -b $BRANCH

# make our patch
patch -p1 --no-backup-if-mismatch < $PATCH

# add and comment changes
git add -p .github/
git commit -m "update CI python versions, remove 3.7"

git add -p setup.py
git commit -m "update setup.py requirement versions now that 3.7 is gone"

# update requirements
./script/update-requirements

# re-bootstrap to make sure those versions are installed
./script/bootstrap

# make any formatting changes
./script/format

# show any lint errors
./script/lint

# add and comment requirements changes
git add -p requirements*.txt
git commit -m "update requirements*.txt"

# if there's any formatting changes add them and then commit them, there
# shouldn't be anything else happening here, if you make non-formatting changes
# for some reason commit those manually
if ! git status --porcelain; then
git add -p
git commit -m "updated black formatting"
fi

# push our current branch
git push -u origin $BRANCH

# and open a PR, this assumes your local handle matches your github handle, if
# not set USER= before running the script
hub pull-request --browse --file /tmp/body.txt -b main -h $BRANCH -a $USER
42 changes: 42 additions & 0 deletions script/automations/do-patch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash
# patches for use with the script can likely be created with the following
# git format-patch -1 [sha]

set -e

PATCH="$1"
BRANCH="$2"
COMMIT_MESSAGE="$3"
PR_MESSAGE="$4"

if [[ -z "$PR_MESSAGE" || ! -e "$PR_MESSAGE" ]]; then
echo "incorrect usage"
exit 1
fi

# make sure we don't have uncommited changes
([[ `git status --porcelain` ]] && echo "local changes" && exit 1 || exit 0)

# make sure we're on main to start
(test $(git rev-parse --abbrev-ref HEAD) != "main" && echo "on branch" && exit 1 || exit 0)

# make sure we're completely up to date with origin
git pull

# create our branch
git checkout -b $BRANCH

# make our patch
patch -p1 --no-backup-if-mismatch < $PATCH

# add and comment changes
# TODO: this doesn't support newly added files...
git add -p
git commit -m "$COMMIT_MESSAGE"

# push our current branch
git push -u origin $BRANCH

# and open a PR, this assumes your local handle matches your github handle, if
# not set USER= before running the script
hub pull-request --browse --file $PR_MESSAGE -b main -h $BRANCH -a $USER
59 changes: 59 additions & 0 deletions script/automations/make-updates.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash

set -e

if [ -z "$1" ]; then
if ! git diff --no-ext-diff --quiet --exit-code; then
echo "local changes"
exit 1
fi

if test $(git rev-parse --abbrev-ref HEAD) != "main"; then
echo "on branch"
exit 1
fi

git pull
git checkout -b isort
fi


MODULE=$(basename "$PWD" | sed 's/-/_/')

sed -e s/octodns_spf/$MODULE/ ~/octodns/octodns-template/pyproject.toml > pyproject.toml

TMP=$(mktemp)
awk "/build.*/ {print; print \" # >=5.12.0 does not support python 3.7, we still do\"; print \" 'isort==5.11.5',\"; next }1" ./setup.py > $TMP
mv $TMP setup.py

perl -i -p0e 's/export PYTHONPATH.*\npytest/pytest/se' script/coverage
perl -i -p0e 's/export PYTHONPATH.*\npytest/pytest/se' script/test

cp ~/octodns/octodns-template/script/format script/format

source env/bin/activate

./script/update-requirements
deactivate
rm -rf env/
./script/bootstrap

source env/bin/activate

git add .
git commit -m "Add isort, use pyproject.toml for isort and black" --no-verify

./script/format

git add .
git commit -m "isort formatting"

echo "# Commit for isort formatting changes" >> .git-blame-ignore-revs
git rev-parse --verify HEAD >> .git-blame-ignore-revs

git add .
git commit -m "ignore isort commit in blame" --no-verify

git pob

hub pull-request --file /tmp/body.txt -b main -h isort -a ross
Loading

0 comments on commit 5b83fb6

Please sign in to comment.