Git Product home page Git Product logo

Comments (8)

mattyr avatar mattyr commented on June 12, 2024 1

@simi I just ran again, and there was just one issue detected: git_pre_commit_debugger_points_checker: 1.0, 1.1, 1.2, 1.3, 1.4.

For posterity (and/or a second set of eyes), a slightly improved script below. complete with silly pacman-like progress indicator:

require 'open-uri'
require 'zlib'
require 'progressbar'
require 'digest/md5'

$stdout.sync = true

# trap ctrl-c
trap('INT') do
  puts 'Exiting...'
  exit(1)
end

# make cache dir
Dir.mkdir('cache') unless Dir.exist?('cache')
# make output dir
Dir.mkdir('output') unless Dir.exist?('output')

def get_raw_specs
  # download full index from index.rubygem.org, and cache it to a file
  unless File.exist?('./cache/specs.4.8.gz')
    # write the index to a file
    File.open('./cache/specs.4.8.gz', 'wb') do |fo|
      fo.write URI.open('https://index.rubygems.org/specs.4.8.gz').read
    end
  end
  Marshal.load(Zlib::GzipReader.open('./cache/specs.4.8.gz').read)
end

def specs
  @specs ||= get_raw_specs.group_by { |name, _, _| name }
end

def cache_file_name(gem_name)
  "./cache/#{gem_name}-#{Digest::MD5.hexdigest(gem_name)}.info"
end

def get_raw_gem_info(name, force = false)
  fname = cache_file_name(name)
  # check if the gem info is cached
  if File.exist?(fname) && !force
    # read the cached gem info
    return File.open(fname, 'rb').read
  end


  # download the gem info from rubygems.org
  gem_info = URI.open("https://index.rubygems.org/info/#{name}").read
  # cache the gem info to a file
  File.open(fname, 'wb') do |fo|
    fo.write gem_info
  end
  gem_info
end

def check_for_missing_versions(gem_name)
  # get the list of versions from the index
  spec_versions = specs[gem_name].map do |_, version, platform|
    platform == 'ruby' ? version.to_s : "#{version.to_s}-#{platform}"
  end
  # get the list of versions from the gem info
  gem_info = get_raw_gem_info(gem_name)
  gem_info_versions = gem_info.split("\n")[1..].map{|row| row.split(" ")[0]}
  # check if the versions in the index are in the gem info
  spec_versions - gem_info_versions
end

def sillyize
  @silly = Thread.new do
    idx = 0
    chars = ["\u{15E1}","\u{15E7}","\u{2D54}"]
    while true
      @progress.format("%a %b#{chars[idx]}%i %p%% %t %R/sec")
      idx = (idx + 1) % 3
      sleep 0.1
    end
  end
end

def check_chunk(chunk, index)
  File.open("./output/missing_versions_#{index}.txt", 'w') do |fo|
    chunk.each do |name|
      begin
        missing_versions = check_for_missing_versions(name)
        unless missing_versions.empty?
          @progress.log "❌ #{name}: #{missing_versions.join(', ')}"
          fo.puts "#{name}: #{missing_versions.join(', ')}"
        end
        @progress.increment
      rescue => e
        puts "ERROR: #{e}"
        # abort the whole deal
        exit(1)
      end
    end
  end
end

def cache_chunk(chunk)
  chunk.each do |name|
    unless File.exist?(cache_file_name(name))
      get_raw_gem_info(name)
    end
    @progress.increment
  end
end

def cache_all
  @progress = ProgressBar.create(
    title: 'Caching',
    total: specs.keys.length,
    format: "%a %b\u{15E7}%i %p%% %t %R/sec",
    progress_mark: ' ',
    remainder_mark: "\u{FF65}",
    throttle_rate: 0.25
  )

  sillyize

  threads = []

  # split the keys into chunks of 1000
  specs.keys.each_slice(2500) do |chunk|
    threads << Thread.new { cache_chunk(chunk) }
  end
  threads.each(&:join)

  @silly.kill if @silly
  @silly = nil

  puts "done caching"
end

