Skip to content
This repository was archived by the owner on Sep 17, 2023. It is now read-only.

feat: add subcommand to lint depenendency versions for consistent values #156

Merged
merged 6 commits into from
May 7, 2022

Conversation

EricCrosson
Copy link
Contributor

The lint-dependency-version subcommand takes a list of dependencies,
and for each dependency will test that there is at most one version
of that dependency in use throughout the target monorepo.

If this condition is violated, the command will exit non-zero exit code.

The plan is to use this in CI to enforce monorepo invariants for using
only a single version of a given external dependency; for example,
typescript.

Ideally we separate out the library and binary code in this crate,
and later we can write multiple binaries that use this library, one
of which will invoke this new code and can function as a stand-alone
Drone plugin. Thinking about it now, the coupling to Drone is not a
goal of this crate but importing the library portion of this codebase
from a different crate will be a prerequisite for the plugin.

Also:

  • separate the package into binary and library crates
  • read monorepo manifest files in parallel

The `lint-dependency-version` subcommand takes a list of dependencies,
and for each dependency will test that there is at most one version
of that dependency in use throughout the target monorepo.

If this condition is violated, the command will exit non-zero exit code.

The plan is to use this in CI to enforce monorepo invariants for using
only a single version of a given external dependency; for example,
`typescript`.

Ideally we separate out the library and binary code in this crate,
and later we can write multiple binaries that use this library, one
of which will invoke this new code and can function as a stand-alone
Drone plugin. Thinking about it now, the coupling to Drone is not a
goal of this crate but importing the library portion of this codebase
from a different crate will be a prerequisite for the plugin.
I collected the following benchmarks on my desktop machine.

Using no paralleliation

```
$ hyperfine --warmup 10 --min-runs 250 "./target/release/monorepo link --root ~/workspace/my-monorepo"
Benchmark 1: ./target/release/monorepo link --root ~/workspace/my-monorepo
  Time (mean ± σ):      63.1 ms ±  23.6 ms    [User: 50.8 ms, System: 55.9 ms]
  Range (min … max):    30.4 ms … 150.8 ms    250 runs
```

Using a parallel iterator

```
$ hyperfine --warmup 10 --min-runs 250 "./target/release/monorepo link --root ~/workspace/stratos"
Benchmark 1: ./target/release/monorepo link --root ~/workspace/stratos
  Time (mean ± σ):      39.5 ms ±  12.5 ms    [User: 26.5 ms, System: 24.2 ms]
  Range (min … max):    30.0 ms …  90.3 ms    250 runs
```

This looks like a speedup of almost 50%.
@EricCrosson EricCrosson merged commit 67993d7 into master May 7, 2022
@EricCrosson EricCrosson deleted the beta branch May 7, 2022 23:23
@github-actions
Copy link

github-actions bot commented May 7, 2022

🎉 This PR is included in version 4.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant