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

@ -37,11 +37,15 @@ pub const PACKSE_VERSION: &str = "0.3.39";
/// Using a find links url allows using `--index-url` instead of `--extra-index-url` in tests /// Using a find links url allows using `--index-url` instead of `--extra-index-url` in tests
/// to prevent dependency confusion attacks against our test suite. /// to prevent dependency confusion attacks against our test suite.
pub fn build_vendor_links_url() -> String { pub fn build_vendor_links_url() -> String {
format!("https://raw.githubusercontent.com/astral-sh/packse/{PACKSE_VERSION}/vendor/links.html") env::var("UV_TEST_VENDOR_LINKS_URL").ok().unwrap_or(format!(
"https://raw.githubusercontent.com/astral-sh/packse/{PACKSE_VERSION}/vendor/links.html"
))
} }
pub fn packse_index_url() -> String { pub fn packse_index_url() -> String {
format!("https://astral-sh.github.io/packse/{PACKSE_VERSION}/simple-html/") env::var("UV_TEST_INDEX_URL").ok().unwrap_or(format!(
"https://astral-sh.github.io/packse/{PACKSE_VERSION}/simple-html/"
))
} }
#[doc(hidden)] // Macro and test context only, don't use directly. #[doc(hidden)] // Macro and test context only, don't use directly.

View File

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