Skip to content

Commit 166ea3d

Browse files
committed
try to detect cargo-bins in paths
1 parent 30fb05a commit 166ea3d

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

.github/workflows/run-dev-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
- name: Install third-party binaries
4848
uses: taiki-e/install-action@v2
4949
with:
50-
tool: cargo-nextest,cargo-llvm-cov,cargo-binstall,just
50+
tool: cargo-nextest,cargo-llvm-cov,cargo-binstall
5151

5252
- name: Install llvm-cov-pretty (HTML report generator)
5353
run: cargo binstall -y llvm-cov-pretty

noxfile.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import logging
2+
from pathlib import Path
3+
import platform
24
import re
35
import sys
46
import nox
@@ -30,11 +32,34 @@ def __init__(self, session: nox.Session):
3032
self.cargo_bins = cargo_bins
3133
self.cargo_install_cmd: tuple[str, ...] = ("cargo", "install")
3234

35+
installed_path = Path("~/.cargo/bin")
36+
3337
if CARGO_BINSTALL in cargo_bins:
3438
ci_logger.info(
3539
"Found %s: %s" % (CARGO_BINSTALL, cargo_bins[CARGO_BINSTALL])
3640
)
37-
self.cargo_install_cmd = ("cargo", "binstall", "-y")
41+
elif (
42+
installed_path
43+
/ (CARGO_BINSTALL + "" if platform.system() != "Windows" else ".exe")
44+
).exists():
45+
ci_logger.info("Found %s" % CARGO_BINSTALL)
46+
else:
47+
ci_logger.info("Installing %s" % CARGO_BINSTALL)
48+
match platform.system():
49+
case "Windows":
50+
one_liner = """Set-ExecutionPolicy Unrestricted -Scope Process; iex (iwr "https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.ps1").Content"""
51+
session.run(*one_liner.split(), external=True)
52+
case "Linux" | "Darwin":
53+
one_liner = "curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash"
54+
session.run(*one_liner.split(), external=True)
55+
case _:
56+
session.run(
57+
*self.cargo_install_cmd,
58+
CARGO_BINSTALL,
59+
"--locked",
60+
external=True,
61+
)
62+
self.cargo_install_cmd = ("cargo", "binstall", "-y")
3863

3964
def check_install(self, req: str, session: nox.Session):
4065
"""Use cargo to ensure `req` is installed.
@@ -55,10 +80,17 @@ def install():
5580
dep = req if not ver else f"{req}@{ver}"
5681
session.run(*self.cargo_install_cmd, dep, "--locked", external=True)
5782

83+
installed_path = Path("~/.cargo/bin")
84+
5885
installed = False
5986
if req in self.cargo_bins:
6087
ci_logger.info("Found %s %s" % (req, self.cargo_bins[req]))
6188
installed = True
89+
elif (
90+
installed_path / (req + "" if platform.system() != "Windows" else ".exe")
91+
).exists():
92+
ci_logger.info("Found %s" % req)
93+
installed = True
6294
if ver or not installed:
6395
install()
6496

0 commit comments

Comments
 (0)