Skip to content

Commit 82ef2cb

Browse files
author
Bilal Boussayoud
authored
chore: migrate to gh actions (#478)
* chore: migrate to gh actions
1 parent 6916f39 commit 82ef2cb

File tree

8 files changed

+138
-86
lines changed

8 files changed

+138
-86
lines changed

.codeclimate.yml

-21
This file was deleted.

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

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Test and Deploy
2+
on:
3+
push:
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'
11+
workflow_dispatch:
12+
13+
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, jruby-9.2 ]
21+
steps:
22+
- name: Checkout sendgrid-ruby
23+
uses: actions/checkout@v2
24+
with:
25+
fetch-depth: 0
26+
27+
- name: Set up Ruby
28+
uses: ruby/setup-ruby@v1
29+
with:
30+
ruby-version: ${{ matrix.ruby }}
31+
bundler-cache: true
32+
33+
- run: make install
34+
35+
- name: Set up linter
36+
run: bundle add rubocop --version "~> 1.24.1" --group "development" --skip-install
37+
if: ${{ matrix.ruby != '2.4' }}
38+
39+
- run: bundle install --with development
40+
41+
- name: Run linter
42+
run: bundle exec rubocop
43+
if: ${{ matrix.ruby != '2.4' }}
44+
45+
- name: Run tests
46+
run: make test-docker
47+
48+
deploy:
49+
name: Deploy
50+
if: success() && github.ref_type == 'tag'
51+
needs: [ test ]
52+
runs-on: ubuntu-latest
53+
steps:
54+
- name: Checkout sendgrid-ruby
55+
uses: actions/checkout@v2
56+
with:
57+
fetch-depth: 0
58+
59+
- name: Set up Ruby
60+
uses: ruby/setup-ruby@v1
61+
with:
62+
ruby-version: 2.4
63+
bundler-cache: true
64+
65+
- run: make install
66+
67+
- name: Publish to Rubygems
68+
env:
69+
GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_AUTH_TOKEN }}
70+
run: |
71+
mkdir -p $HOME/.gem
72+
touch $HOME/.gem/credentials
73+
chmod 0600 $HOME/.gem/credentials
74+
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
75+
gem build *.gemspec
76+
gem push *.gem
77+
78+
notify-on-failure:
79+
name: Slack notify on failure
80+
if: failure() && github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || github.ref_type == 'tag')
81+
needs: [ test, deploy ]
82+
runs-on: ubuntu-latest
83+
steps:
84+
- uses: rtCamp/action-slack-notify@v2
85+
env:
86+
SLACK_COLOR: failure
87+
SLACK_ICON_EMOJI: ':github:'
88+
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) }}
89+
SLACK_TITLE: Action Failure - ${{ github.repository }}
90+
SLACK_USERNAME: GitHub Actions
91+
SLACK_MSG_AUTHOR: twilio-dx
92+
SLACK_FOOTER: Posted automatically using GitHub Actions
93+
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
94+
MSG_MINIMAL: true

.rubocop_todo.yml

+41-25
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,57 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2020-09-18 20:20:54 UTC using RuboCop version 0.91.0.
3+
# on 2022-01-25 23:45:43 UTC using RuboCop version 1.22.2.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
77
# versions of RuboCop, may require this file to be generated again.
88

9+
# Offense count: 1
10+
# Cop supports --auto-correct.
11+
# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include.
12+
# Include: **/*.gemfile, **/Gemfile, **/gems.rb
13+
Bundler/OrderedGems:
14+
Exclude:
15+
- 'Gemfile'
16+
917
# Offense count: 1
1018
# Configuration parameters: Include.
1119
# Include: **/*.gemspec
1220
Gemspec/RequiredRubyVersion:
1321
Exclude:
1422
- 'sendgrid-ruby.gemspec'
1523

16-
# Offense count: 22
24+
# Offense count: 1
25+
# Cop supports --auto-correct.
26+
# Configuration parameters: EnforcedStyle.
27+
# SupportedStyles: final_newline, final_blank_line
28+
Layout/TrailingEmptyLines:
29+
Exclude:
30+
- 'Gemfile'
31+
32+
# Offense count: 24
1733
Lint/UselessAssignment:
1834
Exclude:
1935
- 'examples/scopes/scopes.rb'
2036
- 'spec/rack/sendgrid_webhook_verification_spec.rb'
2137

22-
# Offense count: 8
23-
# Configuration parameters: IgnoredMethods.
38+
# Offense count: 10
39+
# Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
2440
Metrics/AbcSize:
25-
Max: 144
26-
27-
# Offense count: 9
28-
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods.
29-
# ExcludedMethods: refine
30-
Metrics/BlockLength:
31-
Max: 96
41+
Max: 134
3242

