Add workflow and script to automatically update distribution snapshots#4208
Add workflow and script to automatically update distribution snapshots#4208daandemeyer wants to merge 3 commits intosystemd:mainfrom
Conversation
|
Looks reasonable… |
|
|
||
| yield f"{DISTRIBUTION_GPG_KEYS_UPSTREAM}/RPM-GPG-KEY-fedora-{version + 1}-primary" | ||
| except subprocess.CalledProcessError: | ||
| except urllib.error.URLError: |
Check notice
Code scanning / CodeQL
Empty except Note
Claude review of PR #4208 (829c154)Suggestions
Nits
All previous review items have been addressed in the latest revision. The PR looks good. |
Rename to fetch while we're at it.
Add a GitHub Actions workflow that runs every three days to pin each distribution to its latest snapshot. To make this work, we extend the latest-snapshot verb with the option to write the snapshot to a config file provided by the user. We do this to avoid having to start tracking which config file provided a setting. Even if we had that, we still would need the explicit config file to bootstrap the initial write so we might as well insist on the user providing it. The workflow runs mkosi latest-snapshot for each distribution (arch, centos, debian, fedora, opensuse, ubuntu) which fetches the latest snapshot, updates the corresponding mkosi config file with the new Snapshot= setting, and commits the result. The workflow then creates a pull request for the update using github-script. Each distribution gets its own dedicated branch (update-snapshot/<distro>) so that only a single pull request is open per distribution at a time. If an existing pull request is already open, it is updated in place by force-pushing to the branch. Auto-merge is enabled on each pull request via the GraphQL enablePullRequestAutoMerge mutation so that the snapshot update lands automatically once CI is green.
| old_keys = set(old_packages.keys()) | ||
| new_keys = set(new_packages.keys()) |
There was a problem hiding this comment.
The set() call around them is not really necessary, dict_keys already support all set operations by themselves.
| counts = [] | ||
| if changed: | ||
| counts.append(f"{len(changed)} upgraded") | ||
| if added: | ||
| counts.append(f"{len(added)} added") | ||
| if removed: | ||
| counts.append(f"{len(removed)} removed") | ||
| print(f"**Summary:** {', '.join(counts)}") |
There was a problem hiding this comment.
Nit: You could just go with
print(f"**Summary:** {len(changed)} upgraded, {len(added)} added, {len(removed)} removed")This way the last line always has the same structure, which, at least I, find visually easier when comparing output.
| branch="update-snapshot/${DISTRIBUTION:-default}" | ||
| git checkout -B "$branch" | ||
|
|
||
| mkosi ${DISTRIBUTION:+-d "$DISTRIBUTION"} ${RELEASE:+-r "$RELEASE"} latest-snapshot -- --update "$CONFIG" --commit |
There was a problem hiding this comment.
The latest-snapshot command is not documented. I think it should be, since it's quite useful for the snapshot functionality.
It's also a bit of a break with the rest of the config parsing, that this implements it's own argument parser. That should be documented. It seems a bit peculiar, since so far every subcommand's options just went into the big option bag.
| if not added: | ||
| # No [Distribution] section exists; add one. | ||
| result = new + ["", "[Distribution]", f"Snapshot={snapshot}"] |
There was a problem hiding this comment.
This has the edge case, that if there is just an empty distribution section
[Distribution]
add the end of the file, it will add a second distribution section. So adding the section header should be contingent on not being in_distribution.
Add a GitHub Actions workflow that runs every three days to pin each distribution to its latest snapshot. The workflow runs tools/update-snapshot.py for each distribution (arch, centos, debian, fedora, opensuse, ubuntu) which fetches the latest snapshot via "mkosi latest-snapshot", updates the corresponding mkosi config file with the new Snapshot= setting, and commits the result.
The workflow then creates a pull request for the update using github-script. Each distribution gets its own dedicated branch (update-snapshot/) so that only a single pull request is open per distribution at a time. If an existing pull request is already open, it is updated in place by force-pushing to the branch.
Auto-merge is enabled on each pull request via the GraphQL enablePullRequestAutoMerge mutation so that the snapshot update lands automatically once CI is green.