Order commits in sample hook data from oldest to newest

What does this MR do and why?

Order commits in sample hook data from oldest to newest

Commits in the sample push hook were ordered from newest to oldest. This is inconsistent with the actual behaviour of the push hook.

This MR brings the sample data into alignment with the actual hook payload.

Changelog: fixed

References

https://gitlab.com/gitlab-com/request-for-help/-/issues/3184

How to set up and validate locally

  1. Create a blank project and enable the Buildkite integration with push events enabled.
  2. Apply the following patch in order to view your payloads locally:
patch
diff --git a/app/models/integrations/buildkite.rb b/app/models/integrations/buildkite.rb
index b737d7b909b4..02d7dab22c0d 100644
--- a/app/models/integrations/buildkite.rb
+++ b/app/models/integrations/buildkite.rb
@@ -9,7 +9,7 @@ class Buildkite < Integration
     include ReactivelyCached
     include HasAvatar
 
-    ENDPOINT = "https://buildkite.com"
+    ENDPOINT = "http://127.0.0.1:31337"
 
     field :project_url,
       title: -> { _('Pipeline URL') },
@@ -132,18 +132,7 @@ def token_parts
     end
 
     def buildkite_endpoint(subdomain = nil)
-      if subdomain.present?
-        uri = Addressable::URI.parse(ENDPOINT)
-        new_endpoint = "#{uri.scheme || 'http'}://#{subdomain}.#{uri.host}"
-
-        if uri.port.present?
-          "#{new_endpoint}:#{uri.port}"
-        else
-          new_endpoint
-        end
-      else
-        ENDPOINT
-      end
+      ENDPOINT
     end
 
     def request_options
  1. Spin up the following little Ruby server to echo HTTP request bodies:
server
#!/usr/bin/env ruby

require 'webrick'
require 'json'

# Create the server
server = WEBrick::HTTPServer.new(
  Port: 31337,
  DocumentRoot: Dir.pwd
)

# Handle POST requests
server.mount_proc '/' do |req, res|
  if req.request_method == 'POST'
    puts "=" * 50
    puts "POST Request received at #{Time.now}"
    puts "=" * 50
    
    # Print headers
    puts "\nHeaders:"
    puts "-" * 20
    req.header.each do |key, value|
      puts "#{key}: #{value.join(', ')}"
    end
    
    # Print body
    puts "\nBody:"
    puts "-" * 20
    if req.body && !req.body.empty?
      puts JSON.pretty_generate(JSON.parse(req.body))
    else
      puts "(empty body)"
    end
    
    puts "\n" + "=" * 50
    
    # Send response
    res.status = 200
    res['Content-Type'] = 'text/plain'
    res.body = "POST request received and logged\n"
  else
    # Handle non-POST requests
    res.status = 405
    res['Content-Type'] = 'text/plain'
    res.body = "Only POST requests are accepted\n"
  end
end

# Handle shutdown gracefully
trap('INT') do
  puts "\nShutting down server..."
  server.shutdown
end

puts "Starting Ruby HTTP server on port 31337..."
puts "Send POST requests to http://localhost:31337"
puts "Press Ctrl+C to stop the server"

# Start the server
server.start
  1. Create two commits, older and newer and push them together. Observe the order of commits in echoed payload data.
  2. Press the "test settings" button on your BuildKite integration. Ensure the order matches.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by James Nutt

Merge request reports

Loading