Skip to content

Commit 389c1c0

Browse files
author
childish-sambino
authored
feat: run tests before deploying (#581)
1 parent 2a08fac commit 389c1c0

File tree

3 files changed

+42
-64
lines changed

3 files changed

+42
-64
lines changed

.github/workflows/deploy.yml renamed to .github/workflows/test-and-deploy.yml

+40-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,43 @@
1-
name: Deploy
1+
name: Test and Deploy
22
on:
33
push:
4-
tags:
5-
- '*'
4+
branches: [ '*' ]
5+
tags: [ '*' ]
6+
pull_request:
7+
branches: [ main ]
8+
schedule:
9+
# Run automatically at 8AM PST Monday-Friday
10+
- cron: '0 15 * * 1-5'
611
workflow_dispatch:
712

813
jobs:
14+
test:
15+
name: Test
16+
runs-on: ubuntu-latest
17+
timeout-minutes: 20
18+
strategy:
19+
matrix:
20+
ruby: [ 2.4, 2.5, 2.6, 2.7, '3.0', ruby-head, jruby-9.2 ]
21+
continue-on-error: ${{ matrix.ruby == 'ruby-head' }}
22+
steps:
23+
- name: Checkout twilio-ruby
24+
uses: actions/checkout@v2
25+
26+
- name: Set up Ruby
27+
uses: ruby/setup-ruby@v1
28+
with:
29+
ruby-version: ${{ matrix.ruby }}
30+
bundler-cache: true
31+
32+
- run: bundle install --with development
33+
- run: bundle exec rake install
34+
- name: Run Unit Tests
35+
run: make test
36+
937
deploy:
10-
name: Deploy to Rubygems
38+
name: Deploy
39+
if: success() && github.ref_type == 'tag'
40+
needs: [ test ]
1141
runs-on: ubuntu-latest
1242
steps:
1343
- name: Checkout twilio-ruby
@@ -38,7 +68,7 @@ jobs:
3868
- name: Publish to Rubygems
3969
env:
4070
GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_AUTH_TOKEN }}
41-
run: |
71+
run: |
4272
mkdir -p $HOME/.gem
4373
touch $HOME/.gem/credentials
4474
chmod 0600 $HOME/.gem/credentials
@@ -48,16 +78,16 @@ jobs:
4878
4979
notify-on-failure:
5080
name: Slack notify on failure
51-
if: ${{ failure() }}
52-
needs: [deploy]
81+
if: failure() && github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || github.ref_type == 'tag')
82+
needs: [ test, deploy ]
5383
runs-on: ubuntu-latest
5484
steps:
5585
- uses: rtCamp/action-slack-notify@v2
5686
env:
57-
SLACK_COLOR: ${{ needs.deploy.status }}
87+
SLACK_COLOR: failure
5888
SLACK_ICON_EMOJI: ':github:'
59-
SLACK_MESSAGE: ${{ format('Failed to publish {1} to RubyGems{3} {0}/{1}/actions/runs/{2}', github.server_url, github.repository, github.run_id, ':') }}
60-
SLACK_TITLE: Deployment Failure
89+
SLACK_MESSAGE: ${{ format('Tests *{0}*, Deploy *{1}*, {2}/{3}/actions/runs/{4}', needs.test.result, needs.deploy.result, github.server_url, github.repository, github.run_id) }}
90+
SLACK_TITLE: Action Failure - ${{ github.repository }}
6191
SLACK_USERNAME: GitHub Actions
6292
SLACK_MSG_AUTHOR: twilio-dx
6393
SLACK_FOOTER: Posted automatically using GitHub Actions

.github/workflows/test.yml

-52
This file was deleted.

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# twilio-ruby
22

3-
[![Tests](https://github.com/twilio/twilio-ruby/actions/workflows/test.yml/badge.svg)][github-actions]
3+
[![Tests](https://github.com/twilio/twilio-ruby/actions/workflows/test-and-deploy.yml/badge.svg)][github-actions]
44
[![Gem Version](https://img.shields.io/gem/v/twilio-ruby.svg)](https://rubygems.org/gems/twilio-ruby)
55
[![Learn with 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)
66

@@ -257,7 +257,7 @@ If you've instead found a bug in the library or would like new features added, g
257257
[bundler]: https://bundler.io
258258
[rubygems]: https://rubygems.org
259259
[gem]: https://rubygems.org/gems/twilio
260-
[github-actions]: https://github.com/twilio/twilio-ruby/actions/workflows/test.yml
260+
[github-actions]: https://github.com/twilio/twilio-ruby/actions/workflows/test-and-deploy.yml
261261
[upgrade]: https://github.com/twilio/twilio-ruby/wiki/Ruby-Version-5.x-Upgrade-Guide
262262
[issues]: https://github.com/twilio/twilio-ruby/issues
263263
[faraday]: https://github.com/lostisland/faraday

0 commit comments

Comments
 (0)