diff --git a/.changelog/b146c7e36d3142c7ad5cac2518c43178.md b/.changelog/b146c7e36d3142c7ad5cac2518c43178.md new file mode 100644 index 0000000..900754c --- /dev/null +++ b/.changelog/b146c7e36d3142c7ad5cac2518c43178.md @@ -0,0 +1,4 @@ +--- +type: none +--- +Pull in the latest template changes \ No newline at end of file diff --git a/.git_hooks_pre-commit b/.git_hooks_pre-commit index cb9fe46..88259f8 100755 --- a/.git_hooks_pre-commit +++ b/.git_hooks_pre-commit @@ -5,10 +5,10 @@ SCRIPT_PATH="$( dirname -- "$( readlink -f -- "${0}"; )"; )/script" # Activate OctoDNS Python venv source "${SCRIPT_PATH}/common.sh" -./script/changelog check -./script/lint -./script/format --check --quiet || ( +"${SCRIPT_PATH}/changelog" check +"${SCRIPT_PATH}/lint" +"${SCRIPT_PATH}/format" --check --quiet || ( echo "Formatting check failed, run ./script/format" && exit 1 ) -./script/coverage +"${SCRIPT_PATH}/coverage" diff --git a/script/bootstrap b/script/bootstrap index 90071ac..a7d85e7 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -26,7 +26,7 @@ python -m pip install -U 'pip>=10.0.1' python -m pip install -r requirements.txt if [ "$ENV" != "production" ]; then - python -m pip install -r requirements-dev.txt -r requirements-docs.txt + python -m pip install -r requirements-dev.txt fi if [ -d ".git" ]; then diff --git a/script/cibuild b/script/cibuild index e652b72..1b2d86d 100755 --- a/script/cibuild +++ b/script/cibuild @@ -1,17 +1,12 @@ -#!/bin/sh - -set -e - -cd "$(dirname "$0")/.." +#!/bin/bash echo "## bootstrap ###################################################################" script/bootstrap -if [ -z "$VENV_NAME" ]; then - VENV_NAME="env" -fi - -. "$VENV_NAME/bin/activate" +# Get current script path +SCRIPT_PATH="$( dirname -- "$( readlink -f -- "${0}"; )"; )" +# Activate OctoDNS Python venv +source "${SCRIPT_PATH}/common.sh" echo "## environment & versions ######################################################" python --version @@ -19,7 +14,7 @@ pip --version echo "## modules: " pip freeze echo "## clean up ####################################################################" -find octodns tests -name "*.pyc" -exec rm {} \; +find octodns tests* -name "*.pyc" -exec rm {} \; rm -f *.pyc echo "## begin #######################################################################" # For now it's just lint... diff --git a/script/cibuild-setup-py b/script/cibuild-setup-py index 13cc9ed..cac4e82 100755 --- a/script/cibuild-setup-py +++ b/script/cibuild-setup-py @@ -18,6 +18,10 @@ python -m build --sdist --wheel echo "## validate wheel install ###################################################" pip install dist/*$VERSION*.whl echo "## validate tests can run against installed code ###############################" -pip install pytest pytest-network +# filename needs to resolved independently as pip requires quoting and doesn't support +# wildcards when installing extra requirements +# (see: https://pip.pypa.io/en/stable/user_guide/#installing-from-wheels) +wheel_file=$(ls dist/*$VERSION*.whl) +pip install "${wheel_file}[test]" pytest --disable-network echo "## complete ####################################################################" diff --git a/script/coverage b/script/coverage index c47d2ca..3b5307c 100755 --- a/script/coverage +++ b/script/coverage @@ -1,25 +1,30 @@ #!/bin/bash # Get current script path -SCRIPT_PATH="$( dirname -- "$( readlink -f -- "${0}"; )"; )" +SCRIPT_PATH="$(dirname -- "$(readlink -f -- "${0}")")" # Activate OctoDNS Python venv source "${SCRIPT_PATH}/common.sh" SOURCE_DIR="octodns/" # Don't allow disabling coverage -grep -r -I --line-number "# pragma: +no.*cover" $SOURCE_DIR && { - echo "Code coverage should not be disabled" +PRAGMA_OUTPUT=$(grep -r -I --line-number "# pragma: \+no.*cover" "$SOURCE_DIR" || echo) +PRAGMA_COUNT=$(echo "$PRAGMA_OUTPUT" | grep -c . || true) +PRAGMA_ALLOWED=2 +if [ "$PRAGMA_COUNT" -gt "$PRAGMA_ALLOWED" ]; then + echo "Found $PRAGMA_COUNT instances of 'pragma: no cover' (no more than $PRAGMA_ALLOWED allowed):" + echo "$PRAGMA_OUTPUT" + echo "Code coverage should not be disabled, except for version handling blocks" exit 1 -} +fi pytest \ - --disable-network \ - --cov-reset \ - --cov=$SOURCE_DIR \ - --cov-fail-under=100 \ - --cov-report=html \ - --cov-report=xml \ - --cov-report=term \ - --cov-branch \ - "$@" + --disable-network \ + --cov-reset \ + --cov=$SOURCE_DIR \ + --cov-fail-under=100 \ + --cov-report=html \ + --cov-report=xml \ + --cov-report=term \ + --cov-branch \ + "$@" diff --git a/script/release b/script/release index f3c18a2..248a8a5 100755 --- a/script/release +++ b/script/release @@ -5,6 +5,8 @@ SCRIPT_PATH="$( dirname -- "$( readlink -f -- "${0}"; )"; )" # Activate OctoDNS Python venv source "${SCRIPT_PATH}/common.sh" +set -o pipefail + PYPYRC="$HOME/.pypirc" if [ ! -e "$PYPYRC" ]; then cat << EndOfMessage >&2 @@ -18,28 +20,12 @@ EndOfMessage exit 1 fi -# Set so that setup.py will create a public release style version number -export OCTODNS_RELEASE=1 - -VERSION="$(grep "^__version__" "$ROOT/octodns/__init__.py" | sed -e "s/.* = '//" -e "s/'$//")" +VERSION="$(grep "^__version__" "octodns/__init__.py" | sed -e "s/.* = '//" -e "s/'$//")" git tag -s "v$VERSION" -m "Release $VERSION" git push origin "v$VERSION" echo "Tagged and pushed v$VERSION" - -TMP_DIR=$(mktemp -d -t ci-XXXXXXXXXX) -git archive --format tar "v$VERSION" | tar xv -C $TMP_DIR -echo "Created clean room $TMP_DIR and archived $VERSION into it" - -(cd "$TMP_DIR" && python -m build --sdist --wheel) - -if [ ! -d dist ]; then - mkdir dist/ -fi - -cp $TMP_DIR/dist/*$VERSION.tar.gz $TMP_DIR/dist/*$VERSION*.whl dist/ -echo "Copied $TMP_DIR/dists into ./dist" - +python -m build --sdist --wheel twine check dist/*$VERSION.tar.gz dist/*$VERSION*.whl twine upload dist/*$VERSION.tar.gz dist/*$VERSION*.whl echo "Uploaded $VERSION"