Skip to content

Commit

Permalink
Misc CI improvements (rerun-io#5905)
Browse files Browse the repository at this point in the history
### What

### Checklist
* [x] I checked a box

- [PR Build Summary](https://build.rerun.io/pr/5905)
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)
  • Loading branch information
emilk authored Apr 11, 2024
1 parent 60cf846 commit d884026
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/contrib_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ jobs:
uses: crate-ci/[email protected]

rs-cargo-deny:
name: Cargo Deny
name: cargo-deny
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/reusable_bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ jobs:
mkdir /tmp/compare/
gsutil cp gs://rerun-builds/benches/${{inputs.COMPARE_TO}} /tmp/compare/${{ inputs.COMPARE_TO }}
- name: Install cargo-benchcmp
run: cargo install --quiet cargo-benchcmp

- name: Compare results with benchcmp
if: ${{ inputs.COMPARE_TO != '' }}
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable_checks_rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ jobs:
# ---------------------------------------------------------------------------

rs-cargo-deny:
name: Cargo Deny
name: cargo-deny
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
36 changes: 26 additions & 10 deletions scripts/ci/rust_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from __future__ import annotations

import argparse
import os
import re
import subprocess
import sys
Expand All @@ -13,21 +14,27 @@


class Timing:
def __init__(self, command: str, start_time: float) -> None:
def __init__(self, command: str, duration: float) -> None:
self.command = command
self.duration = time.time() - start_time
self.duration = duration


def run_cargo(command: str, args: str) -> Timing:
command = f"cargo {command} --quiet {args}"
print(f"> {command}")
start = time.time()
result = subprocess.run(command, check=False, capture_output=True, text=True, shell=True)
def run_cargo(cargo_cmd, cargo_args: str) -> Timing:
args = ["cargo", cargo_cmd, "--quiet"] + cargo_args.split(" ")
cmd_str = subprocess.list2cmdline(args)
print(f"> {cmd_str}")
start_time = time.time()

env = os.environ.copy()
env["RUSTFLAGS"] = "--deny warnings"
env["RUSTDOCFLAGS"] = "--deny warnings --deny rustdoc::missing_crate_level_docs"

result = subprocess.run(args, env=env, check=False, capture_output=True, text=True)
if result.returncode != 0:
print(f"'{command}' failed with exit-code {result.returncode}. Output:\n{result.stdout}\n{result.stderr}")
sys.exit(result)
print(f"'{cmd_str}' failed with exit-code {result.returncode}. Output:\n{result.stdout}\n{result.stderr}")
sys.exit(result.returncode)

return Timing(command, start)
return Timing(cmd_str, time.time() - start_time)


def package_name_from_cargo_toml(cargo_toml_path: str) -> str:
Expand Down Expand Up @@ -58,6 +65,8 @@ def main() -> None:

# ----------------------

# NOTE: a lot of these jobs use very little CPU, but we csannot parallelize them because they all take a lock on the `target` directory.

timings = []

# First check with --locked to make sure Cargo.lock is up to date.
Expand Down Expand Up @@ -87,13 +96,20 @@ def main() -> None:
if args.skip_docs is not True:
# Full doc build takes prohibitively long (over 17min as of writing), so we skip it:
# timings.append(run_cargo("doc", "--all-features"))

# These take around 3m40s each on CI, but very useful for catching broken doclinks:
timings.append(run_cargo("doc", "--no-deps --all-features --workspace"))
timings.append(run_cargo("doc", "--document-private-items --no-deps --all-features --workspace"))

if args.skip_tests is not True:
# We first use `--no-run` to measure the time of compiling vs actually running

# Just a normal `cargo test` should always work:
timings.append(run_cargo("test", "--all-targets --no-run"))
timings.append(run_cargo("test", "--all-targets"))

# Full test of everything:
timings.append(run_cargo("test", "--all-targets --all-features --no-run"))
timings.append(run_cargo("test", "--all-targets --all-features"))

# Print timings overview
Expand Down

0 comments on commit d884026

Please sign in to comment.