From e1057f42ac5c3ab1727b867d024c5cccc6eb804d Mon Sep 17 00:00:00 2001 From: Jennifer Mah Date: Sat, 20 Nov 2021 11:07:28 -0800 Subject: [PATCH 1/3] chore: migrate to GitHub Actions --- .codeclimate.yml | 28 ------------------- .github/workflows/release.yml | 48 +++++++++++++++++++++++++++++++++ .github/workflows/tests.yml | 51 +++++++++++++++++++++++++++++++++++ .travis.yml | 39 --------------------------- Makefile | 3 +++ test/__init__.py | 2 -- test/test_project.py | 8 ------ 7 files changed, 102 insertions(+), 77 deletions(-) delete mode 100644 .codeclimate.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/tests.yml delete mode 100644 .travis.yml 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..1f2cb48 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,48 @@ +name: Publish Python distributions +on: + push: + tags: + - '*' + workflow_dispatch: + +jobs: + deploy: + name: Deploy + 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 + + - 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: [ deploy ] + runs-on: ubuntu-latest + steps: + - uses: rtCamp/action-slack-notify@v2 + env: + SLACK_COLOR: 'danger' + SLACK_ICON_EMOJI: ':github:' + SLACK_MESSAGE: ${{ format('Failed to deploy {1}{3} {0}/{1}/actions/runs/{2}', github.server_url, github.repository, github.run_id, ':') }} + SLACK_TITLE: Deployment 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..4ae2a24 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,51 @@ +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 + - run: bash <(curl -s https://codecov.io/bash) + + 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/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')) From 2c7ec1ea0ade20741a234f94e9ba8cc1194c8a83 Mon Sep 17 00:00:00 2001 From: Jennifer Mah Date: Mon, 29 Nov 2021 13:36:14 -0800 Subject: [PATCH 2/3] remove codecov and update deploys to release --- .github/workflows/release.yml | 10 +++++----- .github/workflows/tests.yml | 1 - README.rst | 6 +++--- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1f2cb48..740bcb6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,8 +6,8 @@ on: workflow_dispatch: jobs: - deploy: - name: Deploy + release: + name: Release runs-on: ubuntu-latest steps: - name: Checkout sendgrid-python-smtpapi @@ -32,15 +32,15 @@ jobs: notify-on-failure: name: Slack notify on failure if: ${{ failure() }} - needs: [ deploy ] + 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 deploy {1}{3} {0}/{1}/actions/runs/{2}', github.server_url, github.repository, github.run_id, ':') }} - SLACK_TITLE: Deployment Failure + 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 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4ae2a24..2c558f1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -30,7 +30,6 @@ jobs: - name: Build & Test run: make install test-install test - - run: bash <(curl -s https://codecov.io/bash) notify-on-failure: name: Slack notify on failure 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 From bbdc8a8dec60777b9a6d0c443844be20d9e0bbeb Mon Sep 17 00:00:00 2001 From: Jennifer Mah Date: Wed, 1 Dec 2021 11:32:50 -0800 Subject: [PATCH 3/3] fix: add wheel install and python distribution to release GH action --- .github/workflows/release.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 740bcb6..6ac5355 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,6 +22,8 @@ jobs: 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