gitlab_quality-test_tooling 2.24.1 → 2.25.0
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/Gemfile.lock +1 -1
- data/exe/test-coverage +10 -20
- data/lib/gitlab_quality/test_tooling/code_coverage/artifacts.rb +20 -41
- data/lib/gitlab_quality/test_tooling/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: 00140ea21de2c5a562b7eaf3af41ee5d304a60d9bf73fb812a7e08fa04170a5e
         | 
| 4 | 
            +
              data.tar.gz: 9e8cdf91f59d43b782872ee3c625e21d0c00381feb260ab95454fd5d3cb920c7
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 2e9561c50c8b365001cce2047d448a403c2f5de4ee3ee35841c4ce2e2d2748ca17c135b0b9e5b22389e9245a0922a6171fb99705016040a4206c139d3a3033f5
         | 
| 7 | 
            +
              data.tar.gz: 88359d86bf0cdb99b48d748570a39fa6fd3a73d9908c352d3bd956f9fea7f6c4b8d880763b2e6bccd10fa439e211bc139ea2f952952b7cef7b2e9107a7c8f31f
         | 
    
        data/Gemfile.lock
    CHANGED
    
    
    
        data/exe/test-coverage
    CHANGED
    
    | @@ -15,29 +15,21 @@ require_relative '../lib/gitlab_quality/test_tooling/code_coverage/rspec_report' | |
| 15 15 | 
             
            require_relative '../lib/gitlab_quality/test_tooling/code_coverage/test_map'
         | 
| 16 16 |  | 
| 17 17 | 
             
            params = {}
         | 
