From 4090dd3e6ef142960c71e43b87180f72bfc3f626 Mon Sep 17 00:00:00 2001 From: vineelvineel Date: Thu, 14 Dec 2023 15:52:32 -0500 Subject: [PATCH 01/17] Add circle ci config --- .circleci/config.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..b043dee --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,18 @@ +version: 2.1 + jobs: + build: + working_directory: ~/acts_as_scrubbable + docker: + - image: cimg/ruby:3.2.2 + + steps: + - checkout + - ruby/install-deps + + - run: + name: Run Tests + command: | + mkdir /tmp/test_results + ./cc-test-reporter before-build + + bundle exec rspec --format progress From bbf594e063eebe088814cdadf410c1b8feea47a4 Mon Sep 17 00:00:00 2001 From: Adam Stegman Date: Wed, 3 Jan 2024 15:28:42 -0600 Subject: [PATCH 02/17] indentation --- .circleci/config.yml | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index b043dee..6e17b82 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,18 +1,19 @@ version: 2.1 - jobs: - build: - working_directory: ~/acts_as_scrubbable - docker: - - image: cimg/ruby:3.2.2 - steps: - - checkout - - ruby/install-deps +jobs: + build: + working_directory: ~/acts_as_scrubbable + docker: + - image: cimg/ruby:3.2.2 - - run: - name: Run Tests - command: | - mkdir /tmp/test_results - ./cc-test-reporter before-build + steps: + - checkout + - ruby/install-deps - bundle exec rspec --format progress + - run: + name: Run Tests + command: | + mkdir /tmp/test_results + ./cc-test-reporter before-build + + bundle exec rspec --format progress From b539c70ff42ee59f6d90c9dbd0d2ae1a174475bb Mon Sep 17 00:00:00 2001 From: Adam Stegman Date: Wed, 3 Jan 2024 15:40:39 -0600 Subject: [PATCH 03/17] use orb --- .circleci/config.yml | 12 ++++-------- acts_as_scrubbable.gemspec | 1 + 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6e17b82..41e2e8d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,5 +1,8 @@ version: 2.1 +orbs: + ruby: circleci/ruby@2.1.0 + jobs: build: working_directory: ~/acts_as_scrubbable @@ -9,11 +12,4 @@ jobs: steps: - checkout - ruby/install-deps - - - run: - name: Run Tests - command: | - mkdir /tmp/test_results - ./cc-test-reporter before-build - - bundle exec rspec --format progress + - ruby/rspec-test diff --git a/acts_as_scrubbable.gemspec b/acts_as_scrubbable.gemspec index 172fb29..a089153 100644 --- a/acts_as_scrubbable.gemspec +++ b/acts_as_scrubbable.gemspec @@ -27,6 +27,7 @@ Gem::Specification.new do |s| s.add_development_dependency 'pry-byebug' , '~> 3.2' s.add_development_dependency 'terminal-notifier-guard' , '~> 1.6' s.add_development_dependency 'activerecord-nulldb-adapter', '~> 1.0' + s.add_development_dependency 'rspec_junit_formatter' s.files = `git ls-files`.split("\n") s.test_files = `git ls-files -- spec/*`.split("\n") From 7bcbd55a40b16b555c4d776b77b9c30bbe410a87 Mon Sep 17 00:00:00 2001 From: Adam Stegman Date: Wed, 3 Jan 2024 15:44:20 -0600 Subject: [PATCH 04/17] no cache --- .circleci/config.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 41e2e8d..cd279ac 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -11,5 +11,7 @@ jobs: steps: - checkout - - ruby/install-deps + - ruby/install-deps: + # Always install the latest versions available + with-cache: false - ruby/rspec-test From 56133cf0a2e493963ef514b09009e4351ec1090d Mon Sep 17 00:00:00 2001 From: Adam Stegman Date: Wed, 3 Jan 2024 15:52:52 -0600 Subject: [PATCH 05/17] ugh --- .circleci/config.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index cd279ac..171acef 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -12,6 +12,8 @@ jobs: steps: - checkout - ruby/install-deps: + # Guess we have to keep updating this + bundler-version: 2.5.3 # Always install the latest versions available with-cache: false - ruby/rspec-test From 9ce7190fd7849c4d1c72ef493eb98e43ea1ea359 Mon Sep 17 00:00:00 2001 From: Adam Stegman Date: Wed, 3 Jan 2024 15:55:07 -0600 Subject: [PATCH 06/17] this works slightly better --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 171acef..071381f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -12,8 +12,8 @@ jobs: steps: - checkout - ruby/install-deps: - # Guess we have to keep updating this - bundler-version: 2.5.3 + # Have to set this since there's no lockfile + bundler-version: ">2" # Always install the latest versions available with-cache: false - ruby/rspec-test From a17ad28aa85111e59afe782f6709cd8944220e25 Mon Sep 17 00:00:00 2001 From: Adam Stegman Date: Wed, 3 Jan 2024 15:56:33 -0600 Subject: [PATCH 07/17] one more setting --- .circleci/config.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 071381f..cf87216 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -14,6 +14,8 @@ jobs: - ruby/install-deps: # Have to set this since there's no lockfile bundler-version: ">2" + # Do not use deployment mode, because we don't have a lockfile + path: "bundle" # Always install the latest versions available with-cache: false - ruby/rspec-test From c45be88e72d63dd7060d8c8738ec370ff940a1f8 Mon Sep 17 00:00:00 2001 From: Adam Stegman Date: Wed, 3 Jan 2024 19:27:44 -0600 Subject: [PATCH 08/17] matrix --- .circleci/config.yml | 22 ++++++++++++++++++---- Gemfile | 2 -- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index cf87216..9995e92 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -4,13 +4,17 @@ orbs: ruby: circleci/ruby@2.1.0 jobs: - build: - working_directory: ~/acts_as_scrubbable - docker: - - image: cimg/ruby:3.2.2 + test: + parameters: + ruby-version: + type: string + docker: + - image: cimg/base:stable steps: - checkout + - ruby/install: + version: <> - ruby/install-deps: # Have to set this since there's no lockfile bundler-version: ">2" @@ -19,3 +23,13 @@ jobs: # Always install the latest versions available with-cache: false - ruby/rspec-test + +workflows: + test: + jobs: + - test: + matrix: + parameters: + ruby-version: + - "3.0.6" + - "3.2.2" diff --git a/Gemfile b/Gemfile index 669f0e7..fa75df1 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,3 @@ -ruby '3.2.2' - source 'https://rubygems.org' gemspec From 38a6c55a03a8b5f8c92abaf1bb7f05ac01a2b4dc Mon Sep 17 00:00:00 2001 From: Adam Stegman Date: Thu, 4 Jan 2024 09:22:14 -0600 Subject: [PATCH 09/17] Use ruby executor instead of installing it --- .circleci/config.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9995e92..88c833b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -9,12 +9,11 @@ jobs: ruby-version: type: string - docker: - - image: cimg/base:stable + executor: + name: ruby/default + tag: <> steps: - checkout - - ruby/install: - version: <> - ruby/install-deps: # Have to set this since there's no lockfile bundler-version: ">2" From 056db31efba57445668a0973d122746d5665ce33 Mon Sep 17 00:00:00 2001 From: Adam Stegman Date: Thu, 4 Jan 2024 09:26:37 -0600 Subject: [PATCH 10/17] Add more Ruby versions --- .circleci/config.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 88c833b..363be1f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -30,5 +30,7 @@ workflows: matrix: parameters: ruby-version: - - "3.0.6" + - "3.3.0" - "3.2.2" + - "3.1.4" + - "3.0.6" From 3487a4e8e795e9d3219e3d0bceb5ee47154e10b2 Mon Sep 17 00:00:00 2001 From: Adam Stegman Date: Thu, 4 Jan 2024 09:43:43 -0600 Subject: [PATCH 11/17] Add Rails to the matrix --- .circleci/config.yml | 8 ++++++++ Gemfile | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 363be1f..6167956 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,10 +8,14 @@ jobs: parameters: ruby-version: type: string + rails-version: + type: string executor: name: ruby/default tag: <> + environment: + RAILS_VERSION: <> steps: - checkout - ruby/install-deps: @@ -34,3 +38,7 @@ workflows: - "3.2.2" - "3.1.4" - "3.0.6" + rails-version: + - "~> 7.1.0" + - "~> 7.0.0" + - "~> 6.1.0" diff --git a/Gemfile b/Gemfile index fa75df1..d0d6560 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,8 @@ source 'https://rubygems.org' gemspec + +# Lock Rails down in the matrix build, but not by default +gem "activesupport", ENV.fetch("RAILS_VERSION", nil) +gem "activerecord", ENV.fetch("RAILS_VERSION", nil) +gem "railties", ENV.fetch("RAILS_VERSION", nil) From 4f9a6d92579c021ecbd878ed6ffa0db4e3fa6778 Mon Sep 17 00:00:00 2001 From: Adam Stegman Date: Thu, 4 Jan 2024 10:19:19 -0600 Subject: [PATCH 12/17] Add Ruby head --- .circleci/config.yml | 66 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 57 insertions(+), 9 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6167956..2f14fc4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,5 +1,18 @@ version: 2.1 +_references: + ruby_versions: &ruby_versions + ruby-version: + - "3.3.0" + - "3.2.2" + - "3.1.4" + - "3.0.6" + rails_versions: &rails_versions + rails-version: + - "~> 7.1.0" + - "~> 7.0.0" + - "~> 6.1.0" + orbs: ruby: circleci/ruby@2.1.0 @@ -26,6 +39,44 @@ jobs: # Always install the latest versions available with-cache: false - ruby/rspec-test + test-ruby-head: + parameters: + rails-version: + type: string + docker: + - image: cimg/base:stable + environment: + RAILS_VERSION: <> + steps: + - checkout + - ruby/install: + # RVM wants Ruby 2 for some reason to install Ruby head. + # But then it will use 2.7.8 by default in the future; + # we must use `rvm use ruby-head` before every command that matters + version: "2.7.8" + - ruby/install: + version: ruby-head + - restore_cache: + keys: + - v1-{{ arch }}-ruby-head-bundler + - run: + name: Install Ruby dependencies + command: | + rvm use ruby-head + ruby --version + gem install bundler + bundle config set path bundle + bundle update + - save_cache: + key: v1-{{ arch }}-ruby-head-bundler + paths: + - ./bundle + - run: + name: RSpec tests + command: | + rvm use ruby-head + ruby --version + bundle exec rspec workflows: test: @@ -33,12 +84,9 @@ workflows: - test: matrix: parameters: - ruby-version: - - "3.3.0" - - "3.2.2" - - "3.1.4" - - "3.0.6" - rails-version: - - "~> 7.1.0" - - "~> 7.0.0" - - "~> 6.1.0" + <<: *ruby_versions + <<: *rails_versions + - test-ruby-head: + matrix: + parameters: + <<: *rails_versions From 38dbc174baed95b919a9e8d9bc5f9661a6232255 Mon Sep 17 00:00:00 2001 From: Adam Stegman Date: Thu, 4 Jan 2024 16:11:45 -0600 Subject: [PATCH 13/17] Add rails main --- .circleci/config.yml | 4 ++++ Gemfile | 13 ++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2f14fc4..4c16671 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -12,6 +12,7 @@ _references: - "~> 7.1.0" - "~> 7.0.0" - "~> 6.1.0" + - "main" orbs: ruby: circleci/ruby@2.1.0 @@ -86,6 +87,9 @@ workflows: parameters: <<: *ruby_versions <<: *rails_versions + exclude: + - ruby-version: 3.0.6 + rails-version: main - test-ruby-head: matrix: parameters: diff --git a/Gemfile b/Gemfile index d0d6560..08ed0f5 100644 --- a/Gemfile +++ b/Gemfile @@ -3,6 +3,13 @@ source 'https://rubygems.org' gemspec # Lock Rails down in the matrix build, but not by default -gem "activesupport", ENV.fetch("RAILS_VERSION", nil) -gem "activerecord", ENV.fetch("RAILS_VERSION", nil) -gem "railties", ENV.fetch("RAILS_VERSION", nil) +rails_version = ENV.fetch("RAILS_VERSION", nil) +if rails_version == "main" + gem "activesupport", github: "rails/rails", branch: "main" + gem "activerecord", github: "rails/rails", branch: "main" + gem "railties", github: "rails/rails", branch: "main" +elsif rails_version + gem "activesupport", rails_version + gem "activerecord", rails_version + gem "railties", rails_version +end From 60f79bcb7254105c913940c6c53c922133dc2828 Mon Sep 17 00:00:00 2001 From: Adam Stegman Date: Thu, 4 Jan 2024 17:23:28 -0600 Subject: [PATCH 14/17] name --- .circleci/config.yml | 26 ++++++++++++++------------ Gemfile | 12 ++++++------ 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4c16671..80f1125 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,11 +7,11 @@ _references: - "3.2.2" - "3.1.4" - "3.0.6" - rails_versions: &rails_versions - rails-version: - - "~> 7.1.0" - - "~> 7.0.0" - - "~> 6.1.0" + rails_version_prefixess: &rails_version_prefixes + rails-version-prefix: + - "7.1" + - "7.0" + - "6.1" - "main" orbs: @@ -22,14 +22,14 @@ jobs: parameters: ruby-version: type: string - rails-version: + rails-version-prefix: type: string executor: name: ruby/default tag: <> environment: - RAILS_VERSION: <> + RAILS_VERSION_PREFIX: <> steps: - checkout - ruby/install-deps: @@ -42,12 +42,12 @@ jobs: - ruby/rspec-test test-ruby-head: parameters: - rails-version: + rails-version-prefix: type: string docker: - image: cimg/base:stable environment: - RAILS_VERSION: <> + RAILS_VERSION: <> steps: - checkout - ruby/install: @@ -83,14 +83,16 @@ workflows: test: jobs: - test: + name: "test-ruby-<>-rails-<>" matrix: parameters: <<: *ruby_versions - <<: *rails_versions + <<: *rails_version_prefixes exclude: - ruby-version: 3.0.6 - rails-version: main + rails-version-prefix: main - test-ruby-head: + name: "test-ruby-head-rails-<>" matrix: parameters: - <<: *rails_versions + <<: *rails_version_prefixes diff --git a/Gemfile b/Gemfile index 08ed0f5..31e2630 100644 --- a/Gemfile +++ b/Gemfile @@ -3,13 +3,13 @@ source 'https://rubygems.org' gemspec # Lock Rails down in the matrix build, but not by default -rails_version = ENV.fetch("RAILS_VERSION", nil) -if rails_version == "main" +rails_version_prefix = ENV.fetch("RAILS_VERSION_PREFIX", nil) +if rails_version_prefix == "main" gem "activesupport", github: "rails/rails", branch: "main" gem "activerecord", github: "rails/rails", branch: "main" gem "railties", github: "rails/rails", branch: "main" -elsif rails_version - gem "activesupport", rails_version - gem "activerecord", rails_version - gem "railties", rails_version +elsif rails_version_prefix + gem "activesupport", "~> #{rails_version_prefix}.0" + gem "activerecord", "~> #{rails_version_prefix}.0" + gem "railties", "~> #{rails_version_prefix}.0" end From 1f7a663009cb78b8ba27aea9a32a0b132d865d1b Mon Sep 17 00:00:00 2001 From: Adam Stegman Date: Thu, 4 Jan 2024 17:37:25 -0600 Subject: [PATCH 15/17] pr-security updates --- .github/workflows/pr-security.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/pr-security.yaml b/.github/workflows/pr-security.yaml index 708a53b..6d211f8 100644 --- a/.github/workflows/pr-security.yaml +++ b/.github/workflows/pr-security.yaml @@ -10,12 +10,18 @@ name: PR Security on: pull_request: branches: [main, master] + push: + branches: + - gh-readonly-queue/master/** permissions: # Required for workflows in private repositories. contents: read + # Required to write summary PR comments of results. + pull-requests: write + # Required for SARIF results upload to GHAS. security-events: write actions: read From 6f51638279be6347b83176c708572ad1c1a1b3e4 Mon Sep 17 00:00:00 2001 From: Adam Stegman Date: Thu, 4 Jan 2024 17:50:33 -0600 Subject: [PATCH 16/17] Store test results --- .circleci/config.yml | 5 +++- .github/workflows/pr-security.yaml | 38 ------------------------------ 2 files changed, 4 insertions(+), 39 deletions(-) delete mode 100644 .github/workflows/pr-security.yaml diff --git a/.circleci/config.yml b/.circleci/config.yml index 80f1125..257faff 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -77,7 +77,10 @@ jobs: command: | rvm use ruby-head ruby --version - bundle exec rspec + mkdir -p /tmp/test-results/rspec + bundle exec rspec --profile 10 --format RspecJunitFormatter --out /tmp/test-results/rspec/results.xml --format progress + - store_test_results: + path: /tmp/test-results/rspec workflows: test: diff --git a/.github/workflows/pr-security.yaml b/.github/workflows/pr-security.yaml deleted file mode 100644 index 6d211f8..0000000 --- a/.github/workflows/pr-security.yaml +++ /dev/null @@ -1,38 +0,0 @@ ---- -# onemedical//.github/workflows/pr-security.yaml -# -# This is the workflow for distribution to repositories across the organization. -# It will call the reusable PR security workflow, and run scans against each PR. -name: PR Security - - -# yamllint disable-line rule:truthy -on: - pull_request: - branches: [main, master] - push: - branches: - - gh-readonly-queue/master/** - - -permissions: - # Required for workflows in private repositories. - contents: read - - # Required to write summary PR comments of results. - pull-requests: write - - # Required for SARIF results upload to GHAS. - security-events: write - actions: read - - -jobs: - # Run the reusable workflow. - run-workflow: - name: Run Workflow - # yamllint disable-line rule:line-length - uses: onemedical/github-reusable-workflows/.github/workflows/reusable-pr-security.yaml@main - # The detect-secrets tool is used in some repositories, and generates false - # positives like the one below. Add comment to ignore. - secrets: inherit # pragma: allowlist secret From 3f781a0799ccd553ce567f9198fd482505a3f379 Mon Sep 17 00:00:00 2001 From: Adam Stegman Date: Fri, 5 Jan 2024 09:52:51 -0600 Subject: [PATCH 17/17] Separate jobs for better clarity If head jobs fail, it's probably fine. If released versions fail, it's an issue. --- .circleci/config.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 257faff..c6287da 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -12,7 +12,6 @@ _references: - "7.1" - "7.0" - "6.1" - - "main" orbs: ruby: circleci/ruby@2.1.0 @@ -91,6 +90,15 @@ workflows: parameters: <<: *ruby_versions <<: *rails_version_prefixes + test-head: + jobs: + - test: + name: "test-ruby-<>-rails-main" + matrix: + parameters: + <<: *ruby_versions + rails-version-prefix: + - main exclude: - ruby-version: 3.0.6 rails-version-prefix: main