Skip to content

Commit

Permalink
Add GH action to run tests & publish to Coveralls
Browse files Browse the repository at this point in the history
  • Loading branch information
hammady committed Sep 15, 2023
1 parent 88a4e0f commit db8ba3e
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 27 deletions.
25 changes: 25 additions & 0 deletions .github/actions/rspec_tests/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: rspec-tests
description: Composite action for rspec tests
inputs:
github-token:
required: true
runs:
using: composite
steps:
- name: Install bundler
shell: bash
# The bundler version used must match the one in the repo's gemspec
run: gem install bundler:2.2.19
- name: Bundle dependencies
shell: bash
run: bundle
- name: Run rspec tests
shell: bash
env:
CI: true
run: bundle exec rspec
- name: Use coveralls
uses: coverallsapp/github-action@1.1.3
with:
github-token: ${{ inputs.github-token }}
path-to-lcov: 'coverage/lcov.info'
24 changes: 24 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: 'Test'
on:
push:
branches:
- master
tags:
- v*
pull_request:
types: [opened, reopened, edited, synchronize]
jobs:
test:
strategy:
matrix:
ruby_version: [2.4, 2.5, 2.6, 2.7]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: '${{ matrix.ruby_version }}'
- name: Run rspec tests
uses: ./.github/actions/rspec_tests
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
24 changes: 8 additions & 16 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,8 @@ GEM
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
coderay (1.1.1)
coveralls (0.8.21)
json (>= 1.8, < 3)
simplecov (~> 0.14.1)
term-ansicolor (~> 1.3)
thor (~> 0.19.4)
tins (~> 1.6)
diff-lcs (1.3)
docile (1.1.5)
docile (1.4.0)
docker-api (2.1.0)
excon (>= 0.47.0)
multi_json
Expand All @@ -45,7 +39,7 @@ GEM
http-form_data (2.3.0)
http-parser (1.2.3)
ffi-compiler (>= 1.0, < 2.0)
json (2.3.1)
json (2.6.3)
jsonpath (1.0.5)
multi_json
to_regexp (~> 0.2.1)
Expand Down Expand Up @@ -82,15 +76,12 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.6.0)
rspec-support (3.6.0)
simplecov (0.14.1)
docile (~> 1.1.0)
simplecov (0.17.1)
docile (~> 1.1)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.0)
term-ansicolor (1.6.0)
tins (~> 1.0)
thor (0.19.4)
tins (1.13.2)
simplecov-html (0.10.2)
simplecov-lcov (0.7.0)
to_regexp (0.2.1)
unf (0.1.4)
unf_ext
Expand All @@ -102,10 +93,11 @@ PLATFORMS
DEPENDENCIES
bundler (>= 2.2.10)
coderay (~> 1.1)
coveralls (~> 0.8)
rake (>= 12.3.3)
rspec (~> 3.5)
scaltainer!
simplecov (~> 0.17.1)
simplecov-lcov (~> 0.7.0)

BUNDLED WITH
2.2.19
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[![Build Status](https://travis-ci.org/hammady/scaltainer.svg?branch=master)](https://travis-ci.org/hammady/scaltainer)
![Build Status](https://github.com/hammady/scaltainer/actions/workflows/tests.yml/badge.svg)
[![Coverage Status](https://coveralls.io/repos/github/hammady/scaltainer/badge.svg?service=github&branch=master)](https://coveralls.io/github/hammady/scaltainer?branch=master)
[![Gem Version](https://badge.fury.io/rb/scaltainer.svg)](https://badge.fury.io/rb/scaltainer)

# Scaltainer

Expand Down
3 changes: 2 additions & 1 deletion scaltainer.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "rake", ">= 12.3.3"
spec.add_development_dependency 'rspec', '~> 3.5'
spec.add_development_dependency 'coderay', '~> 1.1'
spec.add_development_dependency 'coveralls', '~> 0.8'
spec.add_development_dependency 'simplecov', '~> 0.17.1'
spec.add_development_dependency 'simplecov-lcov', '~> 0.7.0'

spec.add_runtime_dependency 'excon', '>= 0.47.0'
spec.add_runtime_dependency "docker-api"
Expand Down
26 changes: 18 additions & 8 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,24 @@
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration

require 'simplecov'
require 'coveralls'

SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new [
SimpleCov::Formatter::HTMLFormatter,
Coveralls::SimpleCov::Formatter
]

SimpleCov.start
require 'simplecov-lcov'

SimpleCov.start do
if ENV['CI']
SimpleCov::Formatter::LcovFormatter.config do |config|
config.report_with_single_file = true
config.single_report_path = 'coverage/lcov.info'
end

SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new [
SimpleCov::Formatter::LcovFormatter
]
else
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new [
SimpleCov::Formatter::HTMLFormatter
]
end
end

require 'scaltainer'

Expand Down

0 comments on commit db8ba3e

Please sign in to comment.