3343
# Offense count: 3
3444
# Configuration parameters: CountComments, CountAsOne.
3545
Metrics/ClassLength:
36-
Max: 2006
37-
Exclude:
38-
- 'test/sendgrid/test_sendgrid-ruby.rb'
46+
Max: 2018
3947

40-
# Offense count: 41
41-
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods.
48+
# Offense count: 45
49+
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
4250
Metrics/MethodLength:
4351
Max: 141
4452

45-
# Offense count: 2
46-
# Configuration parameters: CountKeywordArgs.
53+
# Offense count: 4
54+
# Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
4755
Metrics/ParameterLists:
4856
Max: 7
4957

@@ -76,15 +84,15 @@ Naming/PredicateName:
7684
- 'examples/helpers/eventwebhook/example.rb'
7785

7886
# Offense count: 35
87+
# Configuration parameters: AllowedConstants.
7988
Style/Documentation:
8089
Enabled: false
8190

82-
# Offense count: 4
83-
# Configuration parameters: EnforcedStyle.
91+
# Offense count: 3
92+
# Configuration parameters: MaxUnannotatedPlaceholdersAllowed, IgnoredMethods.
8493
# SupportedStyles: annotated, template, unannotated
8594
Style/FormatStringToken:
86-
Exclude:
87-
- 'examples/emailactivity/emailactivity.rb'
95+
EnforcedStyle: unannotated
8896

8997
# Offense count: 97
9098
# Cop supports --auto-correct.
@@ -93,6 +101,14 @@ Style/FormatStringToken:
93101
Style/FrozenStringLiteralComment:
94102
Enabled: false
95103

104+
# Offense count: 1
105+
# Cop supports --auto-correct.
106+
# Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
107+
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
108+
Style/HashSyntax:
109+
Exclude:
110+
- 'Gemfile'
111+
96112
# Offense count: 6
97113
Style/MixinUsage:
98114
Exclude:
@@ -103,9 +119,9 @@ Style/MixinUsage:
103119
- 'test/sendgrid/helpers/mail/test_attachment.rb'
104120
- 'test/sendgrid/helpers/mail/test_mail.rb'
105121

106-
# Offense count: 55
122+
# Offense count: 54
107123
# Cop supports --auto-correct.
108-
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
124+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
109125
# URISchemes: http, https
110126
Layout/LineLength:
111-
Max: 3211
127+
Max: 381

.travis.yml

-31
This file was deleted.

Makefile

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ install:
55

66
test:
77
bundle exec rake
8-
rubocop
98

109
test-integ: test
1110

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
![Twilio SendGrid Logo](twilio_sendgrid_logo.png)
22

3-
[![Travis Badge](https://travis-ci.com/sendgrid/sendgrid-ruby.svg?branch=main)](https://travis-ci.com/sendgrid/sendgrid-ruby)
3+
[![Travis Badge](https://github.com/sendgrid/sendgrid-ruby/actions/workflows/test-and-deploy.yml/badge.svg)](https://github.com/sendgrid/sendgrid-ruby/actions/workflows/test-and-deploy.yml)
44
[![Gem Version](https://badge.fury.io/rb/sendgrid-ruby.svg)](https://badge.fury.io/rb/sendgrid-ruby)
55
[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
66
[![Twitter Follow](https://img.shields.io/twitter/follow/sendgrid.svg?style=social&label=Follow)](https://twitter.com/sendgrid)

sendgrid-ruby.gemspec

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ Gem::Specification.new do |spec|
2525
spec.add_development_dependency 'rack'
2626
spec.add_development_dependency 'rake', '~> 13.0'
2727
spec.add_development_dependency 'rspec'
28-
spec.add_development_dependency 'rubocop'
2928
spec.add_development_dependency 'simplecov', '~> 0.18.5'
3029
spec.add_development_dependency 'sinatra', '>= 1.4.7', '< 3'
3130
end

test/sendgrid/test_sendgrid-ruby.rb

+2-6
Original file line numberDiff line numberDiff line change
@@ -2683,12 +2683,8 @@ def test_gitignore_exists
26832683
assert(File.file?('./.gitignore'))
26842684
end
26852685

2686-
def test_travis_exists
2687-
assert(File.file?('./.travis.yml'))
2688-
end
2689-
2690-
def test_codeclimate_exists
2691-
assert(File.file?('./.codeclimate.yml'))
2686+
def test_gh_actions_exists
2687+
assert(File.file?('./.github/workflows/test-and-deploy.yml'))
26922688
end
26932689

26942690
def test_changelog_exists

0 commit comments

Comments
 (0)