Package: toolforge-cli
toolforge-cliCLI to run toolforge related commandsLocal development environment (guideline)RequirementsYou need to havePoetryinstalled globally. While you can install it with package managers such aspiporhomebrew, it's highly recommended to use the official installer:https://python-poetry.org/docs/#installing-with-the-official-installerTesting with tox on debianClone the repo (instructions herehttps://gitlab.wikimedia.org/repos/cloud/toolforge/toolforge-cli).Install tox (this is the only debian-specific part):~:$ apt install toxMove to the directory where you cloned the repo, and run tox:/path/to/repo/toolforge-cli:$ toxThat will run the tests and create a virtualenv that you can use to manually debug anything you need, to enter it:/path/to/repo/toolforge-cli:$ source .tox/py3-tests/bin/activateBuilding the debian packagesThe process will be:Create new branchBump the versionUpdate thedebian/changelogandpyproject.toml(done bybump_version.sh)Create a patch, get it reviewed and mergedCreate a tag (debian/<new_version>) and pushBuild the package (done bybuild_deb.sh)Upload the package to the toolforge repositoriesLet's get started!Create new branchTo get started, create a new branch from main:~:$ git checkout -b <new-branch-name>Update the changelog and pyproject.tomlTo do so, you can run the script:~:$ utils/bump_version.shThat will:create an entry indebian/changelogfrom the git log since the lastdebian/*tagbump the version inpyproject.tomltooAt this point, you should create a commit and send it for review, and continue once merged.~:$  git commit -m "Bumped version to <new_version>" --signoff
~:$  git push origin <new-branch-name>Get the version bump commit mergedReview thechangelogand thepyproject.tomlchanges to make sure it's what you want (it uses your name, email, etc.), and ask
for reviews.Create and upload the debian tagOnce merged, you can create a tag nameddebian/<new_version>locally and push it to the repository (ex.git push origin debian/<new_version>).Build the packageWith containersThis is the recommended way of building the package, as it's agnostic of the OS/distro you are using.It will not allow you to sign your package though, so if you need that try using the manual process.Now you can build the package with:~:$ utils/build_deb.shThe first time it might take a bit more time as it will build the core image to build packages, downloading many
dependencies. The next run it will not need to download all those dependencies, so it will be way faster.NOTE: If it failed when installing packages, try passing--no-cacheto force rebuilding the cached layers.wmcs-package-build scriptAn alternative is using the wmcs-package-build.py script that you can find in
the operations/puppet repo at modules/toolforge/files$ ./wmcs-package-build.py --git-repo https://gitlab.wikimedia.org/repos/cloud/toolforge/toolforge-cli -a buster-toolsbeta -a bullseye-toolsbeta --git-branch main --build-dist=bullseyeThe script will SSH into a build server, build the package there, and publish it
to two repos:buster-toolsbetaandbullseye-tooslbeta.The additional params--backports, --toolforge-repo=tools --build-dist=bullseyeare necessary because the build requires Poetry and other
build tools not available in the buster repos.If that command is successful, you should then copy the package from the
"toolsbeta" to the "tools" distribution:ssh tools-services-05.tools.eqiad1.wikimedia.cloud
$ sudo -i
# aptly repo copy buster-toolsbeta buster-tools toolforge-cli_VERSION_all
# aptly repo copy bullseye-toolsbeta bullseye-tools toolforge-cli_VERSION_all
# aptly publish --skip-signing update buster-tools
# aptly publish --skip-signing update bullseye-toolsAdditional documentation on the wmcs-package-build script is available athttps://wikitech.wikimedia.org/wiki/Portal:Toolforge/Admin/Packaging#wmcs-package-buildManual process (only on debian)For this you'll need debuild installed:~:$ sudo apt install debuildInstall the build dependencies, this requires devscripts and equivs:~:$ sudo apt install devscripts equivs
...
/path/to/repo/toolforge-cli:$ sudo mk-build-deps --install debian/controlOr just manually check thedebian/controlfileBuild-Dependenciesand install them manually.Note that it will build a debian package right there, and install it, you can remove it to clean up the dependencies any time.Now for the actuall build:/path/to/repo/toolforge-cli:$ debuild -uc -usThat will end up creating an unsigned package under../toolforge-cli.*.deb.
If you want to sign it, you will have to do something like:/path/to/repo/toolforge-cli:$ debuild -kmy@key.orgUploading to the toolforge repositoryOnce you have built the package you want, you can uploade it following:https://wikitech.wikimedia.org/wiki/Portal:Toolforge/Admin/Packaging#Uploading_a_package