From a7e8802854f9a5227bb451a690eef7eb7597c27c Mon Sep 17 00:00:00 2001 From: Jennifer Mah Date: Fri, 19 Nov 2021 22:39:22 -0800 Subject: [PATCH 1/3] chore: migrate to GitHub Actions --- .codeclimate.yml | 7 ----- .github/workflows/release.yml | 48 +++++++++++++++++++++++++++++++++ .github/workflows/tests.yaml | 51 +++++++++++++++++++++++++++++++++++ .travis.yml | 45 ------------------------------- Makefile | 1 + README.rst | 4 +-- tests/test_repofiles.py | 2 -- 7 files changed, 102 insertions(+), 56 deletions(-) delete mode 100644 .codeclimate.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/tests.yaml delete mode 100644 .travis.yml diff --git a/.codeclimate.yml b/.codeclimate.yml deleted file mode 100644 index dd2104f..0000000 --- a/.codeclimate.yml +++ /dev/null @@ -1,7 +0,0 @@ -engines: - pep8: - enabled: true - -ratings: - paths: - - "**.py" \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..a028029 --- /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-http-client + 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.yaml b/.github/workflows/tests.yaml new file mode 100644 index 0000000..232d96c --- /dev/null +++ b/.github/workflows/tests.yaml @@ -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-http-client + 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 f4aef1d..0000000 --- a/.travis.yml +++ /dev/null @@ -1,45 +0,0 @@ -dist: xenial -language: python -cache: pip -python: -- '2.7' -- '3.4' -- '3.5' -- '3.6' -- '3.7' -- '3.8' -- '3.9' -before_install: -- pip install pycodestyle coverage codecov -- if [[ "$TRAVIS_PYTHON_VERSION" == 2.7* ]]; then pip install mock; fi -install: -- pip install virtualenv --upgrade -- make install -- make test-install -script: -- pycodestyle --exclude=venv -- coverage run -m unittest discover -after_script: -- codecov -- make test -- coverage run tests/test_unit.py -after_success: -- codecov -deploy: - provider: pypi - user: __token__ - password: "$PYPI_TOKEN" - skip_cleanup: true - 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: LQ9fGMn/Hfj//uFbQh8t/3yw2Ymq9WUWpErnWEZf++/cmrNNqvu/qaRTgadqzdHFIzqzO9A/HF88t+IRpih8aHmNBp4Sa1IXjWtNniXs9qZIGSL74kEgMpY+PIF5zO8LBKaAmZ1/h3NmAsJa616EMdpksr/Uk/WTs/98cmBrOxpdKrkqHtbf4WK5oJcakdeaGd9o9WWt8n2QoMAFoYSFV1BUDVyni3HJTTx+eLOXwInqWP+rRYBomVVyyYvJ1IOZWkZlnLY5BvudOpyzAeYI3KKpDw1O4Z0SlIEh2TmtakxgIK5qxnrDJ7B265dH2S5bk3oqjBNb1VA9Hiz/m02GB+pbJtiftYNCcTXN9pnIJHEhfRxpTTf+QMJrVPpHC+t3LUtpAZX8frcZKtDwkVxrG9y0WTEa4qZpWM0qisyHB72Q2rVXnWHWs1TxIsxYJCxzJ0bLB256LxLkvNxPFyNMmcmDFG0n4wVSWhems5+Dh1H191k9BaSMedtRrMu7CVPkessaEo2o/mpIYF4Xe7Y871VqGEPyzA1NG1Vttb18N0ZGUjxoqW4EuQrGxMY1/WWao91pTY0G8O8k5yyp12AkuzwhJXWQcjRsCG15YrarZmOxMsVG04BKGuFkiprV/0SRFg3sU+FUcBDv7Bvqg2JpKyzwhsEr+MleYquHCjg3/ZI= diff --git a/Makefile b/Makefile index 9a9a676..03bba25 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 diff --git a/README.rst b/README.rst index 59f6541..9565acb 100644 --- a/README.rst +++ b/README.rst @@ -157,8 +157,8 @@ License .. _The MIT License (MIT): https://github.com/sendgrid/python-http-client/blob/HEAD/LICENSE .. _this is an incredible opportunity to join our #DX team: https://sendgrid.com/careers/role/1421152/?gh_jid=1421152 -.. |Build Status| image:: https://travis-ci.com/sendgrid/python-http-client.svg?branch=main - :target: https://travis-ci.com/sendgrid/python-http-client +.. |Build Status| image:: https://github.com/sendgrid/sendgrid-python/actions/workflows/test.yml/badge.svg + :target: https://github.com/sendgrid/sendgrid-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/python-http-client/main.svg?style=flat-square&label=Codecov+Coverage diff --git a/tests/test_repofiles.py b/tests/test_repofiles.py index 1de1990..de55605 100644 --- a/tests/test_repofiles.py +++ b/tests/test_repofiles.py @@ -8,8 +8,6 @@ class RepoFiles(unittest.TestCase): ['./docker-compose.yml', './docker/docker-compose.yml'], ['./.env_sample'], ['./.gitignore'], - ['./.travis.yml'], - ['./.codeclimate.yml'], ['./CHANGELOG.md'], ['./CODE_OF_CONDUCT.md'], ['./CONTRIBUTING.md'], From 34d89821b70cd1c4ba448acc54e81f7295b9a6c0 Mon Sep 17 00:00:00 2001 From: Jennifer Mah Date: Mon, 29 Nov 2021 13:35:54 -0800 Subject: [PATCH 2/3] remove codecov and update deploys to release --- .github/workflows/release.yml | 8 ++++---- .github/workflows/tests.yaml | 1 - README.rst | 6 +++--- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a028029..69d61fc 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-http-client @@ -39,8 +39,8 @@ jobs: 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.yaml b/.github/workflows/tests.yaml index 232d96c..e4ca29f 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -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 9565acb..f0cd923 100644 --- a/README.rst +++ b/README.rst @@ -1,7 +1,7 @@ .. image:: https://github.com/sendgrid/sendgrid-python/raw/HEAD/twilio_sendgrid_logo.png :target: https://www.sendgrid.com -|Build Status| |Twitter Follow| |Codecov branch| |Code Climate| |Python Versions| |PyPI Version| |GitHub contributors| |MIT licensed| +|Test Status| |Twitter Follow| |Codecov branch| |Code Climate| |Python Versions| |PyPI Version| |GitHub contributors| |MIT licensed| **The default branch name for this repository has been changed to `main` as of 07/27/2020.** @@ -157,8 +157,8 @@ License .. _The MIT License (MIT): https://github.com/sendgrid/python-http-client/blob/HEAD/LICENSE .. _this is an incredible opportunity to join our #DX team: https://sendgrid.com/careers/role/1421152/?gh_jid=1421152 -.. |Build Status| image:: https://github.com/sendgrid/sendgrid-python/actions/workflows/test.yml/badge.svg - :target: https://github.com/sendgrid/sendgrid-python/actions/workflows/tests.yml +.. |Test Status| image:: https://github.com/sendgrid/python-http-client/actions/workflows/tests.yml/badge.svg + :target: https://github.com/sendgrid/python-http-client/actions/workflows/tests.yaml .. |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/python-http-client/main.svg?style=flat-square&label=Codecov+Coverage From bc0ed525de8183bd7c9c53ad75eeac4fae75f087 Mon Sep 17 00:00:00 2001 From: Jennifer Mah Date: Wed, 1 Dec 2021 11:43:09 -0800 Subject: [PATCH 3/3] fix: add wheel install and python distribution to release GH action --- .github/workflows/release.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 69d61fc..99109c8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,6 +22,9 @@ 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