class Gitlab::QA::Scenario::Test::Sanity::Version

the commits in the time window will fit.
so ‘COMMITS` needs to be a large enough value that we expect all
the window defined by `HOURS_AGO`. We perform a single API call,
This test checks that the sha_version of a GitLab was authored in

def perform(release)

def perform(release)
  version = Component::Gitlab.perform do |gitlab|
    gitlab.release = release
    gitlab.act do
      pull
      sha_version
    end
  end
  project = "gitlab-org/#{QA::Release.new(release).api_project_name}"
  commit = recent_commits(project).find { |c| c['id'] == version }
  if commit
    puts "Found commit #{version} in recent history of #{project}"
  else
    puts "Did not find #{version} in recent history of #{project}"
    exit 1
  end
end

def recent_commits(project)

def recent_commits(project)
  api = 'https://gitlab.com/api/v4'
  url = "#{api}/projects/#{CGI.escape(project)}/repository/commits"
  since = (Time.now - HOURS_AGO * 60 * 60).strftime('%FT%T')
  uri = URI(url)
  uri.query = URI.encode_www_form(since: since, per_page: COMMITS)
  JSON.parse(Net::HTTP.get(uri))
end