From 8955e5299859155a59fb726cc6cdeb5102e0d912 Mon Sep 17 00:00:00 2001 From: Noah Davis <11672+noahd1@users.noreply.github.com> Date: Tue, 8 Jul 2025 16:16:56 -0700 Subject: [PATCH 1/9] Allow sending a EOL commit status --- lib/cc/pull_requests.rb | 22 ++++++++++++++++++++++ lib/cc/services/github_pull_requests.rb | 8 ++++++++ 2 files changed, 30 insertions(+) diff --git a/lib/cc/pull_requests.rb b/lib/cc/pull_requests.rb index 9d26cb8..54c47d8 100644 --- a/lib/cc/pull_requests.rb +++ b/lib/cc/pull_requests.rb @@ -79,6 +79,10 @@ def test_status_code raise NotImplementedError end + def eol_commit_status_enabled? + false + end + def receive_test_status url = base_status_url("0" * 40) params = { state: "success" } @@ -103,6 +107,7 @@ def receive_request(*permitted_statuses, call_method) if permitted_statuses.flatten.include?(state) && report_status? send(call_method.to_s + "_#{state}") + send_eol_commit_status(commit_sha) else @response = simple_failure("Unknown state") end @@ -110,6 +115,23 @@ def receive_request(*permitted_statuses, call_method) response end + def send_eol_commit_status(commit_sha) + return unless eol_commit_status_enabled? + + # Temporarily store the original target_url and replace it + original_target_url = @payload["details_url"] + @payload["details_url"] = "https://docs.qlty.sh/migration/guide" + + update_status( + "failure", + "Code Climate support is ending! Please migrate to qlty.sh", + "codeclimate/eol" + ) + + # Restore the original target_url + @payload["details_url"] = original_target_url + end + def presenter CC::Service::PullRequestsPresenter.new(@payload) end diff --git a/lib/cc/services/github_pull_requests.rb b/lib/cc/services/github_pull_requests.rb index 605d3f0..213c122 100644 --- a/lib/cc/services/github_pull_requests.rb +++ b/lib/cc/services/github_pull_requests.rb @@ -19,6 +19,10 @@ class Config < CC::Service::Config attribute :rollout_percentage, Axiom::Types::Integer, label: "Author Rollout Percentage", description: "The percentage of users to report status for" + attribute :eol_commit_status_enabled, Axiom::Types::Boolean, + label: "EOL Commit Status Enabled", + description: "Enable EOL commit status reporting", + default: false validates :oauth_token, presence: true end @@ -135,4 +139,8 @@ def response_includes_repo_scope?(response) def test_status_code 422 end + + def eol_commit_status_enabled? + config.eol_commit_status_enabled + end end From bc0bf88332aaf1a41dffd137663c301e6eff8932 Mon Sep 17 00:00:00 2001 From: Noah Davis <11672+noahd1@users.noreply.github.com> Date: Tue, 8 Jul 2025 16:27:52 -0700 Subject: [PATCH 2/9] Change terminology --- .qlty/.gitignore | 7 +++ .qlty/configs/.shellcheckrc | 1 + .qlty/configs/.yamllint.yaml | 8 +++ .qlty/qlty.toml | 82 +++++++++++++++++++++++++ lib/cc/pull_requests.rb | 12 ++-- lib/cc/services/github_pull_requests.rb | 10 +-- 6 files changed, 109 insertions(+), 11 deletions(-) create mode 100644 .qlty/.gitignore create mode 100644 .qlty/configs/.shellcheckrc create mode 100644 .qlty/configs/.yamllint.yaml create mode 100644 .qlty/qlty.toml diff --git a/.qlty/.gitignore b/.qlty/.gitignore new file mode 100644 index 0000000..3036618 --- /dev/null +++ b/.qlty/.gitignore @@ -0,0 +1,7 @@ +* +!configs +!configs/** +!hooks +!hooks/** +!qlty.toml +!.gitignore diff --git a/.qlty/configs/.shellcheckrc b/.qlty/configs/.shellcheckrc new file mode 100644 index 0000000..6a38d92 --- /dev/null +++ b/.qlty/configs/.shellcheckrc @@ -0,0 +1 @@ +source-path=SCRIPTDIR \ No newline at end of file diff --git a/.qlty/configs/.yamllint.yaml b/.qlty/configs/.yamllint.yaml new file mode 100644 index 0000000..d22fa77 --- /dev/null +++ b/.qlty/configs/.yamllint.yaml @@ -0,0 +1,8 @@ +rules: + document-start: disable + quoted-strings: + required: only-when-needed + extra-allowed: ["{|}"] + key-duplicates: {} + octal-values: + forbid-implicit-octal: true diff --git a/.qlty/qlty.toml b/.qlty/qlty.toml new file mode 100644 index 0000000..ce1d938 --- /dev/null +++ b/.qlty/qlty.toml @@ -0,0 +1,82 @@ +# This file was automatically generated by `qlty init`. +# You can modify it to suit your needs. +# We recommend you to commit this file to your repository. +# +# This configuration is used by both Qlty CLI and Qlty Cloud. +# +# Qlty CLI -- Code quality toolkit for developers +# Qlty Cloud -- Fully automated Code Health Platform +# +# Try Qlty Cloud: https://qlty.sh +# +# For a guide to configuration, visit https://qlty.sh/d/config +# Or for a full reference, visit https://qlty.sh/d/qlty-toml +config_version = "0" + +exclude_patterns = [ + "*_min.*", + "*-min.*", + "*.min.*", + "**/.yarn/**", + "**/*.d.ts", + "**/assets/**", + "**/bower_components/**", + "**/build/**", + "**/cache/**", + "**/config/**", + "**/db/**", + "**/deps/**", + "**/dist/**", + "**/extern/**", + "**/external/**", + "**/generated/**", + "**/Godeps/**", + "**/gradlew/**", + "**/mvnw/**", + "**/node_modules/**", + "**/protos/**", + "**/seed/**", + "**/target/**", + "**/templates/**", + "**/testdata/**", + "**/vendor/**", +] + +test_patterns = [ + "**/test/**", + "**/spec/**", + "**/*.test.*", + "**/*.spec.*", + "**/*_test.*", + "**/*_spec.*", + "**/test_*.*", + "**/spec_*.*", +] + +[smells] +mode = "comment" + +[smells.boolean_logic] +threshold = 4 + +[smells.file_complexity] +threshold = 55 + +[smells.return_statements] +threshold = 4 + +[smells.nested_control_flow] +threshold = 4 + +[smells.function_parameters] +threshold = 4 + +[smells.function_complexity] +threshold = 5 + +[smells.duplication] +threshold = 22 + +[[source]] +name = "default" +default = true diff --git a/lib/cc/pull_requests.rb b/lib/cc/pull_requests.rb index 54c47d8..74501ec 100644 --- a/lib/cc/pull_requests.rb +++ b/lib/cc/pull_requests.rb @@ -79,7 +79,7 @@ def test_status_code raise NotImplementedError end - def eol_commit_status_enabled? + def hard_fail_migration_notice_enabled? false end @@ -107,7 +107,7 @@ def receive_request(*permitted_statuses, call_method) if permitted_statuses.flatten.include?(state) && report_status? send(call_method.to_s + "_#{state}") - send_eol_commit_status(commit_sha) + send_hard_fail_migration_notice_commit_status(commit_sha) else @response = simple_failure("Unknown state") end @@ -115,8 +115,8 @@ def receive_request(*permitted_statuses, call_method) response end - def send_eol_commit_status(commit_sha) - return unless eol_commit_status_enabled? + def send_hard_fail_migration_notice_commit_status(commit_sha) + return unless hard_fail_migration_notice_enabled? # Temporarily store the original target_url and replace it original_target_url = @payload["details_url"] @@ -124,8 +124,8 @@ def send_eol_commit_status(commit_sha) update_status( "failure", - "Code Climate support is ending! Please migrate to qlty.sh", - "codeclimate/eol" + "Code Climate plans to stop sending commit statuses to GitHub. Migrate to Qlty.sh for continued support.", + "codeclimate/migrate-to-qlty-sh" ) # Restore the original target_url diff --git a/lib/cc/services/github_pull_requests.rb b/lib/cc/services/github_pull_requests.rb index 213c122..9cfb95b 100644 --- a/lib/cc/services/github_pull_requests.rb +++ b/lib/cc/services/github_pull_requests.rb @@ -19,9 +19,9 @@ class Config < CC::Service::Config attribute :rollout_percentage, Axiom::Types::Integer, label: "Author Rollout Percentage", description: "The percentage of users to report status for" - attribute :eol_commit_status_enabled, Axiom::Types::Boolean, - label: "EOL Commit Status Enabled", - description: "Enable EOL commit status reporting", + attribute :hard_fail_migration_notice, Axiom::Types::Boolean, + label: "Hard Fail Migration Notice Enabled", + description: "Enable hard fail commit status migration notice reporting", default: false validates :oauth_token, presence: true @@ -140,7 +140,7 @@ def test_status_code 422 end - def eol_commit_status_enabled? - config.eol_commit_status_enabled + def hard_fail_migration_notice_enabled? + config.hard_fail_migration_notice end end From 46fc9e2e0cffd6cdc5457eedbd8b1578a2da4b94 Mon Sep 17 00:00:00 2001 From: Noah Davis <11672+noahd1@users.noreply.github.com> Date: Tue, 8 Jul 2025 16:33:34 -0700 Subject: [PATCH 3/9] Update copy --- lib/cc/pull_requests.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cc/pull_requests.rb b/lib/cc/pull_requests.rb index 74501ec..c147f98 100644 --- a/lib/cc/pull_requests.rb +++ b/lib/cc/pull_requests.rb @@ -124,7 +124,7 @@ def send_hard_fail_migration_notice_commit_status(commit_sha) update_status( "failure", - "Code Climate plans to stop sending commit statuses to GitHub. Migrate to Qlty.sh for continued support.", + "Code Climate will stop sending commit statuses to GitHub on July 18th. Migrate to Qlty.sh for continued support.", "codeclimate/migrate-to-qlty-sh" ) From 596ca17bb3918c5ebaa16c7611634fdf2c502e13 Mon Sep 17 00:00:00 2001 From: Noah Davis <11672+noahd1@users.noreply.github.com> Date: Tue, 8 Jul 2025 17:05:47 -0700 Subject: [PATCH 4/9] Fix test --- spec/cc/pull_requests_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/cc/pull_requests_spec.rb b/spec/cc/pull_requests_spec.rb index 8c5760b..24fedde 100644 --- a/spec/cc/pull_requests_spec.rb +++ b/spec/cc/pull_requests_spec.rb @@ -8,7 +8,7 @@ end context "when the status is valid" do - let(:instance) { CC::PullRequests.new({}, name: "test", state: payload_status) } + let(:instance) { CC::PullRequests.new({}, commit_sha: "abcd", name: "test", state: payload_status) } let(:response) do { ok: true, From 5834378258caf3fcc44209e6267048d58f0014e6 Mon Sep 17 00:00:00 2001 From: Noah Davis <11672+noahd1@users.noreply.github.com> Date: Tue, 8 Jul 2025 20:20:23 -0700 Subject: [PATCH 5/9] Terminology --- lib/cc/pull_requests.rb | 8 ++++---- lib/cc/services/github_pull_requests.rb | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/cc/pull_requests.rb b/lib/cc/pull_requests.rb index c147f98..dacda80 100644 --- a/lib/cc/pull_requests.rb +++ b/lib/cc/pull_requests.rb @@ -79,7 +79,7 @@ def test_status_code raise NotImplementedError end - def hard_fail_migration_notice_enabled? + def create_migration_notice_commit_status_enabled? false end @@ -107,7 +107,7 @@ def receive_request(*permitted_statuses, call_method) if permitted_statuses.flatten.include?(state) && report_status? send(call_method.to_s + "_#{state}") - send_hard_fail_migration_notice_commit_status(commit_sha) + create_migration_notice_commit_status(commit_sha) else @response = simple_failure("Unknown state") end @@ -115,8 +115,8 @@ def receive_request(*permitted_statuses, call_method) response end - def send_hard_fail_migration_notice_commit_status(commit_sha) - return unless hard_fail_migration_notice_enabled? + def create_migration_notice_commit_status(commit_sha) + return unless create_migration_notice_commit_status_enabled? # Temporarily store the original target_url and replace it original_target_url = @payload["details_url"] diff --git a/lib/cc/services/github_pull_requests.rb b/lib/cc/services/github_pull_requests.rb index 9cfb95b..8f66443 100644 --- a/lib/cc/services/github_pull_requests.rb +++ b/lib/cc/services/github_pull_requests.rb @@ -19,9 +19,9 @@ class Config < CC::Service::Config attribute :rollout_percentage, Axiom::Types::Integer, label: "Author Rollout Percentage", description: "The percentage of users to report status for" - attribute :hard_fail_migration_notice, Axiom::Types::Boolean, - label: "Hard Fail Migration Notice Enabled", - description: "Enable hard fail commit status migration notice reporting", + attribute :create_migration_notice_commit_status, Axiom::Types::Boolean, + label: "Create Migration Notice", + description: "Post a notice about the migration to Qlty.sh as a failing commit status", default: false validates :oauth_token, presence: true @@ -140,7 +140,7 @@ def test_status_code 422 end - def hard_fail_migration_notice_enabled? - config.hard_fail_migration_notice + def create_migration_notice_commit_status_enabled? + config.create_migration_notice_commit_status end end From 4ef47fd32519aaa69dea567ce18587ba5c040b98 Mon Sep 17 00:00:00 2001 From: Noah Davis <11672+noahd1@users.noreply.github.com> Date: Tue, 8 Jul 2025 20:26:53 -0700 Subject: [PATCH 6/9] Make success for now --- lib/cc/pull_requests.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cc/pull_requests.rb b/lib/cc/pull_requests.rb index dacda80..88d9de0 100644 --- a/lib/cc/pull_requests.rb +++ b/lib/cc/pull_requests.rb @@ -123,7 +123,7 @@ def create_migration_notice_commit_status(commit_sha) @payload["details_url"] = "https://docs.qlty.sh/migration/guide" update_status( - "failure", + "success", # will change this or make this failing soon "Code Climate will stop sending commit statuses to GitHub on July 18th. Migrate to Qlty.sh for continued support.", "codeclimate/migrate-to-qlty-sh" ) From c097ebf18cdb667af016b1e81faacf75faad7e49 Mon Sep 17 00:00:00 2001 From: Noah Davis <11672+noahd1@users.noreply.github.com> Date: Wed, 9 Jul 2025 09:52:00 -0700 Subject: [PATCH 7/9] Update commit status --- lib/cc/pull_requests.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/cc/pull_requests.rb b/lib/cc/pull_requests.rb index 88d9de0..8cf8ce5 100644 --- a/lib/cc/pull_requests.rb +++ b/lib/cc/pull_requests.rb @@ -121,13 +121,13 @@ def create_migration_notice_commit_status(commit_sha) # Temporarily store the original target_url and replace it original_target_url = @payload["details_url"] @payload["details_url"] = "https://docs.qlty.sh/migration/guide" - + update_status( "success", # will change this or make this failing soon - "Code Climate will stop sending commit statuses to GitHub on July 18th. Migrate to Qlty.sh for continued support.", - "codeclimate/migrate-to-qlty-sh" + "Code Climate will stop sending commit statuses to GitHub imminently. Migrate to Qlty.sh for continued support.", + "codeclimate/eol" ) - + # Restore the original target_url @payload["details_url"] = original_target_url end From 31303a8e12aa007491172eddbb612d0405c23ef5 Mon Sep 17 00:00:00 2001 From: Noah Davis <11672+noahd1@users.noreply.github.com> Date: Wed, 9 Jul 2025 10:19:09 -0700 Subject: [PATCH 8/9] Update to error status --- .tool-versions | 1 + lib/cc/pull_requests.rb | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 .tool-versions diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 0000000..a4023dc --- /dev/null +++ b/.tool-versions @@ -0,0 +1 @@ +ruby 2.7.5 diff --git a/lib/cc/pull_requests.rb b/lib/cc/pull_requests.rb index 8cf8ce5..eb839f4 100644 --- a/lib/cc/pull_requests.rb +++ b/lib/cc/pull_requests.rb @@ -123,9 +123,9 @@ def create_migration_notice_commit_status(commit_sha) @payload["details_url"] = "https://docs.qlty.sh/migration/guide" update_status( - "success", # will change this or make this failing soon - "Code Climate will stop sending commit statuses to GitHub imminently. Migrate to Qlty.sh for continued support.", - "codeclimate/eol" + "error", + "Code Climate has been replaced by Qlty and will be eol imminently.", + "codeclimate/upgrade" ) # Restore the original target_url From c172c826a6b090832375941830fad9fcc2e192ed Mon Sep 17 00:00:00 2001 From: Noah Davis <11672+noahd1@users.noreply.github.com> Date: Wed, 9 Jul 2025 12:24:18 -0700 Subject: [PATCH 9/9] Capitalization --- lib/cc/pull_requests.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cc/pull_requests.rb b/lib/cc/pull_requests.rb index eb839f4..bcae0e3 100644 --- a/lib/cc/pull_requests.rb +++ b/lib/cc/pull_requests.rb @@ -124,7 +124,7 @@ def create_migration_notice_commit_status(commit_sha) update_status( "error", - "Code Climate has been replaced by Qlty and will be eol imminently.", + "Code Climate has been replaced by Qlty and will be EOL imminently.", "codeclimate/upgrade" )