diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e865d5d..4f44f04 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,10 +2,10 @@ name: Ruby CI on: push: - + permissions: contents: read - + env: CI: true @@ -18,7 +18,7 @@ jobs: strategy: matrix: - ruby-version: [2.7.1] + ruby-version: [3.1.2] steps: - uses: actions/checkout@v3 @@ -31,5 +31,5 @@ jobs: - name: rubocop run: bundle exec rubocop - name: Run all tests - run: bundle exec rspec specs + run: bundle exec rspec shell: bash diff --git a/.rubocop.yml b/.rubocop.yml index d6abb0e..75ffbe1 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -2,7 +2,7 @@ inherit_gem: simplycop: .simplycop.yml AllCops: - TargetRubyVersion: 2.7.1 + TargetRubyVersion: 3.1.2 Rails: Enabled: false Documentation: @@ -10,6 +10,8 @@ AllCops: Metrics/BlockLength: Max: 250 Metrics/AbcSize: - Max: 20 + Max: 25 Metrics/MethodLength: Max: 25 + + diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 0000000..a259538 --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,13 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2022-11-11 11:58:12 UTC using RuboCop version 1.35.1. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Lint/RedundantCopDisableDirective: + Exclude: + - 'lib/functionality/simply_issue.rb' diff --git a/.ruby-version b/.ruby-version index 860487c..ef538c2 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.7.1 +3.1.2 diff --git a/Gemfile b/Gemfile index c16fe41..8edd26f 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ # frozen_string_literal: true -ruby '2.7.1' +ruby '3.1.2' source 'https://rubygems.org' gem 'airbrake-ruby' diff --git a/Gemfile.lock b/Gemfile.lock index fda8946..330fc3a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -98,7 +98,7 @@ DEPENDENCIES webmock RUBY VERSION - ruby 2.7.1p114 + ruby 3.1.2p20 BUNDLED WITH 2.2.26 diff --git a/lib/functionality/base_deploy_check.rb b/lib/functionality/base_deploy_check.rb index 1940b6b..50ec0cc 100644 --- a/lib/functionality/base_deploy_check.rb +++ b/lib/functionality/base_deploy_check.rb @@ -10,13 +10,17 @@ def self.base_check(config, event, sha) puts "config event branch #{config.event_branch}" result = if SimplyIssue.block_deploys?(config, event) config.client.create_status( - config.app_repo, sha, 'failure', description: 'Deploys are blocked', - context: context_name + config.app_repo, sha, 'failure', + description: 'Deploys are blocked', + context: context_name, + target_url: config.event_payload['html_url'] ) else config.client.create_status( - config.app_repo, sha, 'success', description: 'You are free to deploy', - context: context_name + config.app_repo, sha, 'success', + description: 'You are free to deploy', + context: context_name, + target_url: config.event_payload['html_url'] ) end puts "Created #{result[:state]} state with description #{result[:description]}" diff --git a/lib/functionality/issue_deploy_check.rb b/lib/functionality/issue_deploy_check.rb index 4ded3cb..c230ba0 100644 --- a/lib/functionality/issue_deploy_check.rb +++ b/lib/functionality/issue_deploy_check.rb @@ -28,8 +28,10 @@ def self.create_status_for_all_prs(config, status, message) all_pull_requests = SimplyIssue.get_all_issues(config, 'pull_request') all_pull_requests.each do |pr| result = config.client.create_status( - config.app_repo, pr['head']['sha'], status, description: message, - context: context_name + config.app_repo, pr['head']['sha'], status, + description: message, + context: context_name, + target_url: config.event_payload['html_url'] ) puts "Created #{result[:state]} state with" \ " description #{result[:description]} for PR #{pr.number} and url #{result[:url]}" diff --git a/lib/functionality/pr_deploy_check.rb b/lib/functionality/pr_deploy_check.rb index a8b426d..bba731f 100644 --- a/lib/functionality/pr_deploy_check.rb +++ b/lib/functionality/pr_deploy_check.rb @@ -13,8 +13,10 @@ def self.check_labeled_pr(config) sha = config.event_payload['pull_request']['head']['sha'] result = config.client.create_status( - config.app_repo, sha, - 'success', description: 'You are free to deploy', context: context_name + config.app_repo, sha, 'success', + description: 'You are free to deploy', + context: context_name, + target_url: config.event_payload['html_url'] ) puts "Created #{result[:state]} state with" \ "description #{result[:description]} for sha #{sha} and url #{result[:url]}" diff --git a/lib/functionality/simply_issue.rb b/lib/functionality/simply_issue.rb index 63d157a..35606a9 100644 --- a/lib/functionality/simply_issue.rb +++ b/lib/functionality/simply_issue.rb @@ -5,7 +5,7 @@ # Fetch the labels on PR and issue class SimplyIssue - def self.get_label_tags(config) # rubocop:disable Metrics/AbcSize + def self.get_label_tags(config) if ['pull_request', 'pull_request_target'].include?(config.event_name) puts "Pull request #{config.event_payload['number']}" issue = config.client.pull_request(config.app_repo, config.event_payload['number']) diff --git a/specs/base_deploy_check_spec.rb b/spec/base_deploy_check_spec.rb similarity index 100% rename from specs/base_deploy_check_spec.rb rename to spec/base_deploy_check_spec.rb diff --git a/specs/fixtures/labeled_pr_payload.json b/spec/fixtures/labeled_pr_payload.json similarity index 100% rename from specs/fixtures/labeled_pr_payload.json rename to spec/fixtures/labeled_pr_payload.json diff --git a/specs/fixtures/new_pr_payload.json b/spec/fixtures/new_pr_payload.json similarity index 100% rename from specs/fixtures/new_pr_payload.json rename to spec/fixtures/new_pr_payload.json diff --git a/specs/fixtures/open_pr_payload.json b/spec/fixtures/open_pr_payload.json similarity index 100% rename from specs/fixtures/open_pr_payload.json rename to spec/fixtures/open_pr_payload.json diff --git a/specs/fixtures/push_payload.json b/spec/fixtures/push_payload.json similarity index 100% rename from specs/fixtures/push_payload.json rename to spec/fixtures/push_payload.json diff --git a/specs/fixtures/vcr_cassettes/all_issues_with_blocked_deploy_tag.yml b/spec/fixtures/vcr_cassettes/all_issues_with_blocked_deploy_tag.yml similarity index 100% rename from specs/fixtures/vcr_cassettes/all_issues_with_blocked_deploy_tag.yml rename to spec/fixtures/vcr_cassettes/all_issues_with_blocked_deploy_tag.yml diff --git a/specs/fixtures/vcr_cassettes/all_prs.yml b/spec/fixtures/vcr_cassettes/all_prs.yml similarity index 100% rename from specs/fixtures/vcr_cassettes/all_prs.yml rename to spec/fixtures/vcr_cassettes/all_prs.yml diff --git a/specs/fixtures/vcr_cassettes/blocked_deploy_update_failure.yml b/spec/fixtures/vcr_cassettes/blocked_deploy_update_failure.yml similarity index 100% rename from specs/fixtures/vcr_cassettes/blocked_deploy_update_failure.yml rename to spec/fixtures/vcr_cassettes/blocked_deploy_update_failure.yml diff --git a/specs/fixtures/vcr_cassettes/emergency_deploy_update_success.yml b/spec/fixtures/vcr_cassettes/emergency_deploy_update_success.yml similarity index 100% rename from specs/fixtures/vcr_cassettes/emergency_deploy_update_success.yml rename to spec/fixtures/vcr_cassettes/emergency_deploy_update_success.yml diff --git a/specs/fixtures/vcr_cassettes/no_blocked_deploy_update_success.yml b/spec/fixtures/vcr_cassettes/no_blocked_deploy_update_success.yml similarity index 100% rename from specs/fixtures/vcr_cassettes/no_blocked_deploy_update_success.yml rename to spec/fixtures/vcr_cassettes/no_blocked_deploy_update_success.yml diff --git a/specs/fixtures/vcr_cassettes/status_update_success.yml b/spec/fixtures/vcr_cassettes/status_update_success.yml similarity index 100% rename from specs/fixtures/vcr_cassettes/status_update_success.yml rename to spec/fixtures/vcr_cassettes/status_update_success.yml diff --git a/specs/helpers/test_helper_global_methods.rb b/spec/helpers/test_helper_global_methods.rb similarity index 91% rename from specs/helpers/test_helper_global_methods.rb rename to spec/helpers/test_helper_global_methods.rb index e432105..6bb1783 100644 --- a/specs/helpers/test_helper_global_methods.rb +++ b/spec/helpers/test_helper_global_methods.rb @@ -13,7 +13,7 @@ def configure_vcr private def vcr_config(config) - config.cassette_library_dir = 'specs/fixtures/vcr_cassettes' + config.cassette_library_dir = 'spec/fixtures/vcr_cassettes' config.hook_into :webmock config.allow_http_connections_when_no_cassette = true cassette_options(config) diff --git a/specs/pr_deploy_check_spec.rb b/spec/pr_deploy_check_spec.rb similarity index 100% rename from specs/pr_deploy_check_spec.rb rename to spec/pr_deploy_check_spec.rb diff --git a/specs/simply_issue_spec.rb b/spec/simply_issue_spec.rb similarity index 100% rename from specs/simply_issue_spec.rb rename to spec/simply_issue_spec.rb diff --git a/specs/spec_helper.rb b/spec/spec_helper.rb similarity index 100% rename from specs/spec_helper.rb rename to spec/spec_helper.rb