Page MenuHomePhabricator

[cicd] Streamline toolforge cli deployment and external contributor ci flows
Open, MediumPublic

Description

Quoted Text

The Problems:

1. CLIs deployment problem:

There is currently no way in the deploy cookbook to deploy a cli package (usually done using a cli repo release branch), and execute new/modified functional tests from a new toolforge-deploy branch, unless you give the release branch on the cli repo, and the new/modified functional tests branch on toolforge-deploy the same name (This is not exactly realistic).

This is because the cli is deployed from the release branch on the cli repo,
while the functional tests that are run after each deployment lives in the toolforge-deploy repo (This is likely structured like this because the cli deb package is gotten from the release patch on the cli repo and uploaded to our internal deb repositories, during the cookbook run).

This is also applicable (in a way) to the APIs deployment using the deploy cookbook. The difference is that since the APIs release branch and the functional tests are in the same repo, you can checkout the release branch (created by the cicd pipeline) locally, add your new/modified tests, then update the release branch with this new change.

2. Problem running the gitlab tests and deployment cicd pipelines for PRs from external contributors

more context: https://gitlab.wikimedia.org/repos/cloud/toolforge/builds-builder/-/merge_requests/70#note_136315
TL;DR is that deployment pipelines doesn't work for PRs from non-maintainers.

...(Add more problems here)...

Outline of the current deployment flow for the API:

For APIs, the flow goes like this: (Please indicate if I missed something)

  • submit a PR, and the cicd pipeline builds the dev container image and helm chart and upload them to toolsbeta harbor, these will be used for testing this PR on lima-kilo.
  • once the PR has been tested, approved and merged, cicd pipeline does the following:
    • builds the toolsbeta and tools container image and helm chart and upload these to toolsbeta and tools respectively.
    • creates a gitlab release by tagging the merged git commit
    • creates a toolforge-deploy upgrade branch. This branch will be used to deploy the api on toolsbeta and tools k8s clusters using the deploy cookbook, and the deployment logs and functional tests will be logged in this PR. This PR will be merged after the deployments has been confirmed as successful.

Outline for the current deployment flow for the Clis:

For the CLIs, the flow goes like this: (Please indicate if I missed something)

  • submit a PR, and the cicd pipeline builds the .deb package, zips it, and saves it as a build archive on gitlab. This zip file is downloaded, unzipped and installed in lima-kilo by toolforge_deploy_mr.py script for local testing. (This script currently lives in lima-kilo repo, but should probably be moved to toolforge-deploy repo. Making a mental note of that so I don't forget).
  • once the PR has been tested, approved and merged, the cicd pipeline builds another .deb package, zips and saves it in gitlab as a build artifact.
  • After merging you manually do the follow:
    • fetch the merge locally and checkout a bump_version branch where you run the ./utils/bump_version.sh script on your local machine. This script currently exists on all our clis and is responsible for creating release branch and tag. Then you manually upload this release branch and tag.
    • After creating the release branch on the cli repo, the cicd pipeline builds the package, but this time uploads it to pypi.
    • Next step is to run deploy cookbook this install this package on the bastions and runs the functional tests, but unlike the APIs, the installation and functional tests logs are logged to the cli release PR, not toolforge-deploy (since the release PR is created on the cli repo and not toolforge deploy). Once the installation and functional tests has been confirmed as successful, we merge the cli release PR, then manually create a gitlab release for this. (You can already see that the deployment flow for the clis is more hairy than that of the APIs)

Proposed Fixes:

This will probably be in multiple stages:

  • replace --git-branch option in the deploy cookbook with --deploy-branch and --test-branch. This will allow us to independently choose the deployment branch, and the test branch, and will fix the current issue. If --test-branch is not provided, it can default to the value of --deploy-branch.
  • Simplify the deployment flow for the CLIs (maybe become more like the flow for the APIs) (more on this later...)
  • Work on deploying patches created by non-maintainers, taking care that secrets are handled properly and doesn't leak (more on this later...)

...

Event Timeline

Raymond_Ndibe renamed this task from Better toolforge cli deployment flow to DRAFT: Fix toolforge tests and deployment cicd pipelines.Apr 23 2025, 6:03 PM
Raymond_Ndibe added a project: Epic.
Raymond_Ndibe renamed this task from DRAFT: Fix toolforge tests and deployment cicd pipelines to Fix toolforge tests and deployment cicd pipelines.Apr 24 2025, 10:06 AM
Raymond_Ndibe updated the task description. (Show Details)

We might want to split this task in two, one for the voulteer/non-admin MRs testing, and one for the cli pipeline.

For the volunteer flow, we had a quick chat, and we came up with something like:

Have two pipelines for MRs:

  • test one to run pre-commit/tox
    • triggreed by MR
  • build image one to build the image and push to toolsbeta
    • Triggered only by token, this means:
      • Creating a new project in toolsbeta harbor, with strict policies (both amount of images, retention and size quota)
      • Creating a bot with access to it, for which the credentials will be public (or almost)

By default, when an MR is created:

  • Runs test

When toolforge_deploy_mr.py runs in lima-kilo:

  • it checks if there's a build image pipeline run for the latest commit
    • if it's there, get the image from there
    • if not, trigger the build image pipeline, wait and use that image
dcaro renamed this task from Fix toolforge tests and deployment cicd pipelines to [cicd] Streamline toolforge cli deployment and external contributor ci flows.May 7 2025, 5:09 PM
dcaro triaged this task as Medium priority.
Raymond_Ndibe removed Raymond_Ndibe as the assignee of this task.
Raymond_Ndibe claimed this task.
Raymond_Ndibe updated the task description. (Show Details)
Raymond_Ndibe changed the task status from Open to In Progress.May 18 2025, 8:57 PM
fnegri changed the task status from In Progress to Open.Jan 13 2026, 5:03 PM