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
10 changes: 10 additions & 0 deletions .github/actions/setup-rust/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,16 @@ runs:
chmod +x "$cargo_home/bin/rustup"
fi

# A copied rustup binary skips rustup-init, which normally creates env.
# Recreate that file after clearing our tool root: a runner login profile
# from an earlier install may still source this exact stable path.
cat > "$cargo_home/env" <<EOF
case ":\${PATH}:" in
*:"$cargo_home/bin":*) ;;
*) export PATH="$cargo_home/bin:\$PATH" ;;
esac
EOF

echo "CARGO_HOME=$cargo_home" >> "$GITHUB_ENV"
echo "RUSTUP_HOME=$rustup_home" >> "$GITHUB_ENV"
echo "$cargo_home/bin" >> "$GITHUB_PATH"
Expand Down
6 changes: 3 additions & 3 deletions .repository-projection.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
"projection": "deixic-code",
"projectionSchemaVersion": 1,
"sourceRepository": "dx-corp/mono",
"sourceSha": "792ca39c3e3492c9d7bc4873dfc75869237ecbc4",
"sourceSha": "286d0a37ebf99fa22738837904ad8e9f2b3b111b",
"destinationRepository": "dx-corp/code",
"priorProjectedBase": "7fd521be8426582afe782fce895e6646cc33c762",
"priorProjectedBase": "286f11a74b63db13a1acd5b4734a431f224e002c",
"definitionDigest": "82936441c776e3e8edb5d215a75007ec9714a233f489d460075d79d5ef5ba32f",
"toolDigest": "f8cb071b0f27267120ccf45a00d0982f45113bd23535bef6a1555b4933f99f13",
"contentDigest": "ab481067715e68db84c8c97cdaf6f3d9d73870c42dcb8a47771e05000490ed23",
"contentDigest": "5d1b37000892e79eded38fcd977ec4da312724f0f21f5c1aedf39ac65a3b440b",
"publicationEligible": true
}
28 changes: 28 additions & 0 deletions scripts/setup-rust-env.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import assert from "node:assert/strict";
import { execFileSync } from "node:child_process";
import { mkdtempSync, readFileSync, rmSync, writeFileSync, mkdirSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { test } from "node:test";

test("copied rustup recreates the env file sourced by an existing login profile", () => {
Comment thread
haasonsaas marked this conversation as resolved.
const root = mkdtempSync(join(tmpdir(), "maestro-rust-env-"));
try {
const action = readFileSync(".github/actions/setup-rust/action.yml", "utf8");
const step = action.split(" run: | # zizmor:")[1].split("\n - name:")[0];
const script = step.split("\n").slice(1).map((line) => line.startsWith(" ") ? line.slice(8) : line).join("\n")
.replace("cache_root=/tmp/maestro-rust", `cache_root="${root}/cache"`);
const bin = join(root, "bin"); mkdirSync(bin);
writeFileSync(join(bin, "rustup"), "#!/bin/sh\nexit 0\n", {mode: 0o755});
const env = {...process.env, PATH: `${bin}:${process.env.PATH}`, RUNNER_OS: "Linux", GITHUB_REPOSITORY: "conformance/env", TOOLCHAIN_INPUT: "1.95.0", WORKSPACES_INPUT: ".", GITHUB_ENV: join(root,"env"), GITHUB_PATH: join(root,"path"), GITHUB_OUTPUT: join(root,"output")};
const cargoHome = join(root,"cache/conformance-env/1.95.0/home/cargo");
const profile = join(root,"profile"); writeFileSync(profile, `. "${cargoHome}/env"\n`);
for (let run = 0; run < 2; run++) {
execFileSync("bash", ["-c", script], {env, cwd: process.cwd()});
const output = execFileSync("sh", ["-c", `. "${profile}"; printf runtime-conformance-shell`], {env, encoding: "utf8"});
assert.equal(output, "runtime-conformance-shell");
const path = execFileSync("sh", ["-c", `. "${profile}"; . "${profile}"; printf '%s' "$PATH"`], {env, encoding:"utf8"});
assert.equal(path.split(":").filter((entry) => entry === `${cargoHome}/bin`).length, 1);
}
} finally { rmSync(root, {recursive:true,force:true}); }
});
Loading