diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000000..a4c6a3604d --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,64 @@ +name: Publish Python 🐍 distributions +on: + push: + tags: + - '*' + workflow_dispatch: + +jobs: + deploy: + name: Deploy + runs-on: ubuntu-latest + steps: + - name: Checkout twilio-python + uses: actions/checkout@v2 + + - name: Login to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_TOKEN }} + + # The expression strips off the shortest match from the front of the string to yield just the tag name as the output + - name: Get tagged version + run: echo "GITHUB_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + + - name: Build and Push image + run: make docker-build docker-push + + - 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: Build package + run: python -m 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/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000000..b9c83fc21c --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,54 @@ +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: [ '3.6', '3.7', '3.8', '3.9' ] + steps: + - name: Checkout twilio-python + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Install Dependencies + run: | + pip install virtualenv --upgrade + make install + make test-install + + - name: Run the tests + run: make 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 aa81fe51e4..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,52 +0,0 @@ -dist: xenial -language: python -python: - - "3.6" - - "3.7" - - "3.8" - - "3.9" -services: -- docker -jobs: - include: - - language: python - python: '3.9' - after_success: - - sonar-scanner -install: -- pip install virtualenv --upgrade -- make install -- make test-install -script: -- make test -- if [[ "$TRAVIS_BRANCH" == "main" || "$TRAVIS_BRANCH" == "travis" ]] && [ "$TRAVIS_PULL_REQUEST" - == "false" ]; then echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" - --password-stdin; fi -- make cover -deploy: -- provider: script - script: make docker-build && make docker-push - skip_cleanup: true - on: - tags: true - python: '3.6' -- provider: pypi - skip_cleanup: true - user: __token__ - password: "$PYPI_TOKEN" - on: - tags: true - python: '3.6' -notifications: - slack: - if: branch = main - on_pull_requests: false - on_success: never - on_failure: change - rooms: - secure: FbHzWXjWnpy97v4bmm75T15D0zLBdunEQ3l+w7LqC6cR2nCYOLqcIs2VvwJXXpSbSu9CVzRdMQYfsS7AYi+Fakg93nQOLEtkrhkYiq3yRKXsFVICaJOWPUQbZOdouTKtYZF/0P6FzjdBxbZeD7UW12FKiQ+dL9ncBrgGJExrqFo= -addons: - sonarcloud: - organization: twilio - token: - secure: HVZOSecvGA6z08K3JBzCgxT81UoxB7JUXf8qR7fzzadmXtnnSfkkHFu0XyeUPuCFRRAXQMtxHEib4UsHi3U+vqXRyIDh9fLQanaDMFwDdCuUgVvWeB0PUuf/8bxou8qmhVWNfaLtzEOhCzJXuKWUG8tiURsNy2PaJ2xnNGh3UUY= diff --git a/Makefile b/Makefile index 901acc11ce..0e2ec0f477 100644 --- a/Makefile +++ b/Makefile @@ -54,12 +54,11 @@ nopyc: API_DEFINITIONS_SHA=$(shell git log --oneline | grep Regenerated | head -n1 | cut -d ' ' -f 5) docker-build: docker build -t twilio/twilio-python . - docker tag twilio/twilio-python twilio/twilio-python:${TRAVIS_TAG} + docker tag twilio/twilio-python twilio/twilio-python:${GITHUB_TAG} docker tag twilio/twilio-python twilio/twilio-python:apidefs-${API_DEFINITIONS_SHA} docker tag twilio/twilio-python twilio/twilio-python:latest docker-push: - echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin - docker push twilio/twilio-python:${TRAVIS_TAG} + docker push twilio/twilio-python:${GITHUB_TAG} docker push twilio/twilio-python:apidefs-${API_DEFINITIONS_SHA} docker push twilio/twilio-python:latest diff --git a/README.md b/README.md index 60d10cd63b..ea01b019c3 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # twilio-python -[![Build Status](https://app.travis-ci.com/twilio/twilio-python.svg?branch=main)](https://travis-ci.com/twilio/twilio-python) +[![Tests](https://github.com/twilio/twilio-python/actions/workflows/test.yml/badge.svg)](https://github.com/twilio/twilio-python/actions/workflows/test.yml) [![PyPI](https://img.shields.io/pypi/v/twilio.svg)](https://pypi.python.org/pypi/twilio) [![PyPI](https://img.shields.io/pypi/pyversions/twilio.svg)](https://pypi.python.org/pypi/twilio) [![Learn OSS Contribution in TwilioQuest](https://img.shields.io/static/v1?label=TwilioQuest&message=Learn%20to%20contribute%21&color=F22F46&labelColor=1f243c&style=flat-square&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAMAAAD04JH5AAAASFBMVEUAAAAZGRkcHBwjIyMoKCgAAABgYGBoaGiAgICMjIyzs7PJycnMzMzNzc3UoBfd3d3m5ubqrhfrMEDu7u739/f4vSb/3AD///9tbdyEAAAABXRSTlMAAAAAAMJrBrEAAAKoSURBVHgB7ZrRcuI6EESdyxXGYoNFvMD//+l2bSszRgyUYpFAsXOeiJGmj4NkuWx1Qeh+Ekl9DgEXOBwOx+Px5xyQhDykfgq4wG63MxxaR4ddIkg6Ul3g84vCIcjPBA5gmUMeXESrlukuoK33+33uID8TWeLAdOWsKpJYzwVMB7bOzYSGOciyUlXSn0/ABXTosJ1M1SbypZ4O4MbZuIDMU02PMbauhhHMHXbmebmALIiEbbbbbUrpF1gwE9kFfRNAJaP+FQEXCCTGyJ4ngDrjOFo3jEL5JdqjF/pueR4cCeCGgAtwmuRS6gDwaRiGvu+DMFwSBLTE3+jF8JyuV1okPZ+AC4hDFhCHyHQjdjPHUKFDlHSJkHQXMB3KpSwXNGJPcwwTdZiXlRN0gSp0zpWxNtM0beYE0nRH6QIbO7rawwXaBYz0j78gxjokDuv12gVeUuBD0MDi0OQCLvDaAho4juP1Q/jkAncXqIcCfd+7gAu4QLMACCLxpRsSuQh0igu0C9Svhi7weAGZg50L3IE3cai4IfkNZAC8dfdhsUD3CgKBVC9JE5ABAFzg4QL/taYPAAWrHdYcgfLaIgAXWJ7OV38n1LEF8tt2TH29E+QAoDoO5Ve/LtCQDmKM9kPbvCEBApK+IXzbcSJ0cIGF6e8gpcRhUDogWZ8JnaWjPXc/fNnBBUKRngiHgTUSivSzDRDgHZQOLvBQgf8rRt+VdBUUhwkU6VpJ+xcOwQUqZr+mR0kvBUgv6cB4+37hQAkXqE8PwGisGhJtN4xAHMzrsgvI7rccXqSvKh6jltGlrOHA3Xk1At3LC4QiPdX9/0ndHpGVvTjR4bZA1ypAKgVcwE5vx74ulwIugDt8e/X7JgfkucBMIAr26ndnB4UCLnDOqvteQsHlgX9N4A+c4cW3DXSPbwAAAABJRU5ErkJggg==)](https://twil.io/learn-open-source)