def check_all
  @progress = ProgressBar.create(
    title: 'Checking',
    total: specs.keys.length,
    format: "%a %b\u{15E7}%i %p%% %t %R/sec",
    progress_mark: ' ',
    remainder_mark: "\u{FF65}",
    throttle_rate: 0.25
  )

  sillyize

  idx = 0
  threads = []
  ops = []
  # split the keys into chunks of 1000
  specs.keys.each_slice(10000) do |chunk|
    ops << [chunk, idx]
    idx += 1
  end
  ops.each do |chunk, index|
    threads << Thread.new { check_chunk(chunk, index) }
  end
  threads.each(&:join)

  @silly.kill if @silly
  @silly = nil

  # concatentate the output files
  File.open('./output/missing_versions.txt', 'w') do |fo|
    Dir.glob('./output/missing_versions_*.txt').each do |file|
      fo.puts File.open(file, 'rb').read
    end
  end
end

cache_all
check_all

from rubygems.org.

mattyr avatar mattyr commented on June 12, 2024 1

Ah cool thanks for the bundler/inline tip...nice.

So it might have been a timing or cache issue, when I ran the script, this was what was cached from https://index.rubygems.org/info/git_pre_commit_debugger_points_checker:

---
0.1.0 git:~> 1.5|checksum:f350b30d8782a935c0b09a70c8fad971eb63478995f843a88a2797d6bde315c0
0.2.0 git:~> 1.5|checksum:ebd9e221f2931958b0948a4e8542b818eb393ba7eaf9b83032d882626343b5c8
0.3.0 git:~> 1.5|checksum:6d7eceed164444031b36f691bb5cdf2534debb68e128041745f9ba4b1d82c14c
0.4.0 git:~> 1.5|checksum:f20e3d29740a03962dab46d1db31c2f2aff5a0378e5c121c54bbe46e0b7fa75d
0.5.0 git:~> 1.5|checksum:9eb3c0d4a4de416b9f5e093e706dadcacd08b7ff8797b63b9d6b1f0d1d78ed52
1.5 git:~> 1.5|checksum:6d635ab9bd394b29990ece2352fe6b79ff3eb436a0e4a8083f2314949e42e3e7
1.6 git:~> 1.5|checksum:d4a456b5ca1dbe27178d8f252c75d8e48c64ba1e9414782903d43dc34a4d86d0
1.7 git:~> 1.5|checksum:26afb1a54591fdf8e91c9b6d544ecb78c50adaa66146141e8b802198b3bf04ad
1.8 git:~> 1.5|checksum:e20d47e6d69a6fa850f7fb100f3e121313201998614852c54602fb971ef556b7

However, when I manually checked just now, it does have only the content you shared above (so it appears this instance was fixed as well). Perhaps just a one-off issue (1 odd result out of ~177k feels like pretty good ratio).

from rubygems.org.

simi avatar simi commented on June 12, 2024

Thanks for the list @mattyr. We have been working on back-filling all missing info. I have ensured all gems from your list are backfilled. Can you check now? The original problem should be fixed by #4231.

from rubygems.org.

mattyr avatar mattyr commented on June 12, 2024

it does seem like the missing info is getting filled in - a run-through just now showed a few missing, but spot-checking it looks like as time is passing more are being fixed. i'll give it another run in an hour or so to confirm! thanks.

from rubygems.org.

mattyr avatar mattyr commented on June 12, 2024

Just re-ran the test, and all seems good! Thanks again.

from rubygems.org.

simi avatar simi commented on June 12, 2024

Thanks for check @mattyr. I'll try to check in few days to ensure all is good now after fix being deployed.

from rubygems.org.

simi avatar simi commented on June 12, 2024

@mattyr would you mind to check again using your script for the drift?

from rubygems.org.

simi avatar simi commented on June 12, 2024

Thanks a lot @mattyr. I love the silly pacman progress-bar. Btw. you can use bundler/inline (https://bundler.io/guides/bundler_in_a_single_file_ruby_script.html) to make the script download deps on its own.

https://rubygems.org/gems/git_pre_commit_debugger_points_checker/versions and https://rubygems.org/info/git_pre_commit_debugger_points_checker

---
1.8 git:~> 1.5|checksum:e20d47e6d69a6fa850f7fb100f3e121313201998614852c54602fb971ef556b7

🤔 What's expected in there? All other versions seems yanked (at least currently).

from rubygems.org.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.