Skip to content

Commit

Permalink
patch(_update_bundle.yaml): Alphabetically sort snap revision list (#243
Browse files Browse the repository at this point in the history
)

## Issue

The workflow mistakenly created PRs for updating the snaps list because
of ordering, even though the revisions itself didn't change. This is
because, for python:

```
> {"packages": ["snap1", "snap2", "snap3"]} != {"packages": ["snap1", "snap3", "snap2"]}
True
```
then, `snaps != old_snaps` was being set to true every time, and the
output of `updates_available` was mistakenly being set to `true`
## Solution

Sort the snaps list. See test runs: 

postgresql:
canonical/postgresql-bundle@d5056b5
mysql:
canonical/mysql-bundle@4269833
  • Loading branch information
lucasgameiroborges authored Oct 16, 2024
1 parent 2dfa362 commit 60f088b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions python/cli/data_platform_workflows_cli/update_bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from . import github_actions


@dataclasses.dataclass(frozen=True)
@dataclasses.dataclass(order=True, frozen=True)
class Snap:
name: str
revision: int
Expand Down Expand Up @@ -272,7 +272,7 @@ def main():
file.write(yaml_string)

if len(bundle_snaps) > 0:
snaps_data = {"packages": [dataclasses.asdict(snap) for snap in bundle_snaps]}
snaps_data = {"packages": [dataclasses.asdict(snap) for snap in sorted(bundle_snaps)]}
try:
old_snaps_data = yaml.safe_load(pathlib.Path(SNAPS_YAML_PATH).read_text())
except FileNotFoundError:
Expand Down

0 comments on commit 60f088b

Please sign in to comment.