Fix local packse workflow (#9808)

Make the local packse workflow work again:

```
# In packse:
uv run --extra index --extra serve packse serve --no-hash scenarios &
# In uv:
UV_TEST_INDEX_URL="http://localhost:3141/simple/" ./scripts/scenarios/generate.py
```

Bugs fixed:
* The default scenario pattern didn't match anything.
* The snapshot update test command was wrong since the test
centralization
* Snapshot update failures would not be reported
This commit is contained in:
konsti 2024-12-11 16:32:46 +01:00 committed by GitHub
parent 80d41671bc
commit cb3fefff15
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 6 deletions

View file

@ -83,7 +83,10 @@ def main(scenarios: list[Path], snapshot_update: bool = True):
debug = logging.getLogger().getEffectiveLevel() <= logging.DEBUG
update_common_mod_rs(packse_version)
# Don't update the version to `0.0.0` to preserve the `UV_TEST_VENDOR_LINKS_URL`
# in local tests.
if packse_version != "0.0.0":
update_common_mod_rs(packse_version)
if not scenarios:
if packse_version == "0.0.0":
@ -93,7 +96,7 @@ def main(scenarios: list[Path], snapshot_update: bool = True):
"Detected development version of packse, using scenarios from %s",
path,
)
scenarios = path.glob("*.json")
scenarios = [path]
else:
logging.error(
"No scenarios provided. Found development version of packse but is missing scenarios. Is it installed as an editable?"
@ -108,6 +111,7 @@ def main(scenarios: list[Path], snapshot_update: bool = True):
if target.is_dir():
targets.extend(target.glob("**/*.json"))
targets.extend(target.glob("**/*.toml"))
targets.extend(target.glob("**/*.yaml"))
else:
targets.append(target)
@ -226,16 +230,20 @@ def main(scenarios: list[Path], snapshot_update: bool = True):
"--test-runner",
"nextest",
"--test",
"it",
"--",
tests.with_suffix("").name,
]
logging.debug(f"Running {" ".join(command)}")
subprocess.call(
logging.debug(f"Running {' '.join(command)}")
exit_code = subprocess.call(
command,
cwd=PROJECT_ROOT,
stderr=subprocess.STDOUT,
stdout=sys.stderr if debug else subprocess.DEVNULL,
env=env,
)
if exit_code != 0:
logging.warning(f"Snapshot update failed (Exit code: {exit_code})")
else:
logging.info("Skipping snapshot update")