Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/contents/built-in-updaters/pixi.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ quant-ranger update \
```

`--schedule weekly` runs only configurations set to `weekly`.
Omitting the option is a manual, unfiltered run and includes configurations set to `never`.
Omitting the option is a manual, unfiltered run over every other cadence.
Configurations set to `never` are always skipped, with or without the option.
Other updaters do not accept this option.
Control their cadence by choosing when the workflow calls them.

Expand Down
4 changes: 2 additions & 2 deletions docs/contents/reference/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ $ quant-ranger update pixi-version [OPTIONS]

**Options**:

* `--schedule [weekly|monthly|quarterly]`: Filter to update configurations whose schedule matches this value. Omit to include all configurations, including `never`.
* `--schedule [weekly|monthly|quarterly]`: Filter to update configurations whose schedule matches this value. Omit to include every cadence. Configurations set to `never` are always excluded.
* `--pixi-version TEXT`: Update to this pixi version (e.g. v0.70.0) instead of resolving the latest release from GitHub.
* `--setup-pixi-marker TEXT`: Only update workflow files containing this marker, e.g. when using a fork of setup-pixi. [default: (prefix-dev/setup-pixi)]
* `--help`: Show this message and exit.
Expand All @@ -147,7 +147,7 @@ $ quant-ranger update pixi-update [OPTIONS]

**Options**:

* `--schedule [weekly|monthly|quarterly]`: Filter to update configurations whose schedule matches this value. Omit to include all configurations, including `never`.
* `--schedule [weekly|monthly|quarterly]`: Filter to update configurations whose schedule matches this value. Omit to include every cadence. Configurations set to `never` are always excluded.
* `--help`: Show this message and exit.

### `quant-ranger update node-dependency-cooldown`
Expand Down
3 changes: 2 additions & 1 deletion quant_ranger/_impl/cli_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ def resolve(self, site_config: SiteConfig) -> OptionInfo | ArgumentInfo:
"--schedule",
help=(
"Filter to update configurations whose schedule matches this value. "
"Omit to include all configurations, including `never`."
"Omit to include every cadence. Configurations set to `never` are "
"always excluded."
),
),
]
14 changes: 9 additions & 5 deletions quant_ranger/_impl/updaters/_pixi_update/_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,17 @@ def scan_repository(
if manifest is None:
continue

if (
self.schedule is not None
and self.schedule != manifest.tool.update.autoupdate_schedule
):
configured_schedule = manifest.tool.update.autoupdate_schedule
# `never` opts out of autoupdates entirely, so it is honored even in
# an unfiltered run; the other values only select a cadence.
if configured_schedule == "never":
context.logger.debug(f"Skipping {path}: configured schedule is never.")
continue

if self.schedule is not None and self.schedule != configured_schedule:
context.logger.debug(
f"Skipping {path}: configured schedule is "
f"{manifest.tool.update.autoupdate_schedule}; current scheduled run is {self.schedule}."
f"{configured_schedule}; current scheduled run is {self.schedule}."
)
continue

Expand Down
6 changes: 6 additions & 0 deletions quant_ranger/_impl/updaters/_pixi_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ def scan_repository(
return []

config = self._read_config(repository_ref, context)
# `never` opts out of autoupdates entirely, so it is honored even in an
# unfiltered run; the other values only select a cadence.
if config.autoupdate_schedule == "never":
context.logger.debug("Skipping repository: configured schedule is never.")
return []

if self.schedule is not None and config.autoupdate_schedule != self.schedule:
context.logger.debug(
f"Skipping repository: configured schedule is "
Expand Down
41 changes: 41 additions & 0 deletions tests/test_pixi_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -1305,6 +1305,47 @@ def test_pixi_lockfile_scanner_filters_schedule_mismatches() -> None:
)


def test_pixi_lockfile_scanner_skips_never_without_schedule_filter() -> None:
repository = RepositoryRef(owner="quantco", name="with-lockfiles", branch="main")
logger = RecordingLogger()
github_client = FakeGitHubClient(
files={
"quantco/with-lockfiles": [
"pixi.lock",
"subproject/pixi.lock",
],
},
file_contents={
"pixi.toml": """
[tool.update]
autoupdate-schedule = "never"
""",
"subproject/pixi.toml": """
[tool.update]
autoupdate-schedule = "weekly"
""",
},
)

items = PixiUpdateUpdater(PixiUpdateOptions()).scanner.scan_all(
[repository],
RunContext(
site_config=SiteConfig(),
github_client=cast(GitHubClient, github_client),
logger=logger,
),
)

assert [
(item.repository_ref, item.path.as_posix()) for item in items.update_items
] == [(repository, "subproject/pixi.lock")]
assert logger.logged(
LogLevel.DEBUG,
"[quantco/with-lockfiles@main] Skipping pixi.lock: configured schedule "
"is never.",
)


def test_pixi_lockfile_scanner_skips_missing_manifest() -> None:
repository = RepositoryRef(owner="quantco", name="with-lockfile", branch="main")
logger = RecordingLogger()
Expand Down
32 changes: 32 additions & 0 deletions tests/test_pixi_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,38 @@ def test_pixi_repository_scanner_filters_schedule_mismatches() -> None:
)


def test_pixi_repository_scanner_skips_never_without_schedule_filter() -> None:
repository = RepositoryRef(owner="quantco", name="with-lockfile", branch="main")
logger = RecordingLogger()
github_client = FakeGitHubClient(
files={"quantco/with-lockfile": ["pixi.lock"]},
file_contents={
"pixi.toml": """
[tool.pixi-version-updater]
autoupdate-schedule = "never"
""",
},
)

items = PixiVersionUpdater(
PixiVersionOptions(setup_pixi_marker="prefix-dev/setup-pixi")
).scanner.scan_all(
[repository],
RunContext(
site_config=SiteConfig(),
github_client=cast(GitHubClient, github_client),
logger=logger,
),
)

assert items.update_items == ()
assert logger.logged(
LogLevel.DEBUG,
"[quantco/with-lockfile@main] Skipping repository: configured schedule "
"is never.",
)


def test_pixi_repository_scanner_reads_scheduled_config_once_per_repository() -> None:
repository = RepositoryRef(owner="quantco", name="with-lockfiles", branch="main")
github_client = FakeGitHubClient(
Expand Down
Loading