Skip to content

Commit

Permalink
Provide status url, fix rspec and upgrade Ruby
Browse files Browse the repository at this point in the history
  • Loading branch information
addersuk committed Nov 11, 2022
1 parent d1ddea8 commit 75e2d7a
Show file tree
Hide file tree
Showing 25 changed files with 42 additions and 19 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ name: Ruby CI

on:
push:

permissions:
contents: read

env:
CI: true

Expand All @@ -18,7 +18,7 @@ jobs:

strategy:
matrix:
ruby-version: [2.7.1]
ruby-version: [3.1.2]

steps:
- uses: actions/checkout@v3
Expand All @@ -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
6 changes: 4 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ inherit_gem:
simplycop: .simplycop.yml

AllCops:
TargetRubyVersion: 2.7.1
TargetRubyVersion: 3.1.2
Rails:
Enabled: false
Documentation:
Enabled: false
Metrics/BlockLength:
Max: 250
Metrics/AbcSize:
Max: 20
Max: 25
Metrics/MethodLength:
Max: 25


13 changes: 13 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -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'
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.7.1
3.1.2
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

ruby '2.7.1'
ruby '3.1.2'
source 'https://rubygems.org'

gem 'airbrake-ruby'
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ DEPENDENCIES
webmock

RUBY VERSION
ruby 2.7.1p114
ruby 3.1.2p20

BUNDLED WITH
2.2.26
12 changes: 8 additions & 4 deletions lib/functionality/base_deploy_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]}"
Expand Down
6 changes: 4 additions & 2 deletions lib/functionality/issue_deploy_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]}"
Expand Down
6 changes: 4 additions & 2 deletions lib/functionality/pr_deploy_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]}"
Expand Down
2 changes: 1 addition & 1 deletion lib/functionality/simply_issue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 75e2d7a

Please sign in to comment.