Skip to content

Commit

Permalink
chore: Update CI/CD to use codecov action and cobertura reports
Browse files Browse the repository at this point in the history
  • Loading branch information
jgraichen committed Oct 3, 2024
1 parent 831cdce commit e7c4f17
Show file tree
Hide file tree
Showing 14 changed files with 86 additions and 40 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/maintenance-cache-wipe.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
name: maintenance-cache-clear
on:
schedule:
- cron: "0 0 1 * *"
workflow_dispatch:

jobs:
cache-clear:
runs-on: ubuntu-latest

steps:
- uses: easimon/wipe-cache@v2
17 changes: 17 additions & 0 deletions .github/workflows/maintenance-workflow-cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: maintenance-workflow-cleanup
on:
schedule:
- cron: "0 0 1 * *"
workflow_dispatch:

jobs:
delete-workflow-runs:
runs-on: ubuntu-latest
steps:
- uses: Mattraks/delete-workflow-runs@v2
with:
token: ${{ github.token }}
repository: ${{ github.repository }}
retain_days: 180
keep_minimum_runs: 50
7 changes: 6 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ jobs:
- name: Run integration tests
run: bundle exec rspec -Ispec/integration --color spec/integration

- uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}

rubocop:
name: rubocop
runs-on: ubuntu-22.04
Expand All @@ -76,7 +81,7 @@ jobs:
- uses: actions/checkout@master
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.0
ruby-version: "3.3"
bundler-cache: true

- name: Run rubocop
Expand Down
12 changes: 6 additions & 6 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

# vim: ft=ruby

# appraise 'rails-5.2' do
# gem 'rails', '~> 5.2.0'
# end
appraise 'rails-5.2' do
gem 'rails', '~> 5.2.0'
end

# appraise 'rails-6.0' do
# gem 'rails', '~> 6.0.0'
# end
appraise 'rails-6.0' do
gem 'rails', '~> 6.0.0'
end

appraise 'rails-6.1' do
gem 'rails', '~> 6.1.0'
Expand Down
8 changes: 6 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
source 'https://rubygems.org'

gem 'appraisal'
gem 'coveralls'
gem 'rake'
gem 'rake-release', '~> 1.1'

gem 'rspec', '~> 3.0'
gem 'rspec-rails'
gem 'rubocop-config', github: 'jgraichen/rubocop-config', ref: 'v11', require: false

gem 'simplecov', require: false
gem 'simplecov-cobertura', require: false

gem 'rubocop-config', github: 'jgraichen/rubocop-config', ref: 'v12', require: false

gem 'rails'
gem 'sqlite3', '~> 1.4'
Expand Down
5 changes: 3 additions & 2 deletions gemfiles/rails_5.2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
source "https://rubygems.org"

gem "appraisal"
gem "coveralls"
gem "my-rubocop", github: "jgraichen/my-rubocop", ref: "v4"
gem "rake"
gem "rake-release", "~> 1.1"
gem "rspec", "~> 3.0"
gem "rspec-rails"
gem "simplecov", require: false
gem "simplecov-cobertura", require: false
gem "rubocop-config", github: "jgraichen/rubocop-config", ref: "v12", require: false
gem "rails", "~> 5.2.0"
gem "sqlite3", "~> 1.4"

Expand Down
5 changes: 3 additions & 2 deletions gemfiles/rails_6.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
source "https://rubygems.org"

gem "appraisal"
gem "coveralls"
gem "my-rubocop", github: "jgraichen/my-rubocop", ref: "v4"
gem "rake"
gem "rake-release", "~> 1.1"
gem "rspec", "~> 3.0"
gem "rspec-rails"
gem "simplecov", require: false
gem "simplecov-cobertura", require: false
gem "rubocop-config", github: "jgraichen/rubocop-config", ref: "v12", require: false
gem "rails", "~> 6.0.0"
gem "sqlite3", "~> 1.4"

Expand Down
5 changes: 3 additions & 2 deletions gemfiles/rails_6.1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
source "https://rubygems.org"

