Skip to content

Commit

Permalink
Use regexp to ignore tracks (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
bschimke95 authored Dec 17, 2024
1 parent e8f4357 commit a83cf81
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/promotion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ jobs:
- name: Assemble auto-promotion Arguments
if: ${{ github.event_name != 'workflow_dispatch' }}
run: |
# Ignore the 1.30 track for auto-promotion. We don't support it.
ARGS="$ARGS --ignore-tracks 1.30-moonray 1.30-classic"
# Ignore the 1.30 and strict tracks for auto-promotion. We don't support them.
ARGS="$ARGS --ignore-tracks '^1\.\d{2}$' '^1\.30(-.*)?$'"
echo "ARGS=$ARGS" >> $GITHUB_ENV
- name: Propose Promotions
id: propose-promotions
Expand Down
9 changes: 7 additions & 2 deletions scripts/promote_tracks.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,17 @@ def sorter(info: Channel):

final_channel = f"{track}/{next_risk}"

if not track:
chan_log.debug("Skipping trackless channel")
continue

if not next_risk:
chan_log.debug("Skipping promoting stable")
continue

if track in ignored_tracks:
chan_log.debug("Skipping ignored track")
matched_pattern = next((pattern for pattern in ignored_tracks if re.fullmatch(pattern, track)), None)
if matched_pattern:
chan_log.debug(f"Skipping ignored track '{track}' (matched pattern: '{matched_pattern}')")
continue

if arch in ignored_arches:
Expand Down
17 changes: 17 additions & 0 deletions tests/unit/test_promote_tracks.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,20 @@ def test_latest_track(risk, now):
with freeze_time(now), _make_channel_map("latest", risk):
proposals = promote_tracks.create_proposal(args)
assert proposals == [], "Latest track should not be promoted"

@pytest.mark.parametrize(
"track, ignored_patterns, expected_ignored",
[
("1.31", ["1.31", r"1\.\d+-classic"], True), # Exact match
("1.31-classic", ["1\\.31", r"1\.\d+-classic"], True), # Regex match
("1.32", ["1\\.31", r"1\.\d+-classic"], False), # No match
("1.31-classic", [], False), # Nothing ignored
],
)
def test_ignored_tracks(track, ignored_patterns, expected_ignored):
with _make_channel_map(track, "edge"):
args.ignore_tracks = ignored_patterns
proposals = promote_tracks.create_proposal(args)
assert (len(proposals) == 0) == expected_ignored, (
f"Track '{track}' should {'be ignored' if expected_ignored else 'not be ignored'}"
)

0 comments on commit a83cf81

Please sign in to comment.