Skip to content

Commit

Permalink
Replace Travis with Github Actions for CI/CD (closes #117)
Browse files Browse the repository at this point in the history
  • Loading branch information
mscwilson committed Sep 13, 2021
1 parent e33900f commit 6cd8d3d
Show file tree
Hide file tree
Showing 9 changed files with 128 additions and 48 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Deploy

on:
push:
tags:
- "*"

jobs:
prepare-to-publish:
runs-on: ubuntu-latest
outputs:
gem-version: ${{ steps.gem-version.outputs.gem-version }}

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Save gem version
id: gem-version
run: echo "::set-output name=gem-version::$(grep -oE "[0-9]+\.[0-9]+\.[0-9]+-?[a-z]*\.?[0-9]*" lib/snowplow-tracker/version.rb)"

- name: Save tag version
id: tag-version
run: echo "::set-output name=tag-version::${GITHUB_REF#refs/*/}"

- name: Exit on tag version mismatch
if: ${{ steps.tag-version.outputs.tag-version != steps.gem-version.outputs.gem-version }}
run: |
echo "Tag version (${{ steps.tag-version.outputs.tag-version }}) doesn't match project version (${{ steps.gem-version.outputs.gem-version }})"
exit 1
publish:
needs: prepare-to-publish
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6

- name: Publish to RubyGems
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
env:
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_API_KEY}}"

- name: Release on GitHub
uses: softprops/[email protected]
with:
name: Version ${{ needs.prepare-to-publish.outputs.gem-version }}
prerelease: ${{ contains(needs.prepare-to-publish.outputs.gem-version, '-') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29 changes: 29 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Test

on: pull_request

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ["2.1", "2.3", "2.6", "2.7", "3.0", "jruby-9.1"]

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true # runs ‘bundle install’ and caches installed gems automatically

- name: Run tests
run: bundle exec rspec

- name: Coveralls
if: matrix.ruby-version == '2.6'
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
28 changes: 0 additions & 28 deletions .travis.yml

This file was deleted.

12 changes: 0 additions & 12 deletions .travis/is_valid_tag.rb

This file was deleted.

3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@
source 'https://rubygems.org'
gemspec

gem 'coveralls', require: false
gem 'simplecov', require: false
gem 'simplecov-lcov', require: false
7 changes: 7 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

require "bundler/gem_tasks"
require "rspec/core/rake_task"

task :default => :spec
RSpec::Core::RakeTask.new(:spec)
2 changes: 1 addition & 1 deletion lib/snowplow-tracker/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
# License:: Apache License Version 2.0

module SnowplowTracker
VERSION = '0.6.1'
VERSION = '0.7.0-alpha.2'
TRACKER_VERSION = "rb-#{VERSION}"
end
2 changes: 1 addition & 1 deletion snowplow-tracker.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Gem::Specification.new do |s|
s.name = 'snowplow-tracker'
s.version = SnowplowTracker::VERSION
s.homepage = 'http://github.com/snowplow/snowplow-ruby-tracker'
s.license = 'Apache License 2.0'
s.license = 'Apache-2.0'
s.summary = "Ruby Analytics for Snowplow"
s.description = "With this tracker you can collect event data from your Ruby applications, Ruby on Rails web applications and Ruby gems."
s.authors = ["Alexander Dean", "Fred Blundun"]
Expand Down
31 changes: 26 additions & 5 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,38 @@
# Copyright:: Copyright (c) 2013-2014 Snowplow Analytics Ltd
# License:: Apache License Version 2.0

require 'simplecov'
require 'simplecov-lcov'

# Fix incompatibility of simplecov-lcov with older versions of simplecov that are not expressed in its gemspec.
# https://github.com/fortissimo1997/simplecov-lcov/pull/25
if !SimpleCov.respond_to?(:branch_coverage)
module SimpleCov
def self.branch_coverage?
false
end
end
end

require 'coveralls'
Coveralls.wear!
SimpleCov::Formatter::LcovFormatter.config do |c|
c.report_with_single_file = true
c.single_report_path = 'coverage/lcov.info'
end

require 'webmock/rspec'
require 'snowplow-tracker'
SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new(
[
SimpleCov::Formatter::HTMLFormatter,
SimpleCov::Formatter::LcovFormatter,
]
)

SimpleCov.start do
add_filter "/spec/"
add_filter 'spec/'
end

require 'webmock/rspec'
require 'snowplow-tracker'

WebMock.disable_net_connect!(:allow_localhost => true)

RSpec.configure do |config|
Expand Down

0 comments on commit 6cd8d3d

Please sign in to comment.