Skip to content

Commit 54be340

Browse files
authored
Add GitHub Actions for CI and pushing to RubyGems (discourse#6)
1 parent a397c33 commit 54be340

File tree

8 files changed

+90
-28
lines changed

8 files changed

+90
-28
lines changed

.github/workflows/ci.yml

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
tags:
9+
- v*
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
15+
strategy:
16+
matrix:
17+
ruby:
18+
- 2.5
19+
- 2.6
20+
- 2.7
21+
22+
steps:
23+
- uses: actions/checkout@v2
24+
25+
- name: Setup Redis
26+
uses: shogo82148/actions-setup-redis@v1
27+
with:
28+
redis-version: '5.x'
29+
30+
- name: Set up Ruby
31+
uses: actions/setup-ruby@v1
32+
with:
33+
ruby-version: ${{ matrix.ruby }}
34+
architecture: 'x64'
35+
36+
- name: Setup bundler
37+
run: |
38+
gem install bundler --no-doc
39+
bundle config path vendor/bundle
40+
41+
- name: Bundler cache
42+
uses: actions/cache@v2
43+
with:
44+
path: vendor/bundle
45+
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
46+
restore-keys: |
47+
${{ runner.os }}-gems-
48+
49+
- name: Setup gems
50+
run: bundle install --jobs 4
51+
52+
- name: Rubocop
53+
run: bundle exec rubocop
54+
55+
- name: RSpec
56+
run: bundle exec rspec
57+
58+
publish:
59+
if: contains(github.ref, 'refs/tags/v')
60+
needs: build
61+
runs-on: ubuntu-latest
62+
63+
steps:
64+
- uses: actions/checkout@v2
65+
66+
- name: Release Gem
67+
uses: CvX/publish-rubygems-action@master
68+
env:
69+
RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}

.gitignore

-2
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,3 @@
99
Gemfile.lock
1010
.DS_Store
1111
*.swp
12-
13-
.rubocop-https---raw-githubusercontent-com-discourse-discourse-master--rubocop-yml

.rubocop.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
inherit_from: https://raw.githubusercontent.com/discourse/discourse/master/.rubocop.yml
1+
inherit_gem:
2+
rubocop-discourse: default.yml

.travis.yml

-18
This file was deleted.

Gemfile

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# frozen_string_literal: true
12
source 'https://rubygems.org'
23

34
git_source(:github) { 'https://github.com/discourse/mini_scheduler' }

Guardfile

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# frozen_string_literal: true
12
# A sample Guardfile
23
# More info at https://github.com/guard/guard#readme
34

Rakefile

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
1-
require "bundler/gem_tasks"
1+
#!/usr/bin/env rake
2+
# frozen_string_literal: true
3+
24
require "rspec/core/rake_task"
5+
require 'bundler'
6+
7+
begin
8+
Bundler.setup :default, :development
9+
Bundler::GemHelper.install_tasks
10+
rescue Bundler::BundlerError => error
11+
$stderr.puts error.message
12+
$stderr.puts "Run `bundle install` to install missing gems"
13+
exit error.status_code
14+
end
315

416
RSpec::Core::RakeTask.new(:spec)
517

6-
task default: :spec
18+
desc "Default: run tests"
19+
task default: [ :spec ]

mini_scheduler.gemspec

+2-5
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@ Gem::Specification.new do |spec|
1515
spec.homepage = "https://github.com/discourse/mini_scheduler"
1616
spec.license = "MIT"
1717

18-
# Specify which files should be added to the gem when it is released.
19-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
20-
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
21-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22-
end
18+
spec.files = `git ls-files`.split($/).reject { |s| s =~ /^(spec|\.)/ }
2319
spec.require_paths = ["lib"]
2420

2521
spec.add_dependency "sidekiq"
@@ -32,4 +28,5 @@ Gem::Specification.new do |spec|
3228
spec.add_development_dependency "guard-rspec"
3329
spec.add_development_dependency "mock_redis"
3430
spec.add_development_dependency "rake"
31+
spec.add_development_dependency 'rubocop-discourse'
3532
end

0 commit comments

Comments
 (0)