gem "appraisal"
gem "coveralls"
gem "my-rubocop", github: "jgraichen/my-rubocop", ref: "v4"
gem "rake"
gem "rake-release", "~> 1.1"
gem "rspec", "~> 3.0"
gem "rspec-rails"
gem "simplecov", require: false
gem "simplecov-cobertura", require: false
gem "rubocop-config", github: "jgraichen/rubocop-config", ref: "v12", require: false
gem "rails", "~> 6.1.0"
gem "sqlite3", "~> 1.4"

Expand Down
5 changes: 3 additions & 2 deletions gemfiles/rails_7.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
source "https://rubygems.org"

gem "appraisal"
gem "coveralls"
gem "my-rubocop", github: "jgraichen/my-rubocop", ref: "v4"
gem "rake"
gem "rake-release", "~> 1.1"
gem "rspec", "~> 3.0"
gem "rspec-rails"
gem "simplecov", require: false
gem "simplecov-cobertura", require: false
gem "rubocop-config", github: "jgraichen/rubocop-config", ref: "v12", require: false
gem "rails", "~> 6.1.0"
gem "sqlite3", "~> 1.4"

Expand Down
5 changes: 3 additions & 2 deletions gemfiles/rails_head.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
source "https://rubygems.org"

gem "appraisal"
gem "coveralls"
gem "my-rubocop", github: "jgraichen/my-rubocop", ref: "v4"
gem "rake"
gem "rake-release", "~> 1.1"
gem "rspec", "~> 3.0"
gem "rspec-rails"
gem "simplecov", require: false
gem "simplecov-cobertura", require: false
gem "rubocop-config", github: "jgraichen/rubocop-config", ref: "v12", require: false
gem "rails", git: "https://github.com/rails/rails", require: "rails"
gem "sqlite3", "~> 1.4"

Expand Down
2 changes: 1 addition & 1 deletion lib/msgr/test_pool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def ns_run(count: 1, timeout: 5)

class << self
def new(*args)
@instance ||= super(*args) # rubocop:disable Naming/MemoizedInstanceVariableName
@instance ||= super # rubocop:disable Naming/MemoizedInstanceVariableName
end

def run(**kwargs)
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/dummy/app/consumers/test_consumer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class << self
def index
data = {fuubar: 'abc'}

publish data, to: 'local.test.another_action'
publish(data, to: 'local.test.another_action')
end

def another_action
Expand Down
23 changes: 11 additions & 12 deletions spec/integration/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@
require 'bundler'
Bundler.require :rails, :test

# Coverage
require 'coveralls'
Coveralls.wear! do
require 'simplecov'
require 'simplecov-cobertura'

SimpleCov.start do
command_name 'rspec:integration'
add_filter 'spec'

self.formatters = [
SimpleCov::Formatter::HTMLFormatter,
SimpleCov::Formatter::CoberturaFormatter,
]
end

ENV['RAILS_ENV'] ||= 'test'
Expand All @@ -19,11 +26,7 @@
# in spec/support/ and its subdirectories.
Dir[File.expand_path('support/**/*.rb', __dir__)].sort.each {|f| require f }

# Checks for pending migrations before tests are run.
# If you are not using ActiveRecord, you can remove this line.
if defined?(ActiveRecord::Migration) && Rails::VERSION::MAJOR >= 4
ActiveRecord::Migration.check_pending!
end
ActiveRecord::Migration.check_all_pending!

RSpec.configure do |config|
# If you're not using ActiveRecord, or you'd prefer not to run each of your
Expand All @@ -47,10 +50,6 @@
c.syntax = :expect
end

config.before do
Msgr.logger = false
end

config.after do
# Flush the consumer queue
Msgr.client.stop delete: true
Expand Down
17 changes: 10 additions & 7 deletions spec/unit/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@
require 'bundler'
Bundler.setup :default, :test

# Coverage
require 'coveralls'
Coveralls.wear! do
require 'simplecov'
require 'simplecov-cobertura'

SimpleCov.start do
command_name 'rspec:unit'
add_filter 'spec'

self.formatters = [
SimpleCov::Formatter::HTMLFormatter,
SimpleCov::Formatter::CoberturaFormatter,
]
end

require 'msgr'
Expand All @@ -20,8 +27,4 @@
# Only allow expect syntax
c.syntax = :expect
end

config.before do
Msgr.logger = false
end
end

0 comments on commit e7c4f17

Please sign in to comment.