From ad030ba73ffbfd10b4eef292ca2bc1ac2bf6c60b Mon Sep 17 00:00:00 2001 From: Punit Jain Date: Mon, 13 Sep 2021 10:20:39 +0100 Subject: [PATCH 1/8] change pr target event on all places. --- lib/functionality/simply_issue.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/functionality/simply_issue.rb b/lib/functionality/simply_issue.rb index 8054206..b3c05f5 100644 --- a/lib/functionality/simply_issue.rb +++ b/lib/functionality/simply_issue.rb @@ -6,7 +6,7 @@ # Fetch the labels on PR and issue class SimplyIssue def self.get_label_tags(config) - if config.event_name == 'pull_request' + if %w[pull_request pull_request_target].include?(config.event_name) puts config.event_payload['number'] issue = config.client.pull_request(config.app_repo, config.event_payload['number']) else From ad3114e568ddd161153c50e88c6847ad1f16368d Mon Sep 17 00:00:00 2001 From: Punit Jain Date: Mon, 13 Sep 2021 10:50:57 +0100 Subject: [PATCH 2/8] debug --- lib/action.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/action.rb b/lib/action.rb index 5eb0ad4..8e67989 100644 --- a/lib/action.rb +++ b/lib/action.rb @@ -17,6 +17,7 @@ if config.event_payload['action'] == 'opened' || config.event_payload['action'] == 'synchronize' puts 'Pull request is opened or synchronized' puts '=============================================' + puts config.event_payload PrDeployCheck.base_check(config, 'issues', config.event_payload['pull_request']['head']['sha']) else puts 'Pull request is labeled' From 57fd2ec7019a6d899adddc7a89c85832fdb303cf Mon Sep 17 00:00:00 2001 From: Punit Jain Date: Mon, 13 Sep 2021 10:59:21 +0100 Subject: [PATCH 3/8] debug more --- lib/functionality/base_deploy_check.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/functionality/base_deploy_check.rb b/lib/functionality/base_deploy_check.rb index 7c58485..cb40533 100644 --- a/lib/functionality/base_deploy_check.rb +++ b/lib/functionality/base_deploy_check.rb @@ -7,6 +7,7 @@ # Checks the deploy checks present class BaseDeployCheck def self.base_check(config, event, sha) # rubocop:disable Metrics/AbcSize + puts "config event branch #{config.event_branch}" result = if !config.event_branch.include?('master') && SimplyIssue.get_all_issues( config, event, 'block deploys' From 653e04ec5b0753479b5f3461b334201bdb6044f5 Mon Sep 17 00:00:00 2001 From: Punit Jain Date: Mon, 13 Sep 2021 11:02:25 +0100 Subject: [PATCH 4/8] dont need to check on master --- lib/functionality/base_deploy_check.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/functionality/base_deploy_check.rb b/lib/functionality/base_deploy_check.rb index cb40533..4da1375 100644 --- a/lib/functionality/base_deploy_check.rb +++ b/lib/functionality/base_deploy_check.rb @@ -8,7 +8,7 @@ class BaseDeployCheck def self.base_check(config, event, sha) # rubocop:disable Metrics/AbcSize puts "config event branch #{config.event_branch}" - result = if !config.event_branch.include?('master') && SimplyIssue.get_all_issues( + result = if SimplyIssue.get_all_issues( config, event, 'block deploys' ).length.positive? From 5fab88c035fab9a5ccf145050c5df143bb7def35 Mon Sep 17 00:00:00 2001 From: Punit Jain Date: Mon, 13 Sep 2021 11:07:53 +0100 Subject: [PATCH 5/8] remove test as we dont need to check on master --- specs/base_deploy_check_spec.rb | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/specs/base_deploy_check_spec.rb b/specs/base_deploy_check_spec.rb index ae4c10e..90041f4 100644 --- a/specs/base_deploy_check_spec.rb +++ b/specs/base_deploy_check_spec.rb @@ -13,20 +13,6 @@ let(:config) { GithubApiConfig.new } - context 'when branch is master' do - it 'returns a success for the deploy check' do - ENV['GITHUB_EVENT_PATH'] = Pathname.new(SPEC_FIXTURES_PATH).join('push_payload.json').to_s - ENV['GITHUB_REF'] = 'ref/master' - ENV['GITHUB_EVENT_NAME'] = 'push' - sha = '63f739d5586b2c6b718045893789d620e0d0aee9' - - VCR.use_cassette('status update success') do - response = PrDeployCheck.base_check(config, 'issues', sha) - expect(response['state']).to eq('success') - end - end - end - context 'when there are no blocked deploy issues' do it 'returns a success for the deploy check' do ENV['GITHUB_EVENT_PATH'] = Pathname.new(SPEC_FIXTURES_PATH).join('open_pr_payload.json').to_s From 457812b4b1c4c4829fdf17b817a61b8db770219e Mon Sep 17 00:00:00 2001 From: Punit Jain Date: Mon, 13 Sep 2021 11:08:41 +0100 Subject: [PATCH 6/8] remove some debugs --- lib/action.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/action.rb b/lib/action.rb index 8e67989..d23263d 100644 --- a/lib/action.rb +++ b/lib/action.rb @@ -11,13 +11,11 @@ begin config = GithubApiConfig.new - puts "Event: #{config.event_name} called" case config.event_name when 'pull_request', 'pull_request_target' if config.event_payload['action'] == 'opened' || config.event_payload['action'] == 'synchronize' puts 'Pull request is opened or synchronized' puts '=============================================' - puts config.event_payload PrDeployCheck.base_check(config, 'issues', config.event_payload['pull_request']['head']['sha']) else puts 'Pull request is labeled' From 783329676fb5cb13804c7c415f616d6c8a825708 Mon Sep 17 00:00:00 2001 From: Punit Jain Date: Mon, 13 Sep 2021 11:13:00 +0100 Subject: [PATCH 7/8] rubocop --- lib/functionality/base_deploy_check.rb | 2 +- lib/functionality/simply_issue.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/functionality/base_deploy_check.rb b/lib/functionality/base_deploy_check.rb index 4da1375..6626c24 100644 --- a/lib/functionality/base_deploy_check.rb +++ b/lib/functionality/base_deploy_check.rb @@ -6,7 +6,7 @@ # Checks the deploy checks present class BaseDeployCheck - def self.base_check(config, event, sha) # rubocop:disable Metrics/AbcSize + def self.base_check(config, event, sha) puts "config event branch #{config.event_branch}" result = if SimplyIssue.get_all_issues( config, event, diff --git a/lib/functionality/simply_issue.rb b/lib/functionality/simply_issue.rb index b3c05f5..a0c6fa6 100644 --- a/lib/functionality/simply_issue.rb +++ b/lib/functionality/simply_issue.rb @@ -5,9 +5,9 @@ # Fetch the labels on PR and issue class SimplyIssue - def self.get_label_tags(config) - if %w[pull_request pull_request_target].include?(config.event_name) - puts config.event_payload['number'] + def self.get_label_tags(config) # rubocop:disable Metrics/AbcSize + if %w[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']) else issue = config.client.issue(config.app_repo, config.event_payload['issue']['number']) From a4101cbcf0a3cbc204237952860d5ea30cc17c6b Mon Sep 17 00:00:00 2001 From: Punit Jain Date: Mon, 13 Sep 2021 11:14:01 +0100 Subject: [PATCH 8/8] comon rubocop --- lib/functionality/simply_issue.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/functionality/simply_issue.rb b/lib/functionality/simply_issue.rb index a0c6fa6..ea5396b 100644 --- a/lib/functionality/simply_issue.rb +++ b/lib/functionality/simply_issue.rb @@ -6,7 +6,7 @@ # Fetch the labels on PR and issue class SimplyIssue def self.get_label_tags(config) # rubocop:disable Metrics/AbcSize - if %w[pull_request pull_request_target].include?(config.event_name) + 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']) else