Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use GitHub Workflow #74

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
55 changes: 55 additions & 0 deletions .github/workflows/notify.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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/[email protected]
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
56 changes: 56 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]

- 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/[email protected]
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
30 changes: 30 additions & 0 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]

- 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
9 changes: 0 additions & 9 deletions .travis.yml

This file was deleted.

32 changes: 32 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
13 changes: 4 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,4 @@ if [ -z "${RELEASE_URL}" ]; then
git push --tags
else
echo "Skipping push to git!"
fi
fi
11 changes: 3 additions & 8 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -24,7 +25,6 @@ passenv =
usedevelop = true
deps =
pytest
pytest-travis-fold
pytest-cov
responses
python-dateutil
Expand Down Expand Up @@ -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