Skip to content

Commit 8aac7fb

Browse files
author
Piotr Wasiak
authored
OS-43 many rails version in ci (#53)
* Remove not needed dependencies from security perspective * Configure rails app to not serve assets and skip sprockets * Fix issues for rails 4 specs * Separate gemfiles for rails 4.2 and higher * Ignore rails specific gemfile locks * Add editorconfig to unify editors * Separate rails 5 and 6 pipeline and use matrix in Circle Fix bundler for rails 4 and bundler audit by separate files * Fix missing bundle on higher rails. Use docker with most recent fixes docker * Disable bundle audit * Adjust matrix to rails compatible versions and rails 6.0.X * Skip audit for rails 4.2 * Escape parameter from circle config passed to shell * Fix broken spec outside rails 5 due to empty params * Add rails 6.1 to test matrix * Document spec helpers * Revert changes with session and flash. Document more about decision * CR: fix typo and comment style
1 parent f9d415f commit 8aac7fb

25 files changed

+189
-151
lines changed

.circleci/config.yml

Lines changed: 73 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,44 @@
1-
version: 2.0
2-
defaults: &defaults
3-
steps:
4-
- checkout
5-
- attach_workspace:
6-
at: ~/project/tmp
7-
- run:
8-
name: Bundle
9-
command: bundle install
10-
- run:
11-
name: bin/ci
12-
command: bin/ci
13-
- run:
14-
name: Generate coverage
15-
command: ./tmp/cc-test-reporter format-coverage -t simplecov -o ./tmp/codeclimate.$CIRCLE_JOB.json coverage/.resultset.json
16-
- persist_to_workspace:
17-
root: ~/project/tmp
18-
paths:
19-
- ./*.json
1+
version: 2.1
2+
references:
3+
attach_workspace_to_tmp: &attach_workspace_to_tmp
4+
attach_workspace:
5+
at: ~/project/tmp
6+
bundle: &bundle
7+
run:
8+
name: Bundle
9+
command: |
10+
if [ $BUNDLE_GEMFILE = ./gemfiles/rails42.gemfile ]; then
11+
gem install -v '1.17.3' bundler;
12+
bundle _1.17.3_ install;
13+
else
14+
gem install bundler;
15+
bundle install;
16+
fi
17+
gemfile_lock_audit: &gemfile_lock_audit
18+
run:
19+
name: audit
20+
command: |
21+
if [ $BUNDLE_GEMFILE != ./gemfiles/rails42.gemfile ]; then
22+
bin/audit;
23+
fi
24+
specs: &specs
25+
run:
26+
name: bin/ci
27+
command: bin/ci
28+
generate_coverage: &generate_coverage
29+
run:
30+
name: Generate coverage
31+
command: ./tmp/cc-test-reporter format-coverage -t simplecov -o ./tmp/codeclimate.$CIRCLE_JOB.json coverage/.resultset.json
32+
persist_to_workspace_coverage: &persist_to_workspace_coverage
33+
persist_to_workspace:
34+
root: ~/project/tmp
35+
paths:
36+
- ./*.json
2037

2138
jobs:
22-
ruby-250:
23-
<<: *defaults
24-
docker:
25-
- image: circleci/ruby:2.5.0
26-
ruby-260:
27-
<<: *defaults
28-
docker:
29-
- image: circleci/ruby:2.6.0
30-
ruby-270:
31-
<<: *defaults
32-
docker:
33-
- image: circleci/ruby:2.7.0
34-
ruby-300:
35-
<<: *defaults
36-
docker:
37-
- image: circleci/ruby:3.0.0
3839
download-and-persist-cc-test-reporter:
3940
docker:
40-
- image: circleci/ruby:2.6.0
41+
- image: circleci/ruby:2.6
4142
steps:
4243
- run:
4344
name: Download cc-test-reporter
@@ -51,7 +52,7 @@ jobs:
5152
- cc-test-reporter
5253
upload-test-coverage:
5354
docker:
54-
- image: circleci/ruby:2.6.0
55+
- image: circleci/ruby:2.6
5556
steps:
5657
- attach_workspace:
5758
at: ~/project/tmp
@@ -60,32 +61,51 @@ jobs:
6061
command: |
6162
./tmp/cc-test-reporter sum-coverage tmp/codeclimate.*.json -p $(ls -la |grep -i ruby |wc -l |awk '{print $1}') -o tmp/codeclimate.total.json
6263
./tmp/cc-test-reporter upload-coverage -i tmp/codeclimate.total.json
64+
test:
65+
parameters:
66+
ruby_version:
67+
type: string
68+
gemfile:
69+
type: string
70+
docker:
71+
- image: "circleci/ruby:<<parameters.ruby_version>>"
72+
environment:
73+
BUNDLE_GEMFILE: "./gemfiles/<<parameters.gemfile>>"
74+
steps:
75+
- checkout
76+
- <<: *attach_workspace_to_tmp
77+
- <<: *bundle
78+
- <<: *gemfile_lock_audit
79+
- <<: *specs
80+
- <<: *generate_coverage
81+
- <<: *persist_to_workspace_coverage
6382

6483
workflows:
6584
version: 2
6685

6786
commit:
6887
jobs:
6988
- download-and-persist-cc-test-reporter
70-
- ruby-250:
71-
requires:
72-
- download-and-persist-cc-test-reporter
73-
- ruby-260:
74-
requires:
75-
- download-and-persist-cc-test-reporter
76-
- ruby-270:
77-
requires:
78-
- download-and-persist-cc-test-reporter
79-
- ruby-300:
80-
requires:
81-
- download-and-persist-cc-test-reporter
8289
- upload-test-coverage:
8390
filters:
8491
branches:
8592
only:
8693
- master
8794
requires:
88-
- ruby-250
89-
- ruby-260
90-
- ruby-270
91-
- ruby-300
95+
- test
96+
- test:
97+
matrix:
98+
parameters:
99+
ruby_version: ["2.5", "2.6", "2.7", "3.0"]
100+
gemfile: ["rails61.gemfile", "rails60.gemfile", "rails5.gemfile", "rails42.gemfile"]
101+
exclude:
102+
- ruby_version: "3.0"
103+
gemfile: rails5.gemfile
104+
- ruby_version: "3.0"
105+
gemfile: rails42.gemfile
106+
- ruby_version: "2.7"
107+
gemfile: rails42.gemfile
108+
- ruby_version: "2.6"
109+
gemfile: rails42.gemfile
110+
requires:
111+
- download-and-persist-cc-test-reporter

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Gemfile.lock
2+
gemfiles/*.lock
23
*.gem
34
.bundle/
45
log/*.log

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
source 'https://rubygems.org'
22
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
33

4-
gemspec
4+
gemspec name: 'jsonapi_parameters'

bin/audit

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,12 @@
1-
bundle audit check --update
1+
#!/usr/bin/env ruby
2+
3+
require 'shellwords'
4+
5+
gemfile_option = %W[--gemfile-lock #{ENV['BUNDLE_GEMFILE']}.lock] if ENV['BUNDLE_GEMFILE'].to_s != ''
6+
command_to_execute =
7+
Shellwords.split("bundle exec bundle-audit check --update")
8+
.concat(Array.new(gemfile_option || []))
9+
.compact
10+
.shelljoin
11+
puts command_to_execute
12+
system(command_to_execute) || raise('Error on bundle audit')

bin/ci

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@
22

33
set -e
44

5-
bundle exec bin/audit
65
bundle exec bin/quality
7-
bundle exec bin/spec
6+
bundle exec bin/spec

gemfiles/rails42.gemfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
source 'https://rubygems.org'
2+
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3+
4+
gem 'rails', '~> 4.2.0'
5+
gem 'sqlite3', '~> 1.3.6'
6+
7+
gemspec name: 'jsonapi_parameters', path: '../'

gemfiles/rails5.gemfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
source 'https://rubygems.org'
2+
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3+
4+
gem 'rails', '~> 5.0'
5+
gem 'sqlite3', '~> 1.4.0'
6+
7+
gemspec name: 'jsonapi_parameters', path: '../'

gemfiles/rails60.gemfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
source 'https://rubygems.org'
2+
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3+
4+
gem 'rails', '~> 6.0.0'
5+
gem 'sqlite3', '~> 1.4.0'
6+
7+
gemspec name: 'jsonapi_parameters', path: '../'

gemfiles/rails61.gemfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
source 'https://rubygems.org'
2+
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3+
4+
gem 'rails', '~> 6.1.0'
5+
gem 'sqlite3', '~> 1.4.0'
6+
7+
gemspec name: 'jsonapi_parameters', path: '../'

0 commit comments

Comments
 (0)