From 08c4f7388cf2171593ece60f3e1fcbc81866f6dd Mon Sep 17 00:00:00 2001 From: Gerry Power Date: Thu, 29 Sep 2022 17:13:28 -0400 Subject: [PATCH] CI setup --- .circleci/config.yml | 56 +++++++-- .gitignore | 4 + .rubocop.yml | 1 + Gemfile.lock | 264 ------------------------------------------- Rakefile | 15 +++ 5 files changed, 68 insertions(+), 272 deletions(-) delete mode 100644 Gemfile.lock diff --git a/.circleci/config.yml b/.circleci/config.yml index 84343ca..3f1cd2d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,13 +1,53 @@ version: 2.1 + +# Note: This circleCi configuration is setup for gem development +# gem development specific configuration notes are below +# Give careful consideration to noted sections for a regular +# service or ruby project +# +references: + test_suite: &test_suite + run: + name: Run test suite + command: bundle exec rake spec + + lint: &lint + run: + name: Code Checks + command: bundle exec rubocop --parallel + + bundle: &bundle + run: + name: bundle install dependencies + command: bundle install + jobs: - build: + lint: docker: - - image: ruby:2.7.2 + - image: 'cimg/ruby:2.7' steps: - checkout - - run: - name: Run the default task - command: | - gem install bundler -v 2.2.11 - bundle install - bundle exec rake + - <<: *bundle + - <<: *lint + + test: + parameters: + ruby-version: + type: string + docker: + - image: 'cimg/ruby:<< parameters.ruby-version >>' + steps: + - checkout + - <<: *bundle + - <<: *test_suite + +workflows: + build_and_test: + jobs: + - lint + - test: + requires: + - lint + matrix: + parameters: + ruby-version: ['2.7', '3.0', '3.1'] diff --git a/.gitignore b/.gitignore index f57d75f..eafd827 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ +# gem +Gemfile.lock + +# Mac .DS_Store .AppleDouble .LSOverride diff --git a/.rubocop.yml b/.rubocop.yml index 2696868..1dab606 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -11,6 +11,7 @@ RSpec/MultipleMemoizedHelpers: AllCops: TargetRubyVersion: 2.4 NewCops: enable + SuggestExtensions: false Layout/LineLength: Max: 120 diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index 3f76594..0000000 --- a/Gemfile.lock +++ /dev/null @@ -1,264 +0,0 @@ -PATH - remote: . - specs: - datadog-service_catalog (0.1.0) - front_matter_parser - httparty - json_schemer - rake - -GEM - remote: https://rubygems.org/ - specs: - actioncable (7.0.4) - actionpack (= 7.0.4) - activesupport (= 7.0.4) - nio4r (~> 2.0) - websocket-driver (>= 0.6.1) - actionmailbox (7.0.4) - actionpack (= 7.0.4) - activejob (= 7.0.4) - activerecord (= 7.0.4) - activestorage (= 7.0.4) - activesupport (= 7.0.4) - mail (>= 2.7.1) - net-imap - net-pop - net-smtp - actionmailer (7.0.4) - actionpack (= 7.0.4) - actionview (= 7.0.4) - activejob (= 7.0.4) - activesupport (= 7.0.4) - mail (~> 2.5, >= 2.5.4) - net-imap - net-pop - net-smtp - rails-dom-testing (~> 2.0) - actionpack (7.0.4) - actionview (= 7.0.4) - activesupport (= 7.0.4) - rack (~> 2.0, >= 2.2.0) - rack-test (>= 0.6.3) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (7.0.4) - actionpack (= 7.0.4) - activerecord (= 7.0.4) - activestorage (= 7.0.4) - activesupport (= 7.0.4) - globalid (>= 0.6.0) - nokogiri (>= 1.8.5) - actionview (7.0.4) - activesupport (= 7.0.4) - builder (~> 3.1) - erubi (~> 1.4) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (7.0.4) - activesupport (= 7.0.4) - globalid (>= 0.3.6) - activemodel (7.0.4) - activesupport (= 7.0.4) - activerecord (7.0.4) - activemodel (= 7.0.4) - activesupport (= 7.0.4) - activestorage (7.0.4) - actionpack (= 7.0.4) - activejob (= 7.0.4) - activerecord (= 7.0.4) - activesupport (= 7.0.4) - marcel (~> 1.0) - mini_mime (>= 1.1.0) - activesupport (7.0.4) - concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 1.6, < 2) - minitest (>= 5.1) - tzinfo (~> 2.0) - ast (2.4.2) - builder (3.2.4) - coderay (1.1.3) - concurrent-ruby (1.1.10) - crass (1.0.6) - diff-lcs (1.5.0) - digest (3.1.0) - ecma-re-validator (0.4.0) - regexp_parser (~> 2.2) - erubi (1.11.0) - ffi (1.15.5) - formatador (1.1.0) - front_matter_parser (1.0.1) - globalid (1.0.0) - activesupport (>= 5.0) - guard (2.18.0) - formatador (>= 0.2.4) - listen (>= 2.7, < 4.0) - lumberjack (>= 1.0.12, < 2.0) - nenv (~> 0.1) - notiffany (~> 0.0) - pry (>= 0.13.0) - shellany (~> 0.0) - thor (>= 0.18.1) - guard-compat (1.2.1) - guard-rspec (4.7.3) - guard (~> 2.1) - guard-compat (~> 1.1) - rspec (>= 2.99.0, < 4.0) - guard-rubocop (1.5.0) - guard (~> 2.0) - rubocop (< 2.0) - hana (1.3.7) - httparty (0.20.0) - mime-types (~> 3.0) - multi_xml (>= 0.5.2) - i18n (1.12.0) - concurrent-ruby (~> 1.0) - json (2.6.2) - json_schemer (0.2.21) - ecma-re-validator (~> 0.3) - hana (~> 1.3) - regexp_parser (~> 2.0) - uri_template (~> 0.7) - listen (3.7.1) - rb-fsevent (~> 0.10, >= 0.10.3) - rb-inotify (~> 0.9, >= 0.9.10) - loofah (2.19.0) - crass (~> 1.0.2) - nokogiri (>= 1.5.9) - lumberjack (1.2.8) - mail (2.7.1) - mini_mime (>= 0.1.1) - marcel (1.0.2) - method_source (1.0.0) - mime-types (3.4.1) - mime-types-data (~> 3.2015) - mime-types-data (3.2022.0105) - mini_mime (1.1.2) - minitest (5.16.3) - multi_xml (0.6.0) - nenv (0.3.0) - net-imap (0.2.3) - digest - net-protocol - strscan - net-pop (0.1.1) - digest - net-protocol - timeout - net-protocol (0.1.3) - timeout - net-smtp (0.3.1) - digest - net-protocol - timeout - nio4r (2.5.8) - nokogiri (1.13.8-x86_64-darwin) - racc (~> 1.4) - notiffany (0.1.3) - nenv (~> 0.1) - shellany (~> 0.0) - parallel (1.22.1) - parser (3.1.2.1) - ast (~> 2.4.1) - pry (0.14.1) - coderay (~> 1.1) - method_source (~> 1.0) - racc (1.6.0) - rack (2.2.4) - rack-test (2.0.2) - rack (>= 1.3) - rails (7.0.4) - actioncable (= 7.0.4) - actionmailbox (= 7.0.4) - actionmailer (= 7.0.4) - actionpack (= 7.0.4) - actiontext (= 7.0.4) - actionview (= 7.0.4) - activejob (= 7.0.4) - activemodel (= 7.0.4) - activerecord (= 7.0.4) - activestorage (= 7.0.4) - activesupport (= 7.0.4) - bundler (>= 1.15.0) - railties (= 7.0.4) - rails-dom-testing (2.0.3) - activesupport (>= 4.2.0) - nokogiri (>= 1.6) - rails-html-sanitizer (1.4.3) - loofah (~> 2.3) - railties (7.0.4) - actionpack (= 7.0.4) - activesupport (= 7.0.4) - method_source - rake (>= 12.2) - thor (~> 1.0) - zeitwerk (~> 2.5) - rainbow (3.1.1) - rake (13.0.6) - rb-fsevent (0.11.2) - rb-inotify (0.10.1) - ffi (~> 1.0) - regexp_parser (2.5.0) - rexml (3.2.5) - rspec (3.11.0) - rspec-core (~> 3.11.0) - rspec-expectations (~> 3.11.0) - rspec-mocks (~> 3.11.0) - rspec-core (3.11.0) - rspec-support (~> 3.11.0) - rspec-expectations (3.11.1) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.11.0) - rspec-json_expectations (2.2.0) - rspec-mocks (3.11.1) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.11.0) - rspec-support (3.11.1) - rubocop (1.36.0) - json (~> 2.3) - parallel (~> 1.10) - parser (>= 3.1.2.1) - rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8, < 3.0) - rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.20.1, < 2.0) - ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.21.0) - parser (>= 3.1.1.0) - rubocop-rake (0.6.0) - rubocop (~> 1.0) - rubocop-rspec (2.13.1) - rubocop (~> 1.33) - ruby-progressbar (1.11.0) - shellany (0.0.1) - strscan (3.0.4) - thor (1.2.1) - timeout (0.3.0) - tzinfo (2.0.5) - concurrent-ruby (~> 1.0) - unicode-display_width (2.2.0) - uri_template (0.7.0) - websocket-driver (0.7.5) - websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.5) - zeitwerk (2.6.0) - -PLATFORMS - x86_64-darwin-19 - -DEPENDENCIES - datadog-service_catalog! - guard - guard-rspec - guard-rubocop - rails - rake (~> 13.0) - rspec (~> 3.9) - rspec-json_expectations - rubocop (~> 1.7) - rubocop-rake - rubocop-rspec - -BUNDLED WITH - 2.2.11 diff --git a/Rakefile b/Rakefile index bd7a008..795e73e 100644 --- a/Rakefile +++ b/Rakefile @@ -7,4 +7,19 @@ require 'rubocop/rake_task' RSpec::Core::RakeTask.new(:spec) RuboCop::RakeTask.new +RUBY_VERSIONS = '2.7, 3.0, 3.1' + +desc 'Run guard and spec for each supported ruby' +task :spec_all do + RUBY_VERSIONS.split(',').map(&:strip).each do |ruby_version| + puts "----- #{ruby_version} -----" + Bundler.with_unbundled_env do + File.delete('Gemfile.lock') + system("RBENV_VERSION=#{ruby_version} bundle install") + abort unless system("RBENV_VERSION=#{ruby_version} bundle exec rake rubocop") + abort unless system("RBENV_VERSION=#{ruby_version} bundle exec rake spec") + end + end +end + task default: %i[spec rubocop]