selective-ruby-core 0.1.7-x86_64-linux → 0.1.9-x86_64-linux
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/lib/bin/build_env.sh +2 -0
 - data/lib/selective/ruby/core/controller.rb +33 -14
 - data/lib/selective/ruby/core/version.rb +1 -1
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: b3c47e84c3fe990beb707bfecd730347e6c421fed599079a6c0b840410fafab8
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 9f8f05903a3755eeeb15651ba0fe9c74b14b727d24c81ba5e8636b8b04a889fa
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: f29321c5faf4f51bebaeeca0844b2ccbb370b29a03039e6cb15f084b4d46f0e48d67491b8ca37fba44bc79519025aabf15c3b4074d0df38a55048a8cb0d685c7
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: ba2304b3d33f43b1b33826bf6c3278d5cb24244171b6122f2b37dbfbc910ca7f059e569105b96973d6580540fb29cb63116dd2df9f38d3d9773100a6df0f4cf7
         
     | 
    
        data/lib/bin/build_env.sh
    CHANGED
    
    
| 
         @@ -9,6 +9,14 @@ module Selective 
     | 
|
| 
       9 
9 
     | 
    
         
             
                    include Helper
         
     | 
| 
       10 
10 
     | 
    
         
             
                    @@selective_suppress_reporting = false
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
      
 12 
     | 
    
         
            +
                    REQUIRED_CONFIGURATION = {
         
     | 
| 
      
 13 
     | 
    
         
            +
                      "host" => "SELECTIVE_HOST",
         
     | 
| 
      
 14 
     | 
    
         
            +
                      "api_key" => "SELECTIVE_API_KEY",
         
     | 
| 
      
 15 
     | 
    
         
            +
                      "platform" => "SELECTIVE_PLATFORM",
         
     | 
| 
      
 16 
     | 
    
         
            +
                      "run_id" => "SELECTIVE_RUN_ID",
         
     | 
| 
      
 17 
     | 
    
         
            +
                      "branch" => "SELECTIVE_BRANCH"
         
     | 
| 
      
 18 
     | 
    
         
            +
                    }.freeze
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
       12 
20 
     | 
    
         
             
                    def initialize(runner, debug: false, log: false)
         
     | 
| 
       13 
21 
     | 
    
         
             
                      @debug = debug
         
     | 
| 
       14 
22 
     | 
    
         
             
                      @runner = runner
         
     | 
| 
         @@ -101,12 +109,8 @@ module Selective 
     | 
|
| 
       101 
109 
     | 
    
         | 
| 
       102 
110 
     | 
    
         
             
                    def transport_url(reconnect: false)
         
     | 
| 
       103 
111 
     | 
    
         
             
                      @transport_url ||= begin
         
     | 
| 
       104 
     | 
    
         
            -
                        api_key =  
     | 
| 
       105 
     | 
    
         
            -
                        host =  
     | 
| 
       106 
     | 
    
         
            -
             
     | 
| 
       107 
     | 
    
         
            -
                        # Validate that host is a valid websocket url(starts with ws:// or wss://)
         
     | 
