diff --git a/.rubocop.yml b/.rubocop.yml index 0ace4fe..c55550c 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,6 +1,6 @@ AllCops: NewCops: enable - TargetRubyVersion: 2.5 + TargetRubyVersion: 3.1 Layout/LineLength: Max: 300 diff --git a/CHANGELOG.md b/CHANGELOG.md index 16eb04a..9f15c76 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ## v1.1.3 -- The app is now hosted on [Glitch](https://glitch.com/). +- Replaced an exception with a 400 status code when the app receives a webhook event with en empty payload. ## v1.1.2 diff --git a/Gemfile b/Gemfile index 20e6688..273a2f2 100644 --- a/Gemfile +++ b/Gemfile @@ -5,6 +5,6 @@ source 'http://rubygems.org' gem 'dotenv' gem 'git' gem 'jwt', '~> 2.1' -gem 'octokit', '~> 4.0' +gem 'octokit', '~> 5.0' gem 'puma' gem 'sinatra', '~> 2.0' diff --git a/Gemfile.lock b/Gemfile.lock index 09ab90d..33ae348 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -17,7 +17,7 @@ GEM net-http (0.4.1) uri nio4r (2.7.0) - octokit (4.25.1) + octokit (5.6.1) faraday (>= 1, < 3) sawyer (~> 0.9) public_suffix (5.0.4) @@ -46,7 +46,7 @@ DEPENDENCIES dotenv git jwt (~> 2.1) - octokit (~> 4.0) + octokit (~> 5.0) puma sinatra (~> 2.0) diff --git a/README.md b/README.md index f8da051..85d6cc4 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ This list will update whenever new changes are pushed, so you always know exactl The app supports a wide array of programming languages and action items. Should you find that your language of choice or action item is not supported, feel free to open an issue. -At the moment, the app is hosted on [Glitch](https://glitch.com/), but it is also set up and configured to be built automatically using Google Cloud Build and hosted through Google Cloud Run. +Whenever a new version is released, the app is automatically built and deployed using Google Cloud Build, and subsequently hosted through Google Cloud Run. ## In-Depth @@ -31,7 +31,7 @@ Whenever new changes are pushed to the Pull Request, the app will update the com You can configure the check to block Pull Requests until all action items are resolved by creating a branch protection rule in your repository settings. -Tech stack: The app is built using Ruby and automatically deployed to Google Cloud Run using Google Cloud Build when a new release is created (*automated deployment has been temporarily paused while the app is hosten on Glitch*). +Tech stack: The app is built using Ruby and automatically deployed to Google Cloud Run using Google Cloud Build when a new release is created. ## Development diff --git a/app.rb b/app.rb index 4a3a85b..70c402b 100644 --- a/app.rb +++ b/app.rb @@ -16,7 +16,7 @@ puts "Running Todo PR Checker version: #{VERSION}" set :bind, '0.0.0.0' -set :port, '3000' +set :port, ENV['PORT'] || '3000' GITHUB_PRIVATE_KEY = OpenSSL::PKey::RSA.new(ENV.fetch('GITHUB_PRIVATE_KEY', nil).gsub('\n', "\n")) GITHUB_WEBHOOK_SECRET = ENV.fetch('GITHUB_WEBHOOK_SECRET', nil) @@ -143,13 +143,13 @@ def get_pull_request_changes(full_repo_name, pull_number) diff.each_line do |line| # This is the most common case, indicating a line was added to the file if line.start_with?('+') && !line.start_with?('+++') - changes[current_file] << { line: line_number, text: line[1..-1] } + changes[current_file] << { line: line_number, text: line[1..] } # Lines that start with @@ contain the the starting line and its length for a new block of changes, for the old and new file respectively elsif line.start_with?('@@') line_number = line.split()[2].split(',')[0].to_i - 1 # Lines that start with +++ contain the new name of the file, which is the one we want to link to in the comment elsif line.start_with?('+++') - current_file = line[6..-1].strip + current_file = line[6..].strip changes[current_file] = [] end @@ -273,7 +273,8 @@ def get_payload_request(request) begin @payload = JSON.parse @payload_raw rescue JSON::ParserError => e - raise "Invalid JSON (#{e}): #{@payload_raw}" + logger.debug "Invalid JSON (#{e}): #{@payload_raw}" + halt 400 end end diff --git a/glitch.json b/glitch.json deleted file mode 100644 index 426b047..0000000 --- a/glitch.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "install": "bundle install --path ./.data/bundler", - "start": "bundle exec ruby app.rb", - "watch": { - "install": { - "include": [ - "^Gemfile$" - ] - }, - "restart": { - "include": [ - "\\.rb$" - ] - } - } -} \ No newline at end of file