-
Notifications
You must be signed in to change notification settings - Fork 0
Update setup-rust dependencies for Node.js 24 #396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,9 +10,10 @@ | |
| from __future__ import annotations | ||
|
|
||
| import re | ||
| import typing as typ | ||
| from pathlib import Path | ||
|
|
||
| import pytest | ||
| import yaml | ||
|
|
||
| from .conftest import ( | ||
| FIXTURES_DIR, | ||
|
|
@@ -22,10 +23,8 @@ | |
| skip_unless_workflow_tests, | ||
| ) | ||
|
|
||
| if typ.TYPE_CHECKING: | ||
| from pathlib import Path | ||
|
|
||
| WORKFLOW = "test-rustflags-export.yml" | ||
| WORKFLOW_PATH = Path(__file__).resolve().parents[2] / ".github" / "workflows" / WORKFLOW | ||
| # The workflow runs on the release event because the nested setup-rust skips | ||
| # sccache for releases, whose post-step is unreliable under act. | ||
| EVENT = "release" | ||
|
|
@@ -49,6 +48,56 @@ def _run(job: str, artefact_dir: Path) -> str: | |
| return logs | ||
|
|
||
|
|
||
| def test_setup_rust_toolchain_workflow_shape() -> None: | ||
| """The runner job exercises the intended local setup-rust path.""" | ||
| workflow = yaml.safe_load(WORKFLOW_PATH.read_text(encoding="utf-8")) | ||
| assert isinstance(workflow, dict), f"{WORKFLOW_PATH} must contain a YAML mapping" | ||
| jobs = workflow.get("jobs") | ||
| assert isinstance(jobs, dict), f"{WORKFLOW_PATH} must define a jobs mapping" | ||
| job = jobs.get("setup-rust-toolchain-available") | ||
| assert isinstance(job, dict), ( | ||
| "workflow must define the setup-rust-toolchain-available job" | ||
| ) | ||
| steps = job.get("steps") | ||
| assert isinstance(steps, list), ( | ||
| "setup-rust-toolchain-available must define a steps collection" | ||
| ) | ||
| assert all(isinstance(step, dict) for step in steps), ( | ||
| "every setup-rust-toolchain-available step must be a mapping" | ||
| ) | ||
|
|
||
| setup_steps = [step for step in steps if step.get("name") == "Setup stable Rust"] | ||
| assert len(setup_steps) == 1, "expected exactly one Setup stable Rust step" | ||
| setup_step = setup_steps[0] | ||
| assert setup_step["uses"] == "./.github/actions/setup-rust", ( | ||
| "Setup stable Rust must call the local setup-rust action" | ||
| ) | ||
| assert setup_step["with"] == { | ||
| "toolchain": "stable", | ||
| "install-binstall": "false", | ||
| "use-sccache": "false", | ||
| }, "Setup stable Rust must select the isolated stable toolchain path" | ||
|
|
||
| verify_steps = [ | ||
| step | ||
| for step in steps | ||
| if step.get("name") == "Verify Rust tools remain available" | ||
| ] | ||
| assert len(verify_steps) == 1, ( | ||
| "expected exactly one Verify Rust tools remain available step" | ||
| ) | ||
| verify_step = verify_steps[0] | ||
| script = verify_step["run"] | ||
| assert "rustc --version" in script, "verification must execute rustc" | ||
| assert "cargo --version" in script, "verification must execute cargo" | ||
| assert 'test -n "${rustc_version}"' in script, ( | ||
| "verification must assert that rustc returned a version" | ||
| ) | ||
| assert 'test -n "${cargo_version}"' in script, ( | ||
| "verification must assert that cargo returned a version" | ||
| ) | ||
|
Comment on lines
+69
to
+98
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Assert the stable-toolchain removal precondition. Add a structural assertion for the Without this assertion, a later removal of the isolation step can make the Act test pass from a runner-provided stable toolchain. Proposed fix+ removal_steps = [
+ step
+ for step in steps
+ if step.get("name") == "Remove the preinstalled stable toolchain"
+ ]
+ assert len(removal_steps) == 1, "expected exactly one stable removal step"
+ removal_script = removal_steps[0].get("run")
+ assert isinstance(removal_script, str), "stable removal step must have a script"
+ assert "rustup toolchain uninstall stable" in removal_script, (
+ "stable removal step must uninstall the stable toolchain"
+ )
+ assert "rustup run stable rustc" in removal_script, (
+ "stable removal step must verify stable is unavailable"
+ )
+
setup_steps = [step for step in steps if step.get("name") == "Setup stable Rust"]🤖 Prompt for AI Agents |
||
|
|
||
|
|
||
| @skip_unless_act | ||
| @skip_unless_workflow_tests | ||
| def test_rust_build_release_exports_rustflags_to_later_steps( | ||
|
|
@@ -117,3 +166,20 @@ def test_setup_rust_leaves_an_inherited_rustflags_alone(artefact_dir: Path) -> N | |
| assert "debuginfo=2" not in logs.split("setup_rust_inherited_rustflags=")[-1], ( | ||
| f"the input displaced the inherited value:\n{logs}" | ||
| ) | ||
|
|
||
|
|
||
| @skip_unless_act | ||
| @skip_unless_workflow_tests | ||
| def test_setup_rust_exposes_rust_tools_to_later_steps(artefact_dir: Path) -> None: | ||
| """A supported Linux setup leaves rustc and cargo available downstream.""" | ||
| logs = _run("setup-rust-toolchain-available", artefact_dir) | ||
|
|
||
| assert re.search(r"setup_rust_toolchain=\[stable-[^]]+", logs), ( | ||
| f"setup-rust did not select the required stable toolchain:\n{logs}" | ||
| ) | ||
| assert re.search(r"setup_rust_rustc=\[rustc \d+\.\d+\.\d+", logs), ( | ||
| f"rustc was not available after setup-rust:\n{logs}" | ||
| ) | ||
| assert re.search(r"setup_rust_cargo=\[cargo \d+\.\d+\.\d+", logs), ( | ||
| f"cargo was not available after setup-rust:\n{logs}" | ||
| ) | ||
Uh oh!
There was an error while loading. Please reload this page.