| 
       108 
     | 
    
         
            -
                        raise "Invalid host: #{host}" unless host.match?(/^wss?:\/\//)
         
     | 
| 
       109 
     | 
    
         
            -
             
     | 
| 
      
 112 
     | 
    
         
            +
                        api_key = build_env.delete("api_key")
         
     | 
| 
      
 113 
     | 
    
         
            +
                        host = build_env.delete("host")
         
     | 
| 
       110 
114 
     | 
    
         
             
                        run_id = build_env.delete("run_id")
         
     | 
| 
       111 
115 
     | 
    
         
             
                        run_attempt = build_env.delete("run_attempt")
         
     | 
| 
       112 
116 
     | 
    
         
             
                        run_attempt = SecureRandom.uuid if run_attempt.nil? || run_attempt.empty?
         
     | 
| 
         @@ -134,7 +138,20 @@ module Selective 
     | 
|
| 
       134 
138 
     | 
    
         
             
                    def build_env
         
     | 
| 
       135 
139 
     | 
    
         
             
                      @build_env ||= begin
         
     | 
| 
       136 
140 
     | 
    
         
             
                        result = `#{File.join(ROOT_GEM_PATH, "lib", "bin", "build_env.sh")}`
         
     | 
| 
       137 
     | 
    
         
            -
                        JSON.parse(result)
         
     | 
| 
      
 141 
     | 
    
         
            +
                        JSON.parse(result).tap do |env|
         
     | 
| 
      
 142 
     | 
    
         
            +
                          validate_build_env(env)
         
     | 
| 
      
 143 
     | 
    
         
            +
                        end
         
     | 
| 
      
 144 
     | 
    
         
            +
                      end
         
     | 
| 
      
 145 
     | 
    
         
            +
                    end
         
     | 
| 
      
 146 
     | 
    
         
            +
             
     | 
| 
      
 147 
     | 
    
         
            +
                    def validate_build_env(env)
         
     | 
| 
      
 148 
     | 
    
         
            +
                      missing = REQUIRED_CONFIGURATION.each_with_object([]) do |(key, env_var), arry|
         
     | 
| 
      
 149 
     | 
    
         
            +
                        arry << env_var if env[key].nil? || env[key].empty?
         
     | 
| 
      
 150 
     | 
    
         
            +
                      end
         
     | 
| 
      
 151 
     | 
    
         
            +
                      
         
     | 
| 
      
 152 
     | 
    
         
            +
                      with_error_handling do
         
     | 
| 
      
 153 
     | 
    
         
            +
                        raise "Missing required environment variables: #{missing.join(", ")}" unless missing.empty?
         
     | 
| 
      
 154 
     | 
    
         
            +
                        raise "Invalid host: #{env['host']}" unless env['host'].match?(/^wss?:\/\//)
         
     | 
| 
       138 
155 
     | 
    
         
             
                      end
         
     | 
| 
       139 
156 
     | 
    
         
             
                    end
         
     | 
| 
       140 
157 
     | 
    
         | 
| 
         @@ -220,9 +237,11 @@ module Selective 
     | 
|
| 
       220 
237 
     | 
    
         
             
                    end
         
     | 
| 
       221 
238 
     | 
    
         | 
| 
       222 
239 
     | 
    
         
             
                    def handle_command(data)
         
     | 
| 
       223 
     | 
    
         
            -
                       
     | 
| 
       224 
     | 
    
         
            -
             
     | 
| 
       225 
     | 
    
         
            -
                       
     | 
| 
      
 240 
     | 
    
         
            +
                      if respond_to? "handle_#{data[:command]}", true
         
     | 
| 
      
 241 
     | 
    
         
            +
                        send("handle_#{data[:command]}", data)
         
     | 
| 
      
 242 
     | 
    
         
            +
                      else
         
     | 
| 
      
 243 
     | 
    
         
            +
                        raise "Unknown command received: #{data[:command]}" if debug?
         
     | 
| 
      
 244 
     | 
    
         
            +
                      end
         
     | 
| 
       226 
245 
     | 
    
         
             
                    end
         
     | 
| 
       227 
246 
     | 
    
         | 
| 
       228 
247 
     | 
    
         
             
                    def handle_print_notice(data)
         
     | 
| 
         @@ -262,7 +281,7 @@ module Selective 
     | 
|
| 
       262 
281 
     | 
    
         
             
                    def handle_close(data)
         
     | 
| 
       263 
282 
     | 
    
         
             
                      exit_status = data[:exit_status]
         
     | 
| 
       264 
283 
     | 
    
         
             
                      self.class.restore_reporting!
         
     | 
| 
       265 
     | 
    
         
            -
                      runner.finish unless exit_status.is_a?(Integer)
         
     | 
| 
      
 284 
     | 
    
         
            +
                      with_error_handling { runner.finish } unless exit_status.is_a?(Integer)
         
     | 
| 
       266 
285 
     | 
    
         | 
| 
       267 
286 
     | 
    
         
             
                      kill_transport
         
     | 
| 
       268 
287 
     | 
    
         
             
                      pipe.delete_pipes
         
     | 
| 
         @@ -291,12 +310,12 @@ module Selective 
     | 
|
| 
       291 
310 
     | 
    
         | 
| 
       292 
311 
     | 
    
         
             
                    def get_diff(num_commits)
         
     | 
| 
       293 
312 
     | 
    
         
             
                      target_branch = build_env["target_branch"]
         
     | 
| 
       294 
     | 
    
         
            -
                      return  
     | 
| 
      
 313 
     | 
    
         
            +
                      return if target_branch.nil? || target_branch.empty?
         
     | 
| 
       295 
314 
     | 
    
         | 
| 
       296 
315 
     | 
    
         
             
                      Open3.capture2e("git fetch origin #{target_branch} --depth=#{num_commits}").then do |output, status|
         
     | 
| 
       297 
316 
     | 
    
         
             
                        unless status.success?
         
     | 
| 
       298 
317 
     | 
    
         
             
                          print_warning "Selective was unable to fetch the target branch. This may result in a sub-optimal test order. If the issue persists, please contact support. The output was:\n\n#{output}"
         
     | 
| 
       299 
     | 
    
         
            -
                          return 
     | 
| 
      
 318 
     | 
    
         
            +
                          return
         
     | 
| 
       300 
319 
     | 
    
         
             
                        end
         
     | 
| 
       301 
320 
     | 
    
         
             
                      end
         
     | 
| 
       302 
321 
     | 
    
         | 
| 
         @@ -305,7 +324,7 @@ module Selective 
     | 
|
| 
       305 
324 
     | 
    
         
             
                          output.split("\n")
         
     | 
| 
       306 
325 
     | 
    
         
             
                        else
         
     | 
| 
       307 
326 
     | 
    
         
             
                          print_warning "Selective was unable to diff with the target branch. This may result in a sub-optimal test order. If the issue persists, please contact support. The output was:\n\n#{output}"
         
     | 
| 
       308 
     | 
    
         
            -
                           
     | 
| 
      
 327 
     | 
    
         
            +
                          nil
         
     | 
| 
       309 
328 
     | 
    
         
             
                        end
         
     | 
| 
       310 
329 
     | 
    
         
             
                      end
         
     | 
| 
       311 
330 
     | 
    
         
             
                    end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: selective-ruby-core
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.9
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: x86_64-linux
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Benjamin Wood
         
     | 
| 
         @@ -9,7 +9,7 @@ authors: 
     | 
|
| 
       9 
9 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       10 
10 
     | 
    
         
             
            bindir: exe
         
     | 
| 
       11 
11 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       12 
     | 
    
         
            -
            date: 2024-01- 
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2024-01-12 00:00:00.000000000 Z
         
     | 
| 
       13 
13 
     | 
    
         
             
            dependencies:
         
     | 
| 
       14 
14 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       15 
15 
     | 
    
         
             
              name: zeitwerk
         
     |