Skip to content
This repository was archived by the owner on Jul 16, 2026. It is now read-only.

Make build_package job idempotent - #113

Merged
rtibbles merged 2 commits into
mainfrom
idempotent-build-package
Mar 4, 2026
Merged

Make build_package job idempotent#113
rtibbles merged 2 commits into
mainfrom
idempotent-build-package

Conversation

@rtibbles

@rtibbles rtibbles commented Mar 4, 2026

Copy link
Copy Markdown
Member

Summary

The build_package workflow job runs make sign-and-upload, which calls dput to upload to Launchpad. On rerun, dput re-uploads and Launchpad silently rejects the duplicate (async rejection via email — dput exits 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-source subcommand to launchpad_copy.py that queries the Launchpad API for an existing source package version. The build_package job now calls it before building, and skips GPG import + upload when the package already exists.

Also replaces the ubuntu-distro-info subprocess call in get_supported_series with a direct Launchpad API query on distribution.series. The ubuntu-distro-info system package is not available on Ubuntu Noble runners, which was breaking the copy_to_other_distributions job.

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_series returns correct series list via API
  • 46 tests pass, actionlint passes

References

Fixes CI failure in copy_to_other_distributions: https://github.com/learningequality/kolibri-server/actions/runs/22647146299/job/65637846793

Reviewer guidance

  • scripts/launchpad_copy.py:316-332check_source method uses the same filtering pattern as wait_for_builds (line 344). Worth verifying the status filter is correct for the idempotency check.
  • scripts/launchpad_copy.py:63-73get_supported_series now queries the Launchpad API. The filter is active=True and status in ("Supported", "Current Stable Release"), which excludes "Active Development" (unreleased) and "Obsolete" series.
  • .github/workflows/build_debian.yml:55-66 — the check-source step: 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-info fix and test cleanup based on review discussion. Reviewed all generated code and verified against the real Launchpad API.

rtibbles and others added 2 commits March 3, 2026 17:55
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
rtibbles force-pushed the idempotent-build-package branch from 156e82d to bc481b4 Compare March 4, 2026 01:55
@rtibbles
rtibbles merged commit 97c6b19 into main Mar 4, 2026
7 checks passed
@rtibbles
rtibbles deleted the idempotent-build-package branch March 4, 2026 02:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant