20 Commits

Author SHA1 Message Date
Michael Kriese dff2bd5068 refactor(util/exec): use isContainerbase from the base image package directly (#47247)
* refactor(util/exec): use isContainerbase from the base image package

Co-Authored-By: Claude Opus 5.5 <michael.kriese+claude-code@mend.io>
Co-Authored-By: Claude Sonnet 5.5 <michael.kriese+claude-code@mend.io>

* refactor(util/exec): read CONTAINERBASE from the process environment only

Co-Authored-By: Claude Opus 5.5 <michael.kriese+claude-code@mend.io>
Co-Authored-By: Claude Sonnet 5.5 <michael.kriese+claude-code@mend.io>

* refactor(util/exec): use isContainerbase from the base image package directly

Co-Authored-By: Claude Opus 5.5 <michael.kriese+claude-code@mend.io>
Co-Authored-By: Claude Sonnet 5.5 <michael.kriese+claude-code@mend.io>

---------

Co-authored-by: Claude Opus 5.5 <michael.kriese+claude-code@mend.io>
2026-10-21 11:07:04 +00:00
RahulGautamSingh df201a98ff fix(util/exec): pick tool releases compatible with their parent tool version (#47090)
* fix(util/exec): pick tool releases compatible with resolved node version

* refactor(util/exec): pass resolved runtimes as an object

* refactor(util/exec): match tools against their containerbase parent

* test(util/exec): run real constraints filtering for parent versions
2026-10-16 08:13:04 +00:00
Michael Kriese 2ca2bc0ba0 fix(exec): re-run install-tool when switching back to an earlier tool version (#46823)
`install-tool` installs a version and also makes it the active one. The
memo skipped `install-tool` for any tool version already installed in the
run, so after A -> B -> A the last command ran on B. Track the active
version per tool instead and skip only when the requested version is
already active.

Co-authored-by: Claude Opus 5.5 <michael.kriese+claude-code@mend.io>
2026-10-07 16:15:34 +00:00
Jamie Tanna b2135e41b7 fix(exec): memoise which install-tools we've run (#46084)
When running Renovate with `binarySource=install` on a repository with
many branches, the amount of time running `install-tool` - on already
installed tools - can take a significant percentage of the overall run.

For instance, on one repository we have instrumented with OpenTelemetry,
we see:

- initial `install-tool golang`: 8.7s
- follow-up `install-tool golang`: median 635ms, max 2.4s

However, because we run `install-tool golang` 640 times, this adds up to
24.8/29.2m (85%) of the repo's run time, which is an overwhelming
percentage when we're not even re-installing the tool.

To handle this more effectively, we can add an in-memory cache of all
the tools (and resolved versions) that we've installed in a given run.

We can't do this with `binarySource=docker`, as it has a fresh container
each time.

Co-authored-by: Claude Sonnet 5 <jamie.tanna+claude-code@mend.io>
2026-09-14 20:33:10 +00:00
Sebastian Poxhofer 05e1271376 test: use expect().resolves instead of awaiting inside expect (#45672)
Enables the vitest/prefer-expect-resolves oxlint rule and applies its
autofix across the spec suite.
2026-09-04 10:40:46 +00:00
Sebastian Poxhofer fbedd41e82 test: replace env operation with vi.stubEnv() (#45490)
* test: replace manual process.env mutation with vi.stubEnv

Enable Vitest's `unstubEnvs` so env stubs are reverted automatically
before every test, and convert the manual `process.env.X = ...` /
`delete process.env.X` pairs in specs to `vi.stubEnv()`.

This removes the hand-written `afterEach` cleanup blocks and the
`const OLD_ENV = process.env` / `process.env = { ...OLD_ENV }`
save-restore dance, which silently leaked state between tests when a
test set a variable without a matching delete.

Left as-is (incompatible with `unstubEnvs`, which unstubs before each
test, not after):
- module top-level env writes (cocoapods, gomod, post-update, pip-compile
  and bundler artifacts specs)
- `beforeAll` env writes -- the two in `util/http` moved to `beforeEach`

* test: stop asserting on ambient environment variables

Three specs asserted on values that the surrounding environment can
override, so they only passed on a machine that happened not to set them:

- `util/exec/env`: `getChildProcessEnv()` forwards every entry of
  `basicEnvVars`, but the spec only seeded a subset. Any other forwarded
  variable that was set ambiently (e.g. a lowercase `http_proxy`) leaked
  into the `toEqual` assertion. Clear all of them first.
- `util/git/index`: `process.env.GIT_SSH_COMMAND` deliberately overrides
  the default that the two env-inheritance tests assert on. Clear it.
- `logger/pretty-stdout`: the colorized level strings are built at import
  time, so the `beforeEach` setting `FORCE_COLOR` could never affect them
  -- it was dead code, and the test silently assumed a terminal without
  colour support. Derive the expectation the same way the module does.

* test(datasource/nuget): use a throwaway cache dir for nupkg downloads

The `determine source URL from nupkg` tests do not mock the filesystem,
so they really wrote downloaded packages into a fixed `/tmp/cache` path.
That fails wherever the system tmpdir is not writable, and two checkouts
running the suite at once would share the same directory.

Use `tmp.dir({ unsafeCleanup: true })` and clean it up afterwards, which
is the pattern the other specs that touch disk already use.

* feat(lint): add renovate/prefer-stub-env rule

Enforces in specs what the migration to `vi.stubEnv` established:

- assigning to or deleting `process.env.X` inside `beforeEach`, `afterEach`,
  `it` or `test` is reported, with a fixer that rewrites it to `vi.stubEnv()`
- module scope, `describe` bodies and `beforeAll` / `afterAll` are left alone:
  `unstubEnvs` reverts stubs *before* each test, so a stub created there is
  gone by the time the first test runs, and those must keep assigning directly
- replacing the `process.env` object is reported everywhere and never fixed.
  `vi.stubEnv()` captures the original object when the worker starts, so after
  a reassignment its deletes silently target the old object

The rule found 28 further violations in specs the earlier sweep missed, since
that one was anchored on `delete process.env`. Twelve were auto-fixed; the
rest replaced `process.env` wholesale and are now `clearEnv()` from test/util.

`util/exec/index.spec.ts` opts out with a comment: it asserts on the whole
child env, and `vi.stubEnv()` cannot express that because it maps `PROD`,
`DEV` and `SSR` onto '' instead of deleting them.
2026-08-28 09:26:20 +00:00
Jamie Tanna b8c4eb2088 fix(containerbase): support constraints.rust=nightly (#43543)
As noted in #43489, it's not currently possible to install the nightly
variant of Rust.

Although Containerbase does have support for `install-tool rust nightly`
it never gets that far, as the version lookup occurs through the
`docker` datasource.

We can instead make sure we move to the `rust-version` datasource and
its associated `rust-release-channel` versioning.

The result from the `rust-release-channel` returns a version like
`nightly-2026-06-19`, which needs extra handling in Containerbase.

We can also update **??** what supported Rust versions we'd accept.
2026-06-19 17:50:41 +00:00
Jamie Tanna 8278ce5370 docs(constraints): document the possible constraints and installTools (#42837)
* docs(constraints): list the possible `constraints` and `installTools`

Now we have a stronger type for what a valid tool constraint is, and
what additional constraints are, we should be very explicit with what
each option is, and specify them in the `constraints` as well as our
`installTools` docs.

* test: add coverage

Co-authored-by: Claude Sonnet 4.6 <jamie.tanna+claude-code@mend.io>

---------

Co-authored-by: Claude Sonnet 4.6 <jamie.tanna+claude-code@mend.io>
2026-04-26 16:13:09 +00:00
Jamie Tanna 1044a80642 chore(types): add a strong type for ToolName and ConstraintName (#42589)
* chore(types): add a strong type for `ToolName`s

Until #41849, we can use our local definitions of the tool names that
Containerbase supports by extracting out a `ToolName` type.

* fixup! chore(types): add a strong type for `ToolName`s

Co-authored-by: Claude Opus 4.6 <jamie.tanna+claude-code@mend.io>
Co-authored-by: gpt-4.1 <jamie.tanna+github-copilot@mend.io>

* fixup! fixup! chore(types): add a strong type for `ToolName`s

* no-never

* simplify

* coverage

* sq

* warn

* sq

* fixup! sq

* sq

* fixup! sq

---------

Co-authored-by: Claude Opus 4.6 <jamie.tanna+claude-code@mend.io>
Co-authored-by: gpt-4.1 <jamie.tanna+github-copilot@mend.io>
2026-04-14 08:55:42 +00:00
Sergei Zharinov 930cf6633c refactor: Rewrite imports with .ts extensions (#40700)
fix: Additional vi.mock path corrections and prettier formatting
2026-01-26 22:48:17 +00:00
Jamie Tanna eda8991a7d fix(util/exec): remove hash for Containerbase installs (#40234)
After recent changes to remove `shell: true`, it's clear from #40231
that this breaks Containerbase's installing of tools, as we use the
`hash` shell built-in.

As we no longer need the `hash` call, we can remove it.
2025-12-31 12:51:09 +00:00
Michael Kriese 19c115c813 test: cleanup (#34785) 2025-03-13 17:52:09 +00:00
Michael Kriese 997c23502e test: migrate to vitest (#34475)
Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com>
2025-02-26 09:35:54 +00:00
RahulGautamSingh 290e15752e fix(containerbase): support ranges in flutter and dart sdks (#26535) 2024-01-07 13:11:57 +00:00
Michael Kriese 591b572eda feat(pip_requirements): allow override hashin constraints (#26037) 2023-11-29 18:17:39 +00:00
Sergei Zharinov b69416ce17 refactor(prettier): Force trailing commas (#25631) 2023-11-07 15:50:29 +00:00
Rhys Arkins c7832e55f8 feat!: remove BUILDPACK env support 2023-07-04 19:21:52 +02:00
Michael Kriese 7c04604b87 fix(cargo): use semver versioning to limit allowed versions (#19140) 2022-11-28 10:59:10 +01:00
Rhys Arkins 95339bde33 refactor: use containerbase terminology (#18023) 2022-09-28 17:09:28 +02:00
Rhys Arkins ee6287971d refactor: use containerbase not buildpack terminology (#17398) 2022-08-25 06:59:55 +00:00