diff --git a/.github/workflows/notify.yml b/.github/workflows/notify.yml new file mode 100644 index 0000000..2dbad5d --- /dev/null +++ b/.github/workflows/notify.yml @@ -0,0 +1,55 @@ +name: Notify on Workflow Complete + +on: + workflow_run: + workflows: [verify, release] + types: + - completed + +jobs: + notify: + runs-on: ubuntu-latest + steps: + - name: Send Slack Notification On Success + uses: slackapi/slack-github-action@v1.18.0 + if: github.event.workflow_run.conclusion == 'success' + with: + # For posting a rich message using Block Kit + payload: | + { + "text": "[vinyldns-python] ${{ github.event.workflow.name }} workflow completed successfully!\nAction: ${{ github.event.workflow_run.html_url }}", + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": ":check_mark: [vinyldns-python] `${{ github.event.workflow.name }}` workflow completed successfully!\nAction: ${{ github.event.workflow_run.html_url }}" + } + } + ] + } + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} + SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK + + - name: Send Slack Notification on Failure + uses: slackapi/slack-github-action@v1.18.0 + if: github.event.workflow_run.conclusion != 'success' + with: + # For posting a rich message using Block Kit + payload: | + { + "text": "[vinyldns-python] ${{ github.event.workflow.name }} FAILED!\nAction: ${{ github.event.workflow_run.html_url }}", + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": ":x: [vinyldns-python] `${{ github.event.workflow.name }}` FAILED!\nAction: ${{ github.event.workflow_run.html_url }}" + } + } + ] + } + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} + SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..d5e396a --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,56 @@ +# This GitHub action can publish assets for release when a tag is created. +# Currently, it's setup to run on any tag that matches the pattern "v*" (ie. v0.1.0). + +name: Release +on: + push: + tags: + - 'v*' + +jobs: + deploy: + + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2.4.0 + + - name: Set up Python 3.9 + uses: actions/setup-python@v2 + with: + python-version: "3.9" + + - name: Install Dependencies + run: make install + shell: bash + + - name: Run tests + run: make test + shell: bash + + - name: Build package + run: make build + shell: bash + + - name: Publish package + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} + + - name: Get current version + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + id: get-version + run: echo "::set-output name=CURRENT_VERSION::$(cat setup.cfg | head -2 | tail -1 | awk -F= '{print $2}'| sed 's/ //g')" + + - name: Create Release + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + uses: softprops/action-gh-release@v0.1.13 + with: + name: Release v${{ steps.get-version.outputs.CURRENT_VERSION }} + tag_name: v${{ steps.get-version.outputs.CURRENT_VERSION }} + draft: true + prerelease: true + generate_release_notes: true \ No newline at end of file diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml new file mode 100644 index 0000000..85d03bd --- /dev/null +++ b/.github/workflows/verify.yml @@ -0,0 +1,30 @@ +name: Verify + +on: + pull_request: + branches: [ '*' ] + push: + branches: [ main ] + workflow_dispatch: + +jobs: + test: + + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2.4.0 + + - name: Set up Python 3.9 + uses: actions/setup-python@v2 + with: + python-version: "3.9" + + - name: Install Dependencies + run: make install + shell: bash + + - name: Run tests + run: make test + shell: bash \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 2bf5f90..0000000 --- a/.travis.yml +++ /dev/null @@ -1,9 +0,0 @@ -sudo: false -language: python -python: -- "2.7" -- "3.6" - -before_install: export BOTO_CONFIG=/dev/null -install: pip install tox-travis -script: tox diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d6677e4 --- /dev/null +++ b/Makefile @@ -0,0 +1,32 @@ +SHELL=bash + +# Check that the required version of make is being used +REQ_MAKE_VER:=3.82 +ifneq ($(REQ_MAKE_VER),$(firstword $(sort $(MAKE_VERSION) $(REQ_MAKE_VER)))) + $(error The version of MAKE $(REQ_MAKE_VER) or higher is required; you are running $(MAKE_VERSION)) +endif + +.ONESHELL: + +.PHONY: install +install: + @set -euo pipefail + echo "Updating pip" + python -m pip install --upgrade pip + echo "Installing dependencies" + pip install virtualenv + chmod +x bootstrap.sh + bash bootstrap.sh + +.PHONY: test +test: + @set -euo pipefail + echo "Running unit and functional tests" + tox -e check,py39,func_test + +.PHONY: build +build: + @set -euo pipefail + echo "Clearing the dist directory..." + rm -rf dist + python setup.py sdist bdist_wheel \ No newline at end of file diff --git a/README.md b/README.md index f3fed66..77d7e59 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ To run, `pip install vinyldns-python` and then: * `python3` * `pip` * `virtualenv` +* `docker` To get started, you will want to setup your virtual environment. @@ -43,25 +44,19 @@ To get started, you will want to setup your virtual environment. Unit tests are developed using [pytest](https://docs.pytest.org/en/latest/). We use [Responses](https://github.com/getsentry/responses), which allows for simple mocking of HTTP endpoints. -To run unit tests, you can simply run `python3 setup.py test`. To target a specific test, you can +To run unit tests, you can simply run `python3 setup.py test` from your virtualenv. To target a specific test, you can run `python3 setup.py test -a "-k my_test"` **Functional Tests** -Functional tests are also developed with pytest. These tests run against a local instance of VinylDNS. Note that for now -they are not tied into our travis build, so they must be run locally for validation. +Functional tests are also developed with pytest. These tests run against a local instance of VinylDNS. From your virtualenv, run `tox -e func_test` **Running a full build** When you are finished writing your code you will want to run everything including linters. The -simplest way to do this is to run `tox -e check,py36`, which will run static checks and run unit tests. - -If you see any failures / warnings, correct them until `tox` runs successfully. - -If you do not have `tox` in your environment, `pip install tox` to add it. For more information you can -read the [tox docs](https://tox.readthedocs.io/en/latest/index.html). +simplest way to do this is to run `tox -e check,py39,func_test` from virtualenv, which will run static checks and run unit tests, functional tests. ## Local Development See the [quickstart](https://github.com/vinyldns/vinyldns/blob/master/README.md#quickstart) in the diff --git a/bootstrap.sh b/bootstrap.sh index 56b9895..f7a29f7 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -7,3 +7,6 @@ python3 setup.py install echo "Installing twine..." pip install twine + +echo "Installing tox, docker-compose and wheel..." +pip install tox docker-compose wheel \ No newline at end of file diff --git a/release.sh b/release.sh index 65bca76..a851abe 100755 --- a/release.sh +++ b/release.sh @@ -94,4 +94,4 @@ if [ -z "${RELEASE_URL}" ]; then git push --tags else echo "Skipping push to git!" -fi +fi \ No newline at end of file diff --git a/tox.ini b/tox.ini index 09bcdff..7002595 100644 --- a/tox.ini +++ b/tox.ini @@ -4,17 +4,18 @@ envlist = clean, check, - {py27,py34,py35,py36,py37}, + {py27,py35,py36,py37,py38,py39}, report, func_test [testenv] basepython = py27: {env:TOXPYTHON:python2.7} - py34: {env:TOXPYTHON:python3.4} py35: {env:TOXPYTHON:python3.5} py36: {env:TOXPYTHON:python3.6} py37: {env:TOXPYTHON:python3.7} + py38: {env:TOXPYTHON:python3.8} + py39: {env:TOXPYTHON:python3.9} {clean,check,report,codecov,func_test}: {env:TOXPYTHON:python3} setenv = PYTHONPATH={toxinidir}/tests @@ -24,7 +25,6 @@ passenv = usedevelop = true deps = pytest - pytest-travis-fold pytest-cov responses python-dateutil @@ -70,8 +70,3 @@ commands = {posargs:pytest -vv func_tests} whitelist_externals = bash - -[travis] -python = - 2.7: check, py27 - 3.6: check, py36, func_test