Skip to content

Updates `latest` to be the latest semantic release

Laura Montemayor requested to merge latest-and-specs into master

What does this MR do and why?

Updates latest to be the latest semantic release. Also renames ( latest_for_catalog_resources -> versions_for_catalog_resources) and simplifies / updates to use the semantic version sorting.

  • Removes sorting functionality for versions since there is currently no need
  • Removes finder in lieu for simpler resolver
  • Removes unused scopes from the model
  • Removes latest_version from ResourceType in favor of simpler + faster implementation
  • Refactors some specs to make them comply with semantic versioning

Issue: #442238 (closed)

How to set this up

Since this is mostly about making sure that the `latest` version is the latest semantic version, the best way to test this is the following:

In a project that is marked as a catalog resource, create three releases in the following order: 10.0.0 -> 3.1.1 -> 2.1.6. Previously, this would've shown up in the order they were created, so 2.1.6 would be "latest" because it was using released_at. Now the order of versions should be semantic. Example query:

query  {
  ciCatalogResource(id: "gid://gitlab/Ci::Catalog::Resource/15") {
    versions {
      edges {
        node {
          id
          releasedAt
        }
      }
    }
  }
}

Response shows the latest at the top, even though 2.1.6 was created today. The rest of the versions are in the correct order (this will be what is used for the FE versions dropdown):

{
  "data": {
    "ciCatalogResource": {
      "versions": {
        "edges": [
          {
            "node": {
              "name": "10.0.0",
              "createdAt": "2024-02-26T12:01:56Z"
            }
          },
          {
            "node": {
              "name": "3.1.1",
              "createdAt": "2024-02-14T10:40:37Z"
            }
          },
          {
            "node": {
              "name": "2.1.6",
              "createdAt": "2024-02-28T14:28:26Z"
            }
          }
        ]
      }
    }
  }
}

You can also test this by include ing the latest component.

NOTE: I know this appears like a large MR, but numbers can be deceiving. Changes are as follows:

  • DELETION: 6 are complete file deletions (finder / finder spec / shared context / sort enum / sort enum spec / graphl doc)
  • FORMAT: 2 are formatting changes (added a space / removed a comment) 😬 sorry
  • DELETION: 1 backend removal of a type
  • SPECS: 7 files are backend specs that needed to get updated to use the semantic version
  • CHANGE: VersionsResolver: removes sort and adds batchloader to query versions per catalog resources
  • CHANGE: VersionModel: update latest and update latest_for_catalog_resources -> renamed to versions_for_catalog_resources

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Laura Montemayor

Merge request reports