Skip to content

Add Metadata::CompareService and Metadata::Comparison classes

Reuben Pereira requested to merge rp/diff-notification1 into master

What does this MR do?

These classes will be used to generate (and then display in Slack) diff information of each component.

These classes will be used like the following example:

compare_service = Metadata::CompareService.new(
  source: ProductVersion.from_auto_deploy(deploy_version),
  environment: environment
)
comparison = compare_service.with_latest_successful_deployment

comparison.map_components do |project_compare, source_sha, target_sha, project|
  "#{project.metadata_name} - <#{project_compare.web_url}|#{source_sha}...#{target_sha}>"
end

How?

To find the previous version deployed to the given environment, we search the deployments recorded in the https://ops.gitlab.net/gitlab-org/release/metadata project.

  1. Use ProductVersion#metadata_commit_id to get the commit SHA of the given version (source version).
  2. Call the deployments API to get the latest successful deployment to that environment. Since we plan to use this during the gstg started notifications (for all envs), the previous deployment is the latest successful deployment.
  3. Get the previous version string by calling the commit diffs API (the filename contains the version string).
  4. Create a Comparison object with the source version and previous version.

gitlab-com/gl-infra/delivery#2165 (closed)

Author Check-list

  • Has documentation been updated?
Edited by Reuben Pereira

Merge request reports