diff --git a/.codeclimate.yml b/.codeclimate.yml deleted file mode 100644 index 1d04a03..0000000 --- a/.codeclimate.yml +++ /dev/null @@ -1,28 +0,0 @@ -# Python Engines -engines: - duplication: - enabled: true - config: - languages: - - python - fixme: - enabled: true - pep8: - enabled: true - radon: - enabled: true - markdownlint: - enabled: true - -# Ratings -ratings: - paths: - - "**.py" # default for enable Radon analysis - - "**.md" - - "**.inc" - - "**.module" - -# List the files or directories excluded from analysis. -exclude_paths: -- dist/** -- build/** diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..6ac5355 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,50 @@ +name: Publish Python distributions +on: + push: + tags: + - '*' + workflow_dispatch: + +jobs: + release: + name: Release + runs-on: ubuntu-latest + steps: + - name: Checkout sendgrid-python-smtpapi + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.6' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build + pip install wheel + python setup.py sdist bdist_wheel + + - name: Publish package to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.PYPI_TOKEN }} + + notify-on-failure: + name: Slack notify on failure + if: ${{ failure() }} + needs: [ release ] + runs-on: ubuntu-latest + steps: + - uses: rtCamp/action-slack-notify@v2 + env: + SLACK_COLOR: 'danger' + SLACK_ICON_EMOJI: ':github:' + SLACK_MESSAGE: ${{ format('Failed to release {1}{3} {0}/{1}/actions/runs/{2}', github.server_url, github.repository, github.run_id, ':') }} + SLACK_TITLE: Release Failure + SLACK_USERNAME: GitHub Actions + SLACK_MSG_AUTHOR: twilio-dx + SLACK_FOOTER: Posted automatically using GitHub Actions + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + MSG_MINIMAL: true diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..2c558f1 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,50 @@ +name: Run Tests +on: + push: + branches: [ '*' ] + pull_request: + branches: [ main ] + schedule: + # Run automatically at 8AM PST Monday-Friday + - cron: '0 15 * * 1-5' + workflow_dispatch: + +jobs: + tests: + name: Run Tests + runs-on: ubuntu-latest + timeout-minutes: 20 + strategy: + matrix: + python-version: [ '2.7', '3.5', '3.6', '3.7', '3.8', '3.9' ] + steps: + - name: Checkout sendgrid-python-smtpapi + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Build & Test + run: make install test-install test + + notify-on-failure: + name: Slack notify on failure + if: ${{ failure() && github.ref == 'refs/heads/main' && github.event_name != 'pull_request' }} + needs: [ tests ] + runs-on: ubuntu-latest + steps: + - uses: rtCamp/action-slack-notify@v2 + env: + SLACK_COLOR: 'danger' + SLACK_ICON_EMOJI: ':github:' + SLACK_MESSAGE: ${{ format('Failed running build on {1}{3} {0}/{1}/actions/runs/{2}', github.server_url, github.repository, github.run_id, ':') }} + SLACK_TITLE: Build Failure + SLACK_USERNAME: GitHub Actions + SLACK_MSG_AUTHOR: twilio-dx + SLACK_FOOTER: Posted automatically using GitHub Actions + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + MSG_MINIMAL: true diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index c100c79..0000000 --- a/.travis.yml +++ /dev/null @@ -1,39 +0,0 @@ -dist: xenial -language: python -python: -- '2.7' -- '3.4' -- '3.5' -- '3.6' -- '3.7' -- '3.8' -- '3.9' -install: -- make install -- make test-install -- pip install codecov -script: -- make test -- ". venv/bin/activate; coverage run test/__init__.py" -- ". venv/bin/activate; flake8 --statistics --count" -after_success: -- codecov -deploy: - provider: pypi - user: __token__ - password: "$PYPI_TOKEN" - skip_cleanup: true - distributions: sdist bdist_wheel - on: - branch: main - condition: "$TRAVIS_TEST_RESULT = 0" - tags: true - python: '3.6' -notifications: - slack: - if: branch = main - on_pull_requests: false - on_success: never - on_failure: change - rooms: - secure: btNfACha/8fuIMDdeUyMywSryI/XGm5ZE+cUEKo6l1Z6CX4VcnMCjNPGbj9GEL6jk0PDxBbdyEslci3dzt5ApOBMFg7OWTcPxDKoKNLHnUvEe2VPblZN0O1N/RAM3OPkhpbToo/uyZmnHIqTmOT51RfA1mkUYtu5YgPF+bwjhv0= diff --git a/Makefile b/Makefile index 7cff157..3e3bb1a 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,7 @@ venv: @python --version || (echo "Python is not installed, please install Python 2 or Python 3"; exit 1); + pip install virtualenv virtualenv --python=python venv install: venv @@ -13,6 +14,8 @@ test-install: test: . venv/bin/activate; python -m unittest discover -v . venv/bin/activate; python test/__init__.py + . venv/bin/activate; flake8 --statistics --count + . venv/bin/activate; coverage run test/__init__.py clean: nopyc rm -rf venv diff --git a/README.rst b/README.rst index f8c4769..d1fd087 100644 --- a/README.rst +++ b/README.rst @@ -2,7 +2,7 @@ :target: https://www.sendgrid.com :alt: SendGrid Logo -|Travis Badge| |Twitter Follow| |Codecov branch| |Python Versions| |PyPI Version| |GitHub contributors| |MIT Licensed| +|Tests Badge| |Twitter Follow| |Codecov branch| |Python Versions| |PyPI Version| |GitHub contributors| |MIT Licensed| **This module helps build SendGrid's SMTP API headers.** @@ -121,8 +121,8 @@ License .. _Review Pull Requests: https://github.com/sendgrid/smtpapi-python/blob/HEAD/CONTRIBUTING.md#code-reviews) .. _The MIT License (MIT): https://github.com/sendgrid/smtpapi-python/blob/HEAD/LICENSE -.. |Travis Badge| image:: https://travis-ci.com/sendgrid/smtpapi-python.svg?branch=main - :target: https://travis-ci.com/sendgrid/smtpapi-python +.. |Tests Badge| image:: https://github.com/sendgrid/smtpapi-python/actions/workflows/tests.yml/badge.svg + :target: https://github.com/sendgrid/smtpapi-python/actions/workflows/tests.yml .. |Twitter Follow| image:: https://img.shields.io/twitter/follow/sendgrid.svg?style=social&label=Follow :target: https://twitter.com/sendgrid .. |Codecov branch| image:: https://img.shields.io/codecov/c/github/sendgrid/smtpapi-python/main.svg?style=flat-square&label=Codecov+Coverage diff --git a/test/__init__.py b/test/__init__.py index 00ff8b8..d195960 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -106,12 +106,10 @@ def setUp(self): self.required_files = [ './Dockerfile', - './.codeclimate.yml', './.env_sample', './ISSUE_TEMPLATE.md', './PULL_REQUEST_TEMPLATE.md', './.gitignore', - './.travis.yml', './CHANGELOG.md', './CODE_OF_CONDUCT.md', './CONTRIBUTING.md', diff --git a/test/test_project.py b/test/test_project.py index 5da99fa..5de7ec9 100644 --- a/test/test_project.py +++ b/test/test_project.py @@ -26,14 +26,6 @@ def test_env(self): def test_gitignore(self): self.assertTrue(os.path.isfile('./.gitignore')) - # ./.travis.yml - def test_travis(self): - self.assertTrue(os.path.isfile('./.travis.yml')) - - # ./.codeclimate.yml - def test_codeclimate(self): - self.assertTrue(os.path.isfile('./.codeclimate.yml')) - # ./CHANGELOG.md def test_changelog(self): self.assertTrue(os.path.isfile('./CHANGELOG.md'))