| 18 | 
            -
            required_params = [: | 
| 18 | 
            +
            required_params = [:rspec_reports, :coverage_report, :test_map]
         | 
| 19 19 |  | 
| 20 20 | 
             
            options = OptionParser.new do |opts|
         | 
| 21 21 | 
             
              opts.banner = "Usage: #{$PROGRAM_NAME} [options]"
         | 
| 22 22 |  | 
| 23 | 
            -
              opts.on('-- | 
| 24 | 
            -
                params[: | 
| 23 | 
            +
              opts.on('--rspec-reports GLOB', 'Glob pattern for RSpec JSON reports (e.g., "rspec/rspec-*.json")') do |pattern|
         | 
| 24 | 
            +
                params[:rspec_reports] = pattern
         | 
| 25 25 | 
             
              end
         | 
| 26 26 |  | 
| 27 | 
            -
              opts.on('-- | 
| 28 | 
            -
                params[: | 
| 27 | 
            +
              opts.on('--coverage-report PATH', 'Path to the LCOV coverage report (e.g., "coverage/lcov/gitlab.lcov")') do |path|
         | 
| 28 | 
            +
                params[:coverage_report] = path
         | 
| 29 29 | 
             
              end
         | 
| 30 30 |  | 
| 31 | 
            -
              opts.on('-- | 
| 32 | 
            -
                params[: | 
| 33 | 
            -
              end
         | 
| 34 | 
            -
             | 
| 35 | 
            -
              opts.on('--coverage-report-path PATH', 'Path to LCOV coverage report') do |path|
         | 
| 36 | 
            -
                params[:coverage_report_path] = path
         | 
| 37 | 
            -
              end
         | 
| 38 | 
            -
             | 
| 39 | 
            -
              opts.on('--test-map-url URL', 'URL for the test map') do |url|
         | 
| 40 | 
            -
                params[:test_map_url] = url
         | 
| 31 | 
            +
              opts.on('--test-map PATH', 'Path to the test map file (e.g., "crystalball/packed-mapping.json.gz")') do |path|
         | 
| 32 | 
            +
                params[:test_map] = path
         | 
| 41 33 | 
             
              end
         | 
| 42 34 |  | 
| 43 35 | 
             
              opts.on('-h', '--help', 'Show the usage') do
         | 
| @@ -58,11 +50,9 @@ end | |
| 58 50 |  | 
| 59 51 | 
             
            if params.any? && (required_params - params.keys).none?
         | 
| 60 52 | 
             
              artifacts = GitlabQuality::TestTooling::CodeCoverage::Artifacts.new(
         | 
| 61 | 
            -
                 | 
| 62 | 
            -
                 | 
| 63 | 
            -
                 | 
| 64 | 
            -
                coverage_report_path: params[:coverage_report_path],
         | 
| 65 | 
            -
                test_map_url: params[:test_map_url]
         | 
| 53 | 
            +
                rspec_reports: params[:rspec_reports],
         | 
| 54 | 
            +
                coverage_report: params[:coverage_report],
         | 
| 55 | 
            +
                test_map: params[:test_map]
         | 
| 66 56 | 
             
              )
         | 
| 67 57 |  | 
| 68 58 | 
             
              coverage_report = artifacts.coverage_report
         | 
| @@ -1,27 +1,22 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 3 | 
             
            require 'json'
         | 
| 4 | 
            -
            require 'net/http'
         | 
| 5 4 | 
             
            require 'stringio'
         | 
| 6 | 
            -
            require 'uri'
         | 
| 7 5 | 
             
            require 'zlib'
         | 
| 8 6 |  | 
| 9 | 
            -
            require_relative 'utils'
         | 
| 10 | 
            -
             | 
| 11 7 | 
             
            module GitlabQuality
         | 
| 12 8 | 
             
              module TestTooling
         | 
| 13 9 | 
             
                module CodeCoverage
         | 
| 14 10 | 
             
                  class Artifacts
         | 
| 15 | 
            -
                     | 
| 16 | 
            -
             | 
| 17 | 
            -
                     | 
| 18 | 
            -
             | 
| 19 | 
            -
                     | 
| 20 | 
            -
             | 
| 21 | 
            -
                      @ | 
| 22 | 
            -
                      @ | 
| 23 | 
            -
                      @ | 
| 24 | 
            -
                      @test_map_uri = URI.parse(test_map_url)
         | 
| 11 | 
            +
                    # Loads coverage artifacts from the filesystem
         | 
| 12 | 
            +
                    #
         | 
| 13 | 
            +
                    # @param rspec_reports [String] Glob pattern for RSpec JSON report files (e.g., "rspec/rspec-*.json")
         | 
| 14 | 
            +
                    # @param coverage_report [String] Path to the LCOV coverage report file (e.g., "coverage/lcov/gitlab.lcov")
         | 
| 15 | 
            +
                    # @param test_map [String] Path to the test map file, gzipped or plain JSON (e.g., "crystalball/packed-mapping.json.gz")
         | 
| 16 | 
            +
                    def initialize(rspec_reports:, coverage_report:, test_map:)
         | 
| 17 | 
            +
                      @rspec_reports_glob = rspec_reports
         | 
| 18 | 
            +
                      @coverage_report_path = coverage_report
         | 
| 19 | 
            +
                      @test_map_path = test_map
         | 
| 25 20 | 
             
                    end
         | 
| 26 21 |  | 
| 27 22 | 
             
                    def rspec_reports
         | 
| @@ -37,20 +32,16 @@ module GitlabQuality | |
| 37 32 | 
             
                    end
         | 
| 38 33 |  | 
| 39 34 | 
             
                    def test_map
         | 
| 40 | 
            -
                      @test_map ||=  | 
| 35 | 
            +
                      @test_map ||= fetch_test_map
         | 
| 41 36 | 
             
                    end
         | 
| 42 37 |  | 
| 43 38 | 
             
                    private
         | 
| 44 39 |  | 
| 45 40 | 
             
                    def rspec_reports_paths
         | 
| 46 41 | 
             
                      @rspec_reports_paths ||= begin
         | 
| 47 | 
            -
                        paths = @ | 
| 48 | 
            -
                          Dir.glob(File.join(@working_dir, job_name, @rspec_reports_glob))
         | 
| 49 | 
            -
                        end.compact
         | 
| 42 | 
            +
                        paths = Dir.glob(@rspec_reports_glob)
         | 
| 50 43 |  | 
| 51 | 
            -
                         | 
| 52 | 
            -
                          raise "No RSpec reports found in #{@working_dir}/<job-name>/ for these jobs: #{@rspec_reports_jobs}."
         | 
| 53 | 
            -
                        end
         | 
| 44 | 
            +
                        raise "No RSpec reports found matching pattern: #{@rspec_reports_glob}" if paths.empty?
         | 
| 54 45 |  | 
| 55 46 | 
             
                        paths
         | 
| 56 47 | 
             
                      end
         | 
| @@ -62,30 +53,18 @@ module GitlabQuality | |
| 62 53 | 
             
                      File.read(@coverage_report_path)
         | 
| 63 54 | 
             
                    end
         | 
| 64 55 |  | 
| 65 | 
            -
                    def  | 
| 66 | 
            -
                       | 
| 56 | 
            +
                    def fetch_test_map
         | 
| 57 | 
            +
                      raise "Test map file not found: #{@test_map_path}" unless File.exist?(@test_map_path)
         | 
| 67 58 |  | 
| 68 59 | 
             
                      begin
         | 
| 69 | 
            -
                         | 
| 70 | 
            -
                        response = http_get(@test_map_uri)
         | 
| 71 | 
            -
                        raise "HTTP #{response.code}: #{response.message}" unless response.is_a?(Net::HTTPSuccess)
         | 
| 60 | 
            +
                        content = File.read(@test_map_path)
         | 
| 72 61 |  | 
| 73 | 
            -
                         | 
| 74 | 
            -
             | 
| 75 | 
            -
                        if attempt <= MAX_RETRIES
         | 
| 76 | 
            -
                          sleep_duration = exponential_delay_with_jitter(attempt)
         | 
| 77 | 
            -
                          warn "Attempt #{attempt}/#{MAX_RETRIES} failed: #{e.message}. Retrying in #{sleep_duration.round(2)}s..."
         | 
| 78 | 
            -
                          sleep(sleep_duration)
         | 
| 79 | 
            -
                          retry
         | 
| 80 | 
            -
                        end
         | 
| 81 | 
            -
             | 
| 82 | 
            -
                        raise "Failed to fetch test map from #{@test_map_uri} after #{MAX_RETRIES} attempts: #{e.message}"
         | 
| 83 | 
            -
                      end
         | 
| 84 | 
            -
                    end
         | 
| 62 | 
            +
                        # If it's a gzipped file, decompress it
         | 
| 63 | 
            +
                        content = decompressed_gzip(content) if @test_map_path.end_with?('.gz')
         | 
| 85 64 |  | 
| 86 | 
            -
             | 
| 87 | 
            -
                       | 
| 88 | 
            -
                         | 
| 65 | 
            +
                        JSON.parse(content)
         | 
| 66 | 
            +
                      rescue StandardError => e
         | 
| 67 | 
            +
                        raise "Failed to read test map from #{@test_map_path}: #{e.message}"
         | 
| 89 68 | 
             
                      end
         | 
| 90 69 | 
             
                    end
         | 
| 91 70 |  | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: gitlab_quality-test_tooling
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 2. | 
| 4 | 
            +
              version: 2.25.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - GitLab Quality
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2025-10- | 
| 11 | 
            +
            date: 2025-10-31 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: climate_control
         |