Skip to content

Commit 9d71044

Browse files
author
Bilal Boussayoud
authored
chore: migrate to gh actions (#127)
* chore: migrate to gh actions
1 parent 1d13c95 commit 9d71044

File tree

9 files changed

+166
-62
lines changed

9 files changed

+166
-62
lines changed

.codeclimate.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

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

Lines changed: 94 additions & 0 deletions
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, jruby-9.2 ]
21+
steps:
22+
- name: Checkout ruby-http-client
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 rake rubocop
43+
if: ${{ matrix.ruby != '2.4' }}
44+
45+
- name: Run tests
46+
run: make test
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 ruby-http-client
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.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
inherit_from: .rubocop_todo.yml
2+
13
AllCops:
24
Exclude:
35
- bin/**/*
@@ -44,4 +46,4 @@ Style/StringLiterals:
4446
Style/NumericLiterals:
4547
Enabled: false
4648
Style/FrozenStringLiteralComment:
47-
Enabled: false
49+
Enabled: false

.rubocop_todo.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# This configuration was generated by
2+
# `rubocop --auto-gen-config`
3+
# on 2022-01-25 23:29:33 UTC using RuboCop version 1.22.2.
4+
# The point is for the user to remove these configuration records
5+
# one by one as the offenses are removed from the code base.
6+
# Note that changes in the inspected code, or installation of new
7+
# versions of RuboCop, may require this file to be generated again.
8+
9+
# Offense count: 1
10+
# Configuration parameters: Include.
11+
# Include: **/*.gemspec
12+
Gemspec/RequiredRubyVersion:
13+
Exclude:
14+
- 'ruby_http_client.gemspec'
15+
16+
# Offense count: 1
17+
# Cop supports --auto-correct.
18+
# Configuration parameters: AllowAliasSyntax, AllowedMethods.
19+
# AllowedMethods: alias_method, public, protected, private
20+
Layout/EmptyLinesAroundAttributeAccessor:
21+
Exclude:
22+
- 'lib/ruby_http_client.rb'
23+
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: 1
33+
Lint/MissingSuper:
34+
Exclude:
35+
- 'test/test_ruby_http_client.rb'
36+
37+
# Offense count: 1
38+
# Cop supports --auto-correct.
39+
Lint/RedundantCopDisableDirective:
40+
Exclude:
41+
- 'lib/ruby_http_client.rb'
42+
43+
# Offense count: 1
44+
# Cop supports --auto-correct.
45+
# Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
46+
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
47+
Style/HashSyntax:
48+
Exclude:
49+
- 'Gemfile'
50+
51+
# Offense count: 4
52+
# Cop supports --auto-correct.
53+
# Configuration parameters: Mode.
54+
Style/StringConcatenation:
55+
Exclude:
56+
- 'lib/ruby_http_client.rb'
57+
- 'test/test_ruby_http_client.rb'
58+
59+
# Offense count: 2
60+
# Cop supports --auto-correct.
61+
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
62+
# SupportedStyles: single_quotes, double_quotes
63+
Style/StringLiterals:
64+
Exclude:
65+
- 'Gemfile'

.travis.yml

Lines changed: 0 additions & 36 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
![SendGrid Logo](twilio_sendgrid_logo.png)
22

3-
[![BuildStatus](https://travis-ci.com/sendgrid/ruby-http-client.svg?branch=main)](https://travis-ci.com/sendgrid/ruby-http-client)
3+
[![BuildStatus](https://github.com/sendgrid/ruby-http-client/actions/workflows/test-and-deploy.yml/badge.svg)](https://github.com/sendgrid/ruby-http-client/actions/workflows/test-and-deploy.yml)
44
[![Gem Version](https://badge.fury.io/rb/ruby_http_client.svg)](https://badge.fury.io/rb/ruby_http_client)
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)

ruby_http_client.gemspec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,5 @@ Gem::Specification.new do |spec|
1818
spec.add_development_dependency 'codecov'
1919
spec.add_development_dependency 'minitest'
2020
spec.add_development_dependency 'rake'
21-
spec.add_development_dependency 'rubocop', '~> 0.88.0'
2221
spec.add_development_dependency 'simplecov', '~> 0.18.5'
2322
end

test/test_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
if ENV['CI'] == 'true'
1+
if RUBY_VERSION.equal?('2.7')
22
require 'simplecov'
33
SimpleCov.start
44

test/test_ruby_http_client.rb

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -356,12 +356,8 @@ def test_gitignore_exists
356356
assert(File.file?('./.gitignore'))
357357
end
358358

359-
def test_travis_exists
360-
assert(File.file?('./.travis.yml'))
361-
end
362-
363-
def test_codeclimate_exists
364-
assert(File.file?('./.codeclimate.yml'))
359+
def test_gh_actions_exists
360+
assert(File.file?('./.github/workflows/test-and-deploy.yml'))
365361
end
366362

367363
def test_changelog_exists

0 commit comments

Comments
 (0)