Skip to content

Commit 60ba54a

Browse files
authored
Set up GitHub actions CI (#2403)
* Set up GitHub actions CI * Remove simplecov entirely for now * Fix deprecations * Relax dev deps * Address Rails 6.0 blocking hosts * Rails 6.1 content type changed to application/json; charset=utf-8 * Test a few more rubies and rails * Stop testing grape. We should drop grape support ``` /home/runner/work/active_model_serializers/active_model_serializers/vendor/bundle/ruby/2.6.0/gems/grape-0.19.0/lib/grape/error_formatter.rb:16: warning: in `formatters': the last argument was passed as a single Hash /home/runner/work/active_model_serializers/active_model_serializers/vendor/bundle/ruby/2.6.0/gems/grape-0.19.0/lib/grape/error_formatter.rb:21: warning: although a splat keyword arguments here Run options: --seed 23470 ..........................................................................................................................................................................................................................................................................................................................................................................................................................................E ActiveModelSerializers::GrapeTest#test_render_helper_passes_through_options_correctly: NoMethodError: undefined method `[]' for nil:NilClass bin/rails test /home/runner/work/active_model_serializers/active_model_serializers/test/grape_test.rb:126 W, [2020-12-29T02:27:48.991413 #2790] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#size defined in Hash. This can cause unexpected behavior when accessing the key as a property. You can still access the key via the #[] method. W, [2020-12-29T02:27:48.991505 #2790] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#size defined in Hash. This can cause unexpected behavior when accessing the key as a property. You can still access the key via the #[] method. W, [2020-12-29T02:27:48.991581 #2790] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#size defined in Hash. This can cause unexpected behavior when accessing the key as a property. You can still access the key via the #[] method. W, [2020-12-29T02:27:48.991625 #2790] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#size defined in Hash. This can cause unexpected behavior when accessing the key as a property. You can still access the key via the #[] method. E Error: ActiveModelSerializers::GrapeTest#test_implicit_formatter_handles_collections: NoMethodError: undefined method `[]' for nil:NilClass bin/rails test /home/runner/work/active_model_serializers/active_model_serializers/test/grape_test.rb:185 ............................................................................................................................................... Finished in 2.052241s, 280.6688 runs/s, 473.6285 assertions/s. 576 runs, 972 assertions, 0 failures, 7 errors, 0 skips rake aborted! Command failed with status (1): [ruby -w -I"lib:lib:test" -r./test/test_helper.rb -w -I"/home/runner/work/active_model_serializers/active_model_serializers/vendor/bundle/ruby/2.6.0/gems/rake-12.3.3/lib" "/home/runner/work/active_model_serializers/active_model_serializers/vendor/bundle/ruby/2.6.0/gems/rake-12.3.3/lib/rake/rake_test_loader.rb" "test/action_controller/adapter_selector_test.rb" "test/action_controller/explicit_serializer_test.rb" "test/action_controller/json/include_test.rb" "test/action_controller/json_api/deserialization_test.rb" "test/action_controller/json_api/errors_test.rb" "test/action_controller/json_api/fields_test.rb" "test/action_controller/json_api/linked_test.rb" "test/action_controller/json_api/pagination_test.rb" "test/action_controller/json_api/transform_test.rb" "test/action_controller/lookup_proc_test.rb" "test/action_controller/namespace_lookup_test.rb" "test/action_controller/serialization_scope_name_test.rb" "test/action_controller/serialization_test.rb" "test/active_model_serializers/adapter_for_test.rb" "test/active_model_serializers/json_pointer_test.rb" "test/active_model_serializers/logging_test.rb" "test/active_model_serializers/model_test.rb" "test/active_model_serializers/test/schema_test.rb" "test/active_model_serializers/test/serializer_test.rb" "test/active_record_test.rb" "test/adapter/attributes_test.rb" "test/adapter/deprecation_test.rb" "test/adapter/json/belongs_to_test.rb" "test/adapter/json/collection_test.rb" "test/adapter/json/fields_test.rb" "test/adapter/json/has_many_test.rb" "test/adapter/json/transform_test.rb" "test/adapter/json_api/belongs_to_test.rb" "test/adapter/json_api/collection_test.rb" "test/adapter/json_api/errors_test.rb" "test/adapter/json_api/fields_test.rb" "test/adapter/json_api/has_many_explicit_serializer_test.rb" "test/adapter/json_api/has_many_test.rb" "test/adapter/json_api/has_one_test.rb" "test/adapter/json_api/include_data_if_sideloaded_test.rb" "test/adapter/json_api/json_api_test.rb" "test/adapter/json_api/linked_test.rb" "test/adapter/json_api/links_test.rb" "test/adapter/json_api/pagination_links_test.rb" "test/adapter/json_api/parse_test.rb" "test/adapter/json_api/relationship_test.rb" "test/adapter/json_api/resource_meta_test.rb" "test/adapter/json_api/toplevel_jsonapi_test.rb" "test/adapter/json_api/transform_test.rb" "test/adapter/json_api/type_test.rb" "test/adapter/json_test.rb" "test/adapter/null_test.rb" "test/adapter/polymorphic_test.rb" "test/adapter_test.rb" "test/array_serializer_test.rb" "test/cache_test.rb" "test/collection_serializer_test.rb" "test/generators/scaffold_controller_generator_test.rb" "test/generators/serializer_generator_test.rb" "test/grape_test.rb" "test/lint_test.rb" "test/logger_test.rb" "test/poro_test.rb" "test/serializable_resource_test.rb" "test/serializers/association_macros_test.rb" "test/serializers/associations_test.rb" "test/serializers/attribute_test.rb" "test/serializers/attributes_test.rb" "test/serializers/configuration_test.rb" "test/serializers/fieldset_test.rb" "test/serializers/meta_test.rb" "test/serializers/options_test.rb" "test/serializers/read_attribute_for_serialization_test.rb" "test/serializers/reflection_test.rb" "test/serializers/root_test.rb" "test/serializers/serialization_test.rb" "test/serializers/serializer_for_test.rb" "test/serializers/serializer_for_with_namespace_test.rb" ] /home/runner/work/active_model_serializers/active_model_serializers/vendor/bundle/ruby/2.6.0/gems/rake-12.3.3/exe/rake:27:in `<top (required)>' /opt/hostedtoolcache/Ruby/2.6.6/x64/bin/bundle:23:in `load' /opt/hostedtoolcache/Ruby/2.6.6/x64/bin/bundle:23:in `<main>' Tasks: TOP => default => test (See full trace by running task with --trace) Error: Process completed with exit code 1. ```
1 parent 6d651bc commit 60ba54a

File tree

12 files changed

+101
-345
lines changed

12 files changed

+101
-345
lines changed

.github/workflows/ci.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
3+
name: CI
4+
5+
on:
6+
- "push"
7+
8+
jobs:
9+
test:
10+
name: "Testing"
11+
runs-on: ubuntu-18.04
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
include:
16+
# Recent Rubies and Rails
17+
- ruby-version: '2.6'
18+
rails-version: '6.1'
19+
- ruby-version: '2.6'
20+
rails-version: '6.0'
21+
- ruby-version: '2.7'
22+
rails-version: '6.0'
23+
- ruby-version: '2.6'
24+
rails-version: '5.2'
25+
# Old Rubies and Rails
26+
- ruby-version: '2.5'
27+
rails-version: '5.1'
28+
bundler: '1'
29+
- ruby-version: '2.4'
30+
rails-version: '5.0'
31+
bundler: '1'
32+
- ruby-version: '2.4'
33+
rails-version: '4.2'
34+
bundler: '1'
35+
# Failing with a stack trace in active support
36+
# - ruby-version: '2.4'
37+
# rails-version: '4.1'
38+
# bundler: '1'
39+
40+
continue-on-error: "${{ endsWith(matrix.ruby-version, 'head') }}"
41+
42+
env:
43+
CI: "1"
44+
45+
steps:
46+
- name: "Checkout Code"
47+
uses: "actions/checkout@v2"
48+
timeout-minutes: 5
49+
with:
50+
fetch-depth: 0
51+
52+
- name: Install required libs
53+
run: |
54+
sudo apt-get -yqq install libsqlite3-dev
55+
56+
- name: "Build Ruby"
57+
uses: ruby/setup-ruby@v1
58+
with:
59+
ruby-version: "${{ matrix.ruby-version }}"
60+
bundler: "${{ matrix.bundler || 2 }}"
61+
bundler-cache: true
62+
env:
63+
RAILS_VERSION: ${{ matrix.rails-version }}
64+
65+
- name: "Run tests"
66+
run: |
67+
bundle exec rake
68+
env:
69+
RAILS_VERSION: ${{ matrix.rails-version }}

.simplecov

Lines changed: 0 additions & 110 deletions
This file was deleted.

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
<td>
1414
<a href="https://codeclimate.com/github/rails-api/active_model_serializers"><img src="https://codeclimate.com/github/rails-api/active_model_serializers/badges/gpa.svg" alt="Code Quality"></a>
1515
<a href="https://codebeat.co/projects/github-com-rails-api-active_model_serializers"><img src="https://codebeat.co/badges/a9ab35fa-8b5a-4680-9d4e-a81f9a55ebcd" alt="codebeat" ></a>
16-
<a href="https://codeclimate.com/github/rails-api/active_model_serializers/coverage"><img src="https://codeclimate.com/github/rails-api/active_model_serializers/badges/coverage.svg" alt="Test Coverage"></a>
1716
</td>
1817
</tr>
1918
<tr>

Rakefile

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ begin
55
rescue LoadError
66
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
77
end
8-
begin
9-
require 'simplecov'
10-
rescue LoadError # rubocop:disable Lint/HandleExceptions
11-
end
128
import('lib/tasks/rubocop.rake')
139

1410
Bundler::GemHelper.install_tasks
@@ -56,13 +52,20 @@ namespace :test do
5652
# https://github.com/rails/rails/blob/3d590add45/railties/lib/rails/generators/app_base.rb#L345-L363
5753
_bundle_command = Gem.bin_path('bundler', 'bundle')
5854
require 'bundler'
59-
Bundler.with_clean_env do
55+
with_clean_env = proc do
6056
isolated_test_files.all? do |test_file|
6157
command = "-w -I#{dir}/lib -I#{dir}/test #{Shellwords.shellescape(test_file)}"
6258
full_command = %("#{Gem.ruby}" #{command})
6359
system(full_command)
6460
end or fail 'Failures' # rubocop:disable Style/AndOr
6561
end
62+
bundler_method =
63+
if Bundler.method_defined?(:with_unbundled_env)
64+
:with_unbundled_env
65+
else
66+
:with_clean_env
67+
end
68+
Bundler.public_send(bundler_method, &with_clean_env)
6669
end
6770
end
6871

active_model_serializers.gemspec

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,8 @@ Gem::Specification.new do |spec|
5555
spec.add_development_dependency 'will_paginate', '~> 3.0', '>= 3.0.7'
5656

5757
spec.add_development_dependency 'bundler'
58-
spec.add_development_dependency 'simplecov', '>= 0.11'
5958
spec.add_development_dependency 'timecop', '~> 0.7'
60-
spec.add_development_dependency 'grape', ['>= 0.13', '< 0.19.1']
59+
spec.add_development_dependency 'grape', '>= 0.13'
6160
spec.add_development_dependency 'json_schema'
62-
spec.add_development_dependency 'rake', ['>= 10.0', '< 13.0']
61+
spec.add_development_dependency 'rake', '>= 10.0'
6362
end

docs/STYLE.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818

1919
- [Improve code quality](https://codeclimate.com/github/rails-api/active_model_serializers/code?sort=smell_count&sort_direction=desc).
2020

21-
- [Improve amount of code exercised by tests](https://codeclimate.com/github/rails-api/active_model_serializers/coverage?sort=covered_percent&sort_direction=asc).
22-
2321
- [Fix RuboCop (Style) TODOS](https://github.com/rails-api/active_model_serializers/blob/master/.rubocop_todo.yml).
2422
- Delete and offsense, run `rake rubocop` (or possibly `rake rubocop:auto_correct`),
2523
and [submit a PR](CONTRIBUTING.md#submitting-a-pull-request-pr).

test/action_controller/explicit_serializer_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ def render_using_explicit_each_serializer
7171
def test_render_using_explicit_serializer
7272
get :render_using_explicit_serializer
7373

74-
assert_equal 'application/json', @response.content_type
74+
assert_match(%r{\Aapplication/json}, @response.content_type)
7575
assert_equal '{"name":"Name 1"}', @response.body
7676
end
7777

7878
def test_render_array_using_explicit_serializer
7979
get :render_array_using_explicit_serializer
80-
assert_equal 'application/json', @response.content_type
80+
assert_match(%r{\Aapplication/json}, @response.content_type)
8181

8282
expected = [
8383
{ 'name' => 'Name 1' },
@@ -89,7 +89,7 @@ def test_render_array_using_explicit_serializer
8989

9090
def test_render_array_using_implicit_serializer
9191
get :render_array_using_implicit_serializer
92-
assert_equal 'application/json', @response.content_type
92+
assert_match(%r{\Aapplication/json}, @response.content_type)
9393

9494
expected = [
9595
{ 'name' => 'Name 1' },

0 commit comments

Comments
 (0)