Commit Graph

114 Commits

Author SHA1 Message Date
RahulGautamSingh 9cecb86eca feat(config): add experimental exitCodeForErrors option (#45752)
* feat(config): add experimental exitCodeForErrors option

* feat(config): give unknown-error its own exit code

* docs: restore exit codes 1 and 2 to the table
2026-09-10 11:07:26 +00:00
Sebastian Poxhofer b2d3b64c48 refactor(lint): enforce err key for errors in logger metadata (#45759)
* refactor(lint): enforce err key for errors in logger metadata

* refactor(lint): flag error message and stack strings in logger-err-key
2026-09-09 13:55:14 +00:00
Sebastian Poxhofer 8d08b51db0 refactor: return a RepositoryResult while onboarding (#45531)
* refactor(onboarding): return repository result from ensureOnboarding

Rename ensureOnboardingPr to ensureOnboarding and have it return a new
'onboarding' RepositoryResult. renovateRepository now branches on
repoIsOnboarded, so exactly one of ensureOnboarding/updateRepo produces
the repository result and the non-null assertion on the update result
(TODO #22198) is no longer needed. updateRepo/update no longer return
undefined for non-onboarded repositories.

* refactor(onboarding): keep ensureOnboardingPr name
2026-08-28 11:50:28 +00:00
Sebastian Poxhofer a473e73b3e fix(linters): forbid inert counts in v8 coverage-ignore comments (#45287)
Adds a custom oxlint rule renovate/v8-ignore-no-count that flags the
count form '/* v8 ignore next <N> */'. The count is not honored by
vitest's ast-v8-to-istanbul hint parser, which captures only the
keyword (if/else/next/file); 'next' always exempts exactly the next
AST node. Trailing counts therefore suggest a line range that is never
applied and mislead readers.

The rule is autofixable (drops the count, preserving actual behavior)
and has been applied to all existing occurrences.
2026-08-22 11:25:31 +00:00
Sebastian Poxhofer 716baf630b fix(linters): add rules for filesystem helpers and Date (#44685)
* feat(lint): add renovate/prefer-fs-util and renovate/prefer-luxon rules

Two shared-util substitution rules, both at warn level:

- renovate/prefer-fs-util flags value imports of fs, node:fs,
  fs/promises, node:fs/promises, fs-extra and fs-extra/esm in lib/
  source files outside lib/util/fs/, pointing to the scoped helpers
  from lib/util/fs. Spec files and type-only imports are exempt.
  A config-only change via no-restricted-imports was considered but
  rejected: that rule is at error severity globally and per-path warn
  severity is not expressible, so the 13 existing call sites would
  break the baseline.

- renovate/prefer-luxon flags new Date(...) and Date.now() in lib/
  source files, pointing to Luxon per best-practices. Date/time
  utility modules (lib/util/date, lib/util/pretty-time,
  lib/util/timestamp) and spec files (vi.setSystemTime etc.) are
  exempt.

Baseline: 13 prefer-fs-util and 45 prefer-luxon warnings, zero errors.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* refactor: use Luxon instead of new Date() at remaining call sites

Fixes all renovate/prefer-luxon violations for `new Date(...)`:

- `new Date().toISOString()` -> `DateTime.utc().toISO()` (byte-identical
  output) in the http cache provider, schedule logging and PR cache.
- `new Date()` -> `DateTime.now().toJSDate()` for the git commit-date
  fallback and the rubygems `syncedAt` markers (same `Date` values).
- rust-release-channel now computes the Rust 1.0 release date and nightly
  version dates via `DateTime.utc(...)`; previously `new Date(y, m, d)`
  used the local timezone while the epoch used UTC, so the comparison was
  timezone-dependent at the boundary date. Tests run with TZ=UTC, where
  behavior is unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* refactor: use lib/util/fs helpers in repository worker

Fixes renovate/prefer-fs-util violations outside bootstrap code:

- `fs.ensureDir()` -> `ensureDir()` from lib/util/fs (same fs-extra call
  underneath; it no-ops on an empty dir name, so the repository worker
  spec now simulates the init failure via a rejected `initRepo` instead
  of relying on `fs.ensureDir('')` throwing).
- `fs.remove(privateCacheDir())` -> `cachePathExists()` + `rmCache()`,
  keeping the remove-if-present semantics while asserting cacheDir
  containment.

Two call sites keep raw imports with reasoned disable comments:

- lib/util/modules.ts synchronously enumerates Renovate's own installed
  module directories at import time.
- lib/util/cache/package/impl/sqlite.ts receives cacheDir as an explicit
  argument during global initialization, before GlobalConfig (which the
  scoped cache helpers resolve against) contains cacheDir.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* feat(lint): promote prefer-fs-util and prefer-luxon to error

Both rules are narrowed to what is actually accepted practice before
being promoted:

prefer-luxon no longer flags `Date.now()`: it returns UTC-based epoch
milliseconds used for elapsed-time measurement and TTL arithmetic, which
is timezone-independent by construction. The mined reviewer feedback
behind this rule ("use Luxon for date arithmetic outside util") targets
timezone-dependent date construction/formatting, which cannot occur with
a raw millis number; the rule keeps flagging `new Date(...)`.

prefer-fs-util exempts code that legitimately needs raw fs access
because the scoped lib/util/fs helpers resolve against GlobalConfig
localDir/cacheDir, which does not exist yet or does not apply there:

- lib/logger/: log-file streams at user-configured system paths during
  bootstrap; lib/util/fs also depends on the logger (import cycle).
- lib/workers/global/: creates baseDir/cacheDir themselves and
  reads/writes user-supplied paths before GlobalConfig is seeded.
- lib/config-validator.ts: standalone CLI without GlobalConfig.
- lib/util/git/: owns the localDir lifecycle (clone, emptyDir, symlinks)
  and private-key files with sync cleanup on process exit.

Also fixes a pre-existing tsc error in prefer-fs-util.js: `importKind`
is a TypeScript-ESTree extension missing from eslint's base AST types.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* refactor(fs): make rmCache ignore missing paths

All rmCache callers use it for cleanup, where a missing path is a
no-op, so bake force: true in instead of guarding call sites with
an existence check.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* refactor(linters): exempt lib/instrumentation from prefer-fs-util

`lib/instrumentation/file-exporter.ts` landed on main while this branch
was open and imports `node:fs/promises` directly.

The exporter writes to a user-configured system path
(`RENOVATE_TRACING_FILE_EXPORTER_PATH`) outside `localDir`/`cacheDir`,
so the scoped helpers do not apply. `lib/instrumentation` is also
deliberately kept out of the module graph of instrumented libraries
(see the `⚠️` note in `lib/renovate.ts`), so it must not pull in
`lib/util/fs` and its config/logger dependencies. Exempt the directory,
as is already done for `lib/logger`.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* docs: shorten doc

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-25 16:00:44 +00:00
Jamie Tanna 8fa3d5b4fc fix(workers/repository): don't re-process init error (#43745)
When the `init` phase encounters an error, we're currently processing it
twice.

This leads to "Action Required" Issues losing any error context (as only
the `errorRes`, not the full `error` is returned), making them much less
useful.

We can refactor to:

- not duplicate the handling
- pass around the full `error` so we can log it outside of the `init`
  phase

As noted in #43558.
2026-06-02 17:02:43 +00:00
Sebastian Poxhofer 73b90e958b refactor: remove string concetation for production code (#43442)
refactor: prefer templates rather than `+`
2026-05-19 13:31:27 +00:00
Jamie Tanna ff6761ed23 fix(config/global): return default values for GlobalConfig.get (#42113)
* fix(config/global): return default values for `GlobalConfig.get`

As noted in #39949, it can be awkward working with in `GlobalConfig.get`, where
we would previously need to specify the default value when calling `.get`,
which could lead to drift with the defaults for a given config option.

To reduce this risk, we can rely on a given `default` for a configuration
option, providing that as a default.

Because this now definitely returns a value that matches the config option, it
now allows us to remove `!` assertions.

* fixup! fix(config/global): return default values for `GlobalConfig.get`

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

* fixup! fix(config/global): return default values for `GlobalConfig.get`

* test(presets): remove impossible test

As it's now not possible to set a value as `undefined` (as
`GlobalConfig` will then use the default), this test no longer validates
anything.

* test(workers/repository): add mock

Now `platform` defaults to `github`, we need to mock out the call to
fetch config.

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

* test: coverage

* test: coverage

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <jamie.tanna+claude-code@mend.io>
2026-05-15 17:10:38 +00:00
Mike Ryan f635ae29c4 chore(instrumentation): add timing statistics for getReleases (#42523)
* feat: timing statistics for getReleases

Adds collection and reporting of timing statistics for
`datasource.getReleases()` calls. Each call records the datasource, registryUrl,
packageName, and duration. The intent is to visibility into where
renovate is retrieving release information and how long that might take.

The report consists of a nested data-structure that provides increasing
detail as we descend datasource, registryUrl, and packageName.

The full report  is logged at trace level
`getReleases statistics with packages`.

A summary report including only datasources and registryUrls is logged
at debug level `getReleases statistics summary`.

* add GetReleasesSpanProcessor

- Re-instrument getReleases calls using open telemetry.
- Adds GetReleasesSpanProcessor, which can adapt
  `getReleases` spans to GetReleasesStats.

* fixup instrumentation tests

* pr feedback

* pr feedback: naming

* pr feedback: comments
2026-04-14 17:36:37 +00:00
RahulGautamSingh 7a8dcdbd01 refactor(config/inherit): move onboardingBranch to InheritConfig (#40865)
* move onboardingBranch to InheritConfig

* fix lint issue

* fix import order

* more fixrs

* fix import

* fix imports
2026-02-15 08:17:11 +00:00
Sergei Zharinov 2b0e80b884 feat!: Switch to ESM modules (#40756) 2026-01-29 14:21:41 +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 58d6f4125b fix(types): make result a strong type (#39783)
As a way to make it more predictable what the possible states the
`result` in a given `Repository finished` log message can be, we can
wrap these into a type.

This requires a slight refactor where these are used to make sure that
Typescript is happy with the value being returned.

We can capture the common groups of errors (which are then present as a
`RepositoryResult`) and expose that to be used.
2025-12-08 18:17:54 +00:00
Jamie Tanna b5cd0317cf fix(git): report Git operation statistics at end of run (#39596)
Now we have instrumented our Git operations with tracing, we can make
sure that users who are not using OpenTelemetry still get insights into
their Git operation usage using a debug log output.

Following how other insights are produced, we can introduce a new type
in `lib/util/stats` for `GitOperationStats`, which will track the
overall execution for each operation type, and output them in the same
style as we use for other timing reports.

At the end of a Renovate run, we'll then make sure that this is logged
into a debug log for further investigation.

To create the report, we can make sure that we introduce a new
OpenTelemetry `SpanProcessor`, which will run when we end our Run, and
store any Git operations in `GitOperationStats`.

This adapts code from GPT-4.1 and code from [0].

Co-authored-by: gpt-4.1 <jamie.tanna+github-copilot@mend.io>

[0]: https://github.com/yurisouza/monitoria-sdk/blob/ca9d751fa7c3a785a04f87b8966bb782b4617021/src/adapters/nestjs/span-duration-tracker.ts#L18-L27
2025-12-01 15:53:26 +00:00
Jamie Tanna c1a8da0275 fix(instrumentation): correctly instrument extract and lookup (#39611)
When calling `extractDependencies`, we actually perform both `extract`
and `lookup` splits. However, we are instrumenting the whole method call
as the `extract` split, which results in incorrect tracing data.

To correct this, we can wrap the specific code responsible for the
extraction into `extract`, and then the separate code for `lookup`
accordingly.

This also makes sure that `emptyExtract` sets repository splits.
2025-11-28 13:47:29 +00:00
Jamie Tanna ce729a84c4 chore(telemetry): add span attribute for splits (#38633)
As part of a step towards better OpenTelemetry instrumentation as part
of #38609, we can start by introducing a known span attribute for the
repository "split" we're currently processing.

This requires a slight refactor of the `SpanOptions`, to use our custom
type, which enforces the `RenovateSplit` type when using the span name.

This adds it into each of the splits we currently instrument.

Co-authored-by: secustor <sebastian@poxhofer.at>
2025-11-28 12:32:00 +00:00
Jamie Tanna 1ec6ea4011 chore(instrumentation): instrument empty extraction (#38845)
To make sure that we're always providing a trace for the `extract`
split, we should instrument, regardless of whether it's a no-op.
2025-10-25 11:49:05 +00:00
RahulGautamSingh e148b9986e fix(workers): do not swallow init error (#38764) 2025-10-21 07:44:40 +00:00
Jamie Tanna a62837ae95 chore(instrumentation): instrument the init repo split (#38607)
As part of a step towards better OpenTelemetry instrumentation as part
of #38609, we need to capture the `init` repository split, as the other
splits are currently instrumented.

Note that we've duplicated the error handling, as the `localDir` may be
unset, and we need to handle it.
2025-10-20 08:18:56 +00:00
Jamie Tanna 65d7080920 chore: add Repository Result metadata to "Repository Finished" log (#37089)
chore: add Repository Result metadata to log messages

The `Repository result` log message is useful for understanding
at-a-glance why a Renovate run may have not worked.

Adding the metadata that currently exists in the log line as Meta keys
would allow for logging tools to be able to more meaningfully
interpolate the data, without requiring parsing of the underlying
string.

Co-authored-by: Jamie Tanna <jamie.tanna@elastic.co>
2025-10-07 14:48:38 +00:00
RahulGautamSingh 5adb95593f feat(config): variables (#35350) 2025-07-06 07:24:33 +00:00
RahulGautamSingh 326cfb5b0d feat: interactive reconfigure pr (#34696)
Co-authored-by: Rhys Arkins <rhys@arkins.net>
2025-06-15 22:04:26 +00:00
Sergei Zharinov a02dd076df feat: Abandoned packages logging (#36090)
Co-authored-by: Rhys Arkins <rhys@arkins.net>
Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com>
2025-05-23 05:31:04 +00:00
Sergei Zharinov f977700649 feat(http): Switch to memory cache provider (#33901)
Co-authored-by: Rhys Arkins <rhys@arkins.net>
2025-03-24 08:02:47 +00:00
RahulGautamSingh 499ea9c747 feat(dashboard): on demand config migration (#31129)
Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com>
Co-authored-by: Rhys Arkins <rhys@arkins.net>
Co-authored-by: Sergei Zharinov <zharinov@users.noreply.github.com>
2024-10-17 12:44:55 +00:00
Sebastian Poxhofer 3681b2a945 chore: eslint to enforce for typed imports (#30844) 2024-08-19 13:15:27 +00:00
RahulGautamSingh f06b4bb9cd refactor: move config migration logic (#30801) 2024-08-15 10:23:12 +00:00
Sergei Zharinov 7229d962f7 feat: Stats for datasource cache (#30623) 2024-08-11 08:07:16 +00:00
RahulGautamSingh 2eb7c76027 feat(http)!: remove dnsCache option (#29449)
BREAKING CHANGE: dnsCache is now removed
2024-07-25 15:28:16 +02:00
Sebastian Poxhofer 481aa216b2 feat(instrumentation/reporting): add report option (#26087)
Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2024-03-17 09:22:42 +00:00
Sergei Zharinov 5d7372f917 feat: Http cache stats (#27956) 2024-03-16 13:17:10 +00:00
Sergei Zharinov fd8684ba6e refactor: Extract "HttpStats" utility class (#27944) 2024-03-15 12:39:31 +00:00
Sergei Zharinov 998705d5b0 refactor: Package cache stats utility (#27936) 2024-03-14 15:06:53 +00:00
Sergei Zharinov 9c06813697 refactor: Create utility for stats collection and reporting (#27919) 2024-03-14 09:46:56 +00:00
Sergei Zharinov c30a4b0b54 feat(logger): Log level remapping (#26951)
Co-authored-by: Rhys Arkins <rhys@arkins.net>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2024-02-16 20:06:11 +00:00
Sergei Zharinov b69416ce17 refactor(prettier): Force trailing commas (#25631) 2023-11-07 15:50:29 +00:00
Sergei Zharinov 6f7ac34a2f fix: Type errors (#24108) 2023-08-27 08:13:10 +00:00
Philip 0a47657451 feat: Enhance lookup logs with repository problems (#23896)
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2023-08-25 08:22:14 +00:00
HonkingGoose 951f3d87b9 refactor: replace verb renovating with plain English (#23408)
Co-authored-by: Rhys Arkins <rhys@arkins.net>
2023-08-24 13:07:30 +00:00
Rhys Arkins ba8c2bab83 fix: Revert "feat: Enhance lookup logs to show branches extended info" (#23988) 2023-08-21 12:26:10 +02:00
Rhys Arkins 36e2b328bb chore: update types reference 2023-08-15 11:31:15 +02:00
Philip fe039fea63 feat: Enhance lookup logs to show branches extended info (#23696)
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2023-08-14 07:19:04 +00:00
RahulGautamSingh fa6e5df805 feat(onboarding): skip processing onboarding branch (#22490)
Co-authored-by: Rhys Arkins <rhys@arkins.net>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2023-06-21 10:55:57 +00:00
Sergei Zharinov 8081d08ec4 refactor(http): Enhanced integration with data schemas (#21338) 2023-04-06 15:56:27 +00:00
HonkingGoose 6a446499f7 refactor: rename finalise to finalize (#21278) 2023-04-01 10:00:42 +00:00
Rhys Arkins 03618ee581 feat: autoclose PRs when repo disabled (#21263)
Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com>
2023-04-01 05:42:08 +00:00
Rhys Arkins a3cc159f7e chore: extract and lookup duration logging (#20816) 2023-03-09 11:24:50 +00:00
Gabriel-Ladzaretti de289bb409 feat(core/onboarding): support manual rebase/retry (#17633)
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2023-01-11 14:59:08 +01:00
Rhys Arkins ef7f520240 fix(cache): reset semanticCommits after clone (#19457) 2022-12-17 06:24:03 +00:00
Sergei Zharinov b2d18d1110 feat(http): maxRequestsPerSecond (#18325) 2022-10-25 11:03:19 +00:00