Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: migrate to gh actions #478

Merged
merged 4 commits into from Jan 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 0 additions & 21 deletions .codeclimate.yml

This file was deleted.

94 changes: 94 additions & 0 deletions .github/workflows/test-and-deploy.yml
@@ -0,0 +1,94 @@
name: Test and Deploy
on:
push:
branches: [ '*' ]
childish-sambino marked this conversation as resolved.
Show resolved Hide resolved
tags: [ '*' ]
pull_request:
branches: [ main ]
schedule:
# Run automatically at 8AM PST Monday-Friday
- cron: '0 15 * * 1-5'
workflow_dispatch:

jobs:
test:
name: Test
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
matrix:
ruby: [ 2.4, 2.5, 2.6, 2.7, 3.0, jruby-9.2 ]
steps:
- name: Checkout sendgrid-ruby
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true

- run: make install

- name: Set up linter
run: bundle add rubocop --version "~> 1.24.1" --group "development" --skip-install
if: ${{ matrix.ruby != '2.4' }}

- run: bundle install --with development

- name: Run linter
run: bundle exec rubocop
if: ${{ matrix.ruby != '2.4' }}

- name: Run tests
run: make test-docker

deploy:
name: Deploy
if: success() && github.ref_type == 'tag'
needs: [ test ]
runs-on: ubuntu-latest
steps:
- name: Checkout sendgrid-ruby
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.4
bundler-cache: true

- run: make install

- name: Publish to Rubygems
env:
GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_AUTH_TOKEN }}
run: |
mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
chmod 0600 $HOME/.gem/credentials
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
gem build *.gemspec
gem push *.gem

notify-on-failure:
name: Slack notify on failure
if: failure() && github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || github.ref_type == 'tag')
needs: [ test, deploy ]
runs-on: ubuntu-latest
steps:
- uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: failure
SLACK_ICON_EMOJI: ':github:'
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) }}
SLACK_TITLE: Action Failure - ${{ github.repository }}
SLACK_USERNAME: GitHub Actions
SLACK_MSG_AUTHOR: twilio-dx
SLACK_FOOTER: Posted automatically using GitHub Actions
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
MSG_MINIMAL: true
66 changes: 41 additions & 25 deletions .rubocop_todo.yml
@@ -1,49 +1,57 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2020-09-18 20:20:54 UTC using RuboCop version 0.91.0.
# on 2022-01-25 23:45:43 UTC using RuboCop version 1.22.2.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include.
# Include: **/*.gemfile, **/Gemfile, **/gems.rb
Bundler/OrderedGems:
Exclude:
- 'Gemfile'

# Offense count: 1
# Configuration parameters: Include.
# Include: **/*.gemspec
Gemspec/RequiredRubyVersion:
Exclude:
- 'sendgrid-ruby.gemspec'

# Offense count: 22
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: final_newline, final_blank_line
Layout/TrailingEmptyLines:
Exclude:
- 'Gemfile'

# Offense count: 24
Lint/UselessAssignment:
Exclude:
- 'examples/scopes/scopes.rb'
- 'spec/rack/sendgrid_webhook_verification_spec.rb'

# Offense count: 8
# Configuration parameters: IgnoredMethods.
# Offense count: 10
# Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 144

# Offense count: 9
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods.
# ExcludedMethods: refine
Metrics/BlockLength:
Max: 96
Max: 134

# Offense count: 3
# Configuration parameters: CountComments, CountAsOne.
Metrics/ClassLength:
Max: 2006
Exclude:
- 'test/sendgrid/test_sendgrid-ruby.rb'
Max: 2018

# Offense count: 41
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods.
# Offense count: 45
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
Metrics/MethodLength:
Max: 141

# Offense count: 2
# Configuration parameters: CountKeywordArgs.
# Offense count: 4
# Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
Metrics/ParameterLists:
Max: 7

Expand Down Expand Up @@ -76,15 +84,15 @@ Naming/PredicateName:
- 'examples/helpers/eventwebhook/example.rb'

# Offense count: 35
# Configuration parameters: AllowedConstants.
Style/Documentation:
Enabled: false

# Offense count: 4
# Configuration parameters: EnforcedStyle.
# Offense count: 3
# Configuration parameters: MaxUnannotatedPlaceholdersAllowed, IgnoredMethods.
# SupportedStyles: annotated, template, unannotated
Style/FormatStringToken:
Exclude:
- 'examples/emailactivity/emailactivity.rb'
EnforcedStyle: unannotated

# Offense count: 97
# Cop supports --auto-correct.
Expand All @@ -93,6 +101,14 @@ Style/FormatStringToken:
Style/FrozenStringLiteralComment:
Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
Style/HashSyntax:
Exclude:
- 'Gemfile'

# Offense count: 6
Style/MixinUsage:
Exclude:
Expand All @@ -103,9 +119,9 @@ Style/MixinUsage:
- 'test/sendgrid/helpers/mail/test_attachment.rb'
- 'test/sendgrid/helpers/mail/test_mail.rb'

# Offense count: 55
# Offense count: 54
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Layout/LineLength:
Max: 3211
Max: 381
31 changes: 0 additions & 31 deletions .travis.yml

This file was deleted.

1 change: 0 additions & 1 deletion Makefile
Expand Up @@ -5,7 +5,6 @@ install:

test:
bundle exec rake
rubocop

test-integ: test

Expand Down
2 changes: 1 addition & 1 deletion README.md
@@ -1,6 +1,6 @@
![Twilio SendGrid Logo](twilio_sendgrid_logo.png)

[![Travis Badge](https://travis-ci.com/sendgrid/sendgrid-ruby.svg?branch=main)](https://travis-ci.com/sendgrid/sendgrid-ruby)
[![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)
[![Gem Version](https://badge.fury.io/rb/sendgrid-ruby.svg)](https://badge.fury.io/rb/sendgrid-ruby)
[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
[![Twitter Follow](https://img.shields.io/twitter/follow/sendgrid.svg?style=social&label=Follow)](https://twitter.com/sendgrid)
Expand Down
1 change: 0 additions & 1 deletion sendgrid-ruby.gemspec
Expand Up @@ -25,7 +25,6 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'rack'
spec.add_development_dependency 'rake', '~> 13.0'
spec.add_development_dependency 'rspec'
spec.add_development_dependency 'rubocop'
spec.add_development_dependency 'simplecov', '~> 0.18.5'
spec.add_development_dependency 'sinatra', '>= 1.4.7', '< 3'
end
8 changes: 2 additions & 6 deletions test/sendgrid/test_sendgrid-ruby.rb
Expand Up @@ -2683,12 +2683,8 @@ def test_gitignore_exists
assert(File.file?('./.gitignore'))
end

def test_travis_exists
assert(File.file?('./.travis.yml'))
end

def test_codeclimate_exists
assert(File.file?('./.codeclimate.yml'))
def test_gh_actions_exists
assert(File.file?('./.github/workflows/test-and-deploy.yml'))
end

def test_changelog_exists
Expand Down