This repository was archived by the owner on Jul 16, 2026. It is now read-only.
Make build_package job idempotent - #113
Merged
Merged
Conversation
Add a check-source subcommand to launchpad_copy.py that queries Launchpad for an existing source package, returning 0 if found and 1 if missing. Use it in the build_package workflow job to skip the build+upload when the package already exists in the PPA. Also replace the ubuntu-distro-info subprocess call in get_supported_series with a Launchpad API query on distribution.series, removing the distro-info apt dependency which is unavailable on newer Ubuntu runners. Simplify workflow conditions left over from the dry-run refactor. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove TestGetSupportedSeries, TestCopyToSeries, and TestMainDispatch — these mocked every dependency and only tested that mocks were called in order, not actual behavior. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
rtibbles
force-pushed
the
idempotent-build-package
branch
from
March 4, 2026 01:55
156e82d to
bc481b4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
build_packageworkflow job runsmake sign-and-upload, which callsdputto upload to Launchpad. On rerun,dputre-uploads and Launchpad silently rejects the duplicate (async rejection via email —dputexits 0). This made the step appear to succeed but do nothing useful, and was the only non-idempotent step in the pipeline.This PR adds a
check-sourcesubcommand tolaunchpad_copy.pythat queries the Launchpad API for an existing source package version. Thebuild_packagejob now calls it before building, and skips GPG import + upload when the package already exists.Also replaces the
ubuntu-distro-infosubprocess call inget_supported_serieswith a direct Launchpad API query ondistribution.series. Theubuntu-distro-infosystem package is not available on Ubuntu Noble runners, which was breaking thecopy_to_other_distributionsjob.Verified locally:
check-source --version 0.5.0-0ubuntu1→ exit 0 ("already exists, status: Published")check-source --version 0.5.0-0ubuntu2→ exit 1 ("not found")get_supported_seriesreturns correct series list via APIReferences
Fixes CI failure in
copy_to_other_distributions: https://github.com/learningequality/kolibri-server/actions/runs/22647146299/job/65637846793Reviewer guidance
scripts/launchpad_copy.py:316-332—check_sourcemethod uses the same filtering pattern aswait_for_builds(line 344). Worth verifying the status filter is correct for the idempotency check.scripts/launchpad_copy.py:63-73—get_supported_seriesnow queries the Launchpad API. The filter isactive=Trueandstatus in ("Supported", "Current Stable Release"), which excludes "Active Development" (unreleased) and "Obsolete" series..github/workflows/build_debian.yml:55-66— thecheck-sourcestep: exit 0 means "already uploaded" → skip build. This is intentionally inverted from typical shell convention because the Launchpad query succeeding (found) means we should skip.AI usage
Used Claude Code throughout — prompted to implement the plan, then iterated on the
ubuntu-distro-infofix and test cleanup based on review discussion. Reviewed all generated code and verified against the real Launchpad API.