diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e0746fd..9870228 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,6 +53,8 @@ jobs: uses: dtolnay/rust-toolchain@stable with: target: aarch64-linux-android + - name: Set up Rust Part 2 + uses: cargo-bins/cargo-binstall@main - name: Install rustup target run: rustup target add aarch64-linux-android - name: Set up Python @@ -78,6 +80,8 @@ jobs: uses: dtolnay/rust-toolchain@stable with: profile: minimal + - name: Set up Rust Part 2 + uses: cargo-bins/cargo-binstall@main - name: Set up Python uses: actions/setup-python@v4 with: diff --git a/libs/scripts.py b/libs/scripts.py index fc84c8f..7a3569a 100644 --- a/libs/scripts.py +++ b/libs/scripts.py @@ -15,6 +15,20 @@ def fmt(cd: str, args: list[str]) -> str | int | None: if res.returncode != 0: exit(res.returncode) def test(cd: str, args: list[str]) -> str | int | None: + # Check if tarpaulin is installed + def is_tarpaulin_installed() -> bool: + res = subprocess.run(["cargo", "tarpaulin", "--version"], capture_output=True) + return res.returncode == 0 + + # Install tarpaulin + def install_tarpaulin() -> None: + res = subprocess.run(["cargo", "binstall", "cargo-tarpaulin"]) + if res.returncode != 0: exit(res.returncode) + + # Check if tarpaulin is installed and install it if it isn't + if not is_tarpaulin_installed(): install_tarpaulin() + + # Run tarpaulin cmd = ["cargo", "tarpaulin"] cmd.extend(args) res = subprocess.run(cmd, cwd=cd)