Skip to content

Commit b3992d5

Browse files
committed
TOOLS-4102 Use mise to execute go as well as other dev tools
This gets rid of the Go code to install dev tools entirely, and updates all the places we call these tools to use `mise exec`.
1 parent 48c54ef commit b3992d5

15 files changed

Lines changed: 195 additions & 611 deletions

CONTRIBUTING.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,67 @@ If you're interested in contributing, we have a list of some suggested tickets t
1212
to get started on
1313
[here](https://jira.mongodb.org/issues/?jql=project%20%3D%20TOOLS%20AND%20labels%20%3D%20community%20and%20status%20%3D%20open)
1414

15+
## Dev Tools (mise)
16+
17+
We use [`mise`](https://mise.jdx.dev/) to manage dev tools (Go, linters, formatters, etc.), ensuring
18+
every developer and CI run uses the same versions.
19+
20+
### Installing mise
21+
22+
To install mise, run this command:
23+
24+
```
25+
MISE_VERSION=$( cat ./scripts/mise-version.txt ) sh scripts/mise.run.sh
26+
```
27+
28+
Then run:
29+
30+
```
31+
# Enable the Go backend
32+
mise settings experimental=true
33+
# Trust the config in this repo
34+
mise trust
35+
# Install all dev tools (Go, linters, etc.)
36+
mise install
37+
# Install Node packages needed by eslint, prettier, etc.
38+
npm install
39+
```
40+
41+
After `mise install`, all tools (including `go`) are available directly in your shell when you're in
42+
this repo's directory. See [the mise docs](https://mise.jdx.dev/) for details on shell integration.
43+
44+
### Adding a new tool
45+
46+
Run `mise use github:some-org/some-tool@1.2.3`. We use the `github` backend for tools that provide
47+
binary releases. For Go tools without binary releases, use `go:some/package@vX.Y.Z`.
48+
49+
## Using Mise
50+
51+
You can integrate `mise` with your shell so that dev tools are automatically added to your `PATH`
52+
when your working directory is in the Mongosync repo. See [the `mise` docs](https://mise.jdx.dev/)
53+
for more details on this.
54+
55+
If you _don't_ want to use that integration, you can instead use
56+
`mise exec <list of tools> -- some-tool` to run the tools managed by `mise`, so something like
57+
`mise exec go -- go version`. It's important to list the tools that `mise exec` needs. Without that
58+
list, it will attempt to install _all_ the tools in our `mise.toml` when you run `mise exec`. This
59+
is generally fine locally, but can cause problems in CI, where many of the tools we use cannot be
60+
installed on some of the platforms we use.
61+
62+
### In CI
63+
64+
We do not set up the shell integration when installing `mise` in CI. That means that anything in CI
65+
which needs to run Go or another dev tool should use `mise exec go -- go ...` or a similar
66+
invocation.
67+
68+
### Writing Code that Runs Dev Tools
69+
70+
You may want to write code that uses these tools, either as a script for use in CI or some other
71+
case.
72+
73+
All programmatic tool invocations should use `mise exec <tool>`. This will work in CI as well as
74+
locally.
75+
1576
## Getting Started
1677

1778
1. Create a [MongoDB JIRA account](https://jira.mongodb.org/secure/Signup!default.jspa).

build.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,12 @@ func init() {
4545
Do(buildscript.WriteThirdPartyNotices)
4646

4747
// Static Analysis
48-
taskRegistry.Declare("sa:installdevtools").
49-
Description("installs dev tools").
50-
Do(buildscript.SAInstallDevTools)
5148
taskRegistry.Declare("sa:lint").
5249
Description("runs precious linting").
53-
DependsOn("sa:installdevtools").
5450
Do(buildscript.SAPreciousLint)
55-
taskRegistry.Declare("sa:modtidy").Description("runs go mod tidy").Do(buildscript.SAModTidy)
51+
taskRegistry.Declare("sa:modtidy").
52+
Description("runs go mod tidy").
53+
Do(buildscript.SAModTidy)
5654
taskRegistry.Declare("sa:evgvalidate").
5755
Description("runs evergreen validate").
5856
Do(buildscript.SAEvergreenValidate)

0 commit comments

Comments
 (0)