Skip to content

Commit

Permalink
Merge pull request #59 from andyundso/new-test-suite
Browse files Browse the repository at this point in the history
Run tests on GitHub Actions
  • Loading branch information
jejacks0n authored Sep 29, 2023
2 parents 7176fc0 + c0b7631 commit 36af0e7
Show file tree
Hide file tree
Showing 43 changed files with 335 additions and 37 deletions.
111 changes: 111 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
---
name: CI
on: [push, pull_request]
jobs:
tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
# https://www.fastruby.io/blog/ruby/rails/versions/compatibility-table.html
# Rails 4.2 is open ended, but people usually stopped at using it with 2.4
- ruby: "2.4"
rails: "4_2"
# Rails 5.0 requires 2.2.2 minimum, 2.4.x was maximum
- ruby: "2.4"
rails: "5_0"
# Rails 5.1 requires 2.2.2 minimum, 2.5.x was maximum
- ruby: "2.4"
rails: "5_1"
- ruby: "2.5"
rails: "5_1"
# Rails 5.2 requires 2.2.2 minimum, 2.6.x was maximum
- ruby: "2.4"
rails: "5_2"
- ruby: "2.5"
rails: "5_2"
- ruby: "2.6"
rails: "5_2"
# Rails 6.0 requires 2.5.x minimum, 2.7.x was maximum
- ruby: "2.5"
rails: "6_0"
- ruby: "2.6"
rails: "6_0"
- ruby: "2.7"
rails: "6_0"
# Rails 6.1 requires 2.5.x minimum and is open ended
- ruby: "2.5"
rails: "6_1"
- ruby: "2.6"
rails: "6_1"
- ruby: "2.7"
rails: "6_1"
- ruby: "3.0"
rails: "6_1"
- ruby: "3.1"
rails: "6_1"
- ruby: "3.2"
rails: "6_1"
# Rails 7.0 requires 2.7.x minimum and is open ended
- ruby: "2.7"
rails: "7_0"
- ruby: "3.0"
rails: "7_0"
- ruby: "3.1"
rails: "7_0"
- ruby: "3.2"
rails: "7_0"
env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/rails_${{ matrix.rails }}.gemfile
steps:
- uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler: ${{ matrix.rails == '4_2' && '1.17.3' || 'default' }}
bundler-cache: true

- name: Run tests
run: bundle exec rspec

- name: Archive code coverage results
uses: actions/upload-artifact@v3
with:
name: code-coverage-report
path: coverage/coverage.json

rubocop:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2
bundler-cache: true

- name: Run Rubocop
run: bundle exec rubocop

upload-coverage:
needs: tests
runs-on: ubuntu-latest
if: ${{ github.repository == 'jejacks0n/navigasmic' }}
steps:
- uses: actions/checkout@v4

- name: Download code coverage artifacts
uses: actions/download-artifact@v3
with:
name: code-coverage-report

- name: Test & publish code coverage
uses: paambaati/[email protected]
env:
CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
with:
coverageLocations: ${{github.workspace}}/coverage.json:simplecov
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ coverage
spec/dummy/log/*.log
spec/dummy/tmp/
Gemfile.lock
*.gemfile.lock
*.sqlite
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.5.1
2.7.8
14 changes: 0 additions & 14 deletions .travis.yml

This file was deleted.

48 changes: 48 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
appraise "rails-4-2" do
gem "rails", "~> 4.2.0"

# https://github.com/flavorjones/loofah/pull/267
gem "loofah", "<= 2.20.0"

# Ensure we do not use the precompiled gem, which has Ruby >= 2.7 as a requirement
gem "sqlite3", "< 1.5.0"
end

appraise "rails-5-0" do
gem "rails", "~> 5.0.0"

# https://github.com/flavorjones/loofah/pull/267
gem "loofah", "<= 2.20.0"

# Ensure we do not use the precompiled gem, which has Ruby >= 2.7 as a requirement
gem "sqlite3", "< 1.5.0"
end

appraise "rails-5-1" do
gem "rails", "~> 5.1.0"

# https://github.com/flavorjones/loofah/pull/267
gem "loofah", "<= 2.20.0"

# Ensure we do not use the precompiled gem, which has Ruby >= 2.7 as a requirement
gem "sqlite3", "< 1.5.0"
end

appraise "rails-5-2" do
gem "rails", "~> 5.2.0"

# https://github.com/flavorjones/loofah/pull/267
gem "loofah", "<= 2.20.0"
end

appraise "rails-6-0" do
gem "rails", "~> 6.0.0"
end

appraise "rails-6-1" do
gem "rails", "~> 6.1.0"
end

appraise "rails-7-0" do
gem "rails", "~> 7.0.0"
end
9 changes: 5 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }

gemspec

gem "rails"

# test dependencies
gem "rspec-rails"
gem "simplecov"
group :test do
gem "rspec-rails"
gem "simplecov"
gem "simplecov_json_formatter"
end

# services
gem "rubocop", require: false
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Navigasmic
==========

[![Gem Version](https://img.shields.io/gem/v/navigasmic.svg)](https://rubygems.org/gems/navigasmic)
[![Build Status](https://img.shields.io/travis/jejacks0n/navigasmic.svg)](https://travis-ci.org/jejacks0n/navigasmic)
![Build Status](https://github.com/jejacks0n/navigasmic/actions/workflows/ci.yml/badge.svg)
[![Maintainability](https://api.codeclimate.com/v1/badges/53eb8e1e49cc1e19dde7/maintainability)](https://codeclimate.com/github/jejacks0n/navigasmic/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/53eb8e1e49cc1e19dde7/test_coverage)](https://codeclimate.com/github/jejacks0n/navigasmic/test_coverage)
[![License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://opensource.org/licenses/MIT)
Expand Down Expand Up @@ -156,7 +156,7 @@ posts (they will also only highlight on the given record):

```ruby
n.item "Article", controller: "/blog/posts", action: "show", id: "42"
n.item "Article", class: "featured", link: {controller: "/blog/posts", action: "show", id: "42"}
n.item "Article", class: "featured", link: { controller: "/blog/posts", action: "show", id: "42" }
```

Note that we're passing a string for the posts id. That's because when the param comes in and is compared against the
Expand All @@ -175,7 +175,7 @@ Highlight rules allows for passing an array containing any of/or a Boolean, Stri
examples will highlight:

```ruby
n.item "On the /my_thoughts path, and on Mondays", "/blog/posts", highlights_on: ["/my_thoughts", proc { Time.now.wday == 1}]
n.item "On the /my_thoughts path, and on Mondays", "/blog/posts", highlights_on: ["/my_thoughts", proc { Time.now.wday == 1 }]
n.item "On any action in BlogController", highlights_on: [{ controller: "blog" }]
n.item "On any path beginning with 'my_'", highlights_on: /^\/my_/
n.item "Only on '/my_thoughts'", highlights_on: "/my_thoughts"
Expand Down
17 changes: 17 additions & 0 deletions gemfiles/rails_4_2.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rubocop", require: false
gem "rubocop-rails_config"
gem "rails", "~> 4.2.0"
gem "loofah", "<= 2.20.0"
gem "sqlite3", "< 1.5.0"

group :test do
gem "rspec-rails"
gem "simplecov"
gem "simplecov_json_formatter"
end

gemspec path: "../"
17 changes: 17 additions & 0 deletions gemfiles/rails_5_0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rubocop", require: false
gem "rubocop-rails_config"
gem "rails", "~> 5.0.0"
gem "loofah", "<= 2.20.0"
gem "sqlite3", "< 1.5.0"

group :test do
gem "rspec-rails"
gem "simplecov"
gem "simplecov_json_formatter"
end

gemspec path: "../"
17 changes: 17 additions & 0 deletions gemfiles/rails_5_1.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rubocop", require: false
gem "rubocop-rails_config"
gem "rails", "~> 5.1.0"
gem "loofah", "<= 2.20.0"
gem "sqlite3", "< 1.5.0"

group :test do
gem "rspec-rails"
gem "simplecov"
gem "simplecov_json_formatter"
end

gemspec path: "../"
16 changes: 16 additions & 0 deletions gemfiles/rails_5_2.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rubocop", require: false
gem "rubocop-rails_config"
gem "rails", "~> 5.2.0"
gem "loofah", "<= 2.20.0"

group :test do
gem "rspec-rails"
gem "simplecov"
gem "simplecov_json_formatter"
end

gemspec path: "../"
15 changes: 15 additions & 0 deletions gemfiles/rails_6_0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rubocop", require: false
gem "rubocop-rails_config"
gem "rails", "~> 6.0.0"

group :test do
gem "rspec-rails"
gem "simplecov"
gem "simplecov_json_formatter"
end

gemspec path: "../"
15 changes: 15 additions & 0 deletions gemfiles/rails_6_1.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rubocop", require: false
gem "rubocop-rails_config"
gem "rails", "~> 6.1.0"

group :test do
gem "rspec-rails"
gem "simplecov"
gem "simplecov_json_formatter"
end

gemspec path: "../"
15 changes: 15 additions & 0 deletions gemfiles/rails_7_0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rubocop", require: false
gem "rubocop-rails_config"
gem "rails", "~> 7.0.0"

group :test do
gem "rspec-rails"
gem "simplecov"
gem "simplecov_json_formatter"
end

gemspec path: "../"
1 change: 0 additions & 1 deletion lib/navigasmic/builder/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ def render
end

private

def configuration_or_default(config = nil)
configurations = Navigasmic.configuration.builder_configurations[self.class.to_s]
proc = configurations.present? ? configurations[config || :default] : nil
Expand Down
1 change: 0 additions & 1 deletion lib/navigasmic/builder/crumb_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ def item(label, *args, &block)
end

private

def label_for(label, link, is_nested = false, options = {})
if label.present?
label = @context.instance_exec(label, options, !!link, is_nested, &@config.label_generator).html_safe
Expand Down
1 change: 0 additions & 1 deletion lib/navigasmic/builder/list_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ def item(label, *args, &block)
end

private

def structure_for(label, link = false, options = {}, &block)
label = label_for(label, link, block_given?, options)

Expand Down
1 change: 0 additions & 1 deletion lib/navigasmic/builder/map_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ def item(label, *args, &block)
end

private

def structure_for(label, link, options, &block)
content = content_tag(:loc, link_for(link, options))
content << content_tag(:name, label)
Expand Down
1 change: 0 additions & 1 deletion lib/navigasmic/item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ def highlights_on?(path, params)
end

private

def calculate_highlighting_rules(rules)
[].tap do |highlighting_rules|
if rules.nil?
Expand Down
7 changes: 6 additions & 1 deletion navigasmic.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,10 @@ Gem::Specification.new do |s|
s.license = "MIT"
s.files = Dir["{lib}/**/*"] + ["MIT.LICENSE", "README.md"]

s.required_ruby_version = "~> 2.4"
s.add_dependency "rails", ">= 4.2.0"
s.add_development_dependency "appraisal"
s.add_development_dependency "combustion", "~> 1.3"
s.add_development_dependency "sqlite3"

s.required_ruby_version = ">= 2.4"
end
Empty file.
Loading

0 comments on commit 36af0e7

Please sign in to comment.