Commit Graph

52 Commits

Author SHA1 Message Date
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
Sebastian Poxhofer 171a591d84 feat(git): validate commit shas (#43988)
* feat(git): validate length commit shas

* test: adapt test mocks

* chore: update import paths

* feat(git): make the validation more strict and support repositories using sha256

* test: add fakeSha function for deterministic git commit shas in tests
2026-06-15 06:36:57 +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
RahulGautamSingh bc7d0595d0 feat(config): managerFilePatterns (#34615)
Co-authored-by: Sebastian Poxhofer <secustor@users.noreply.github.com>
Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
Co-authored-by: Rhys Arkins <rhys@arkins.net>
2025-05-04 08:30:24 +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
Sebastian Poxhofer 3681b2a945 chore: eslint to enforce for typed imports (#30844) 2024-08-19 13:15:27 +00:00
renovate[bot] eb8c08079e chore(deps): update typescript-eslint monorepo to v8 (major) (#30750)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2024-08-14 10:33:02 +00:00
Sigurd Spieckermann e5f4a1e065 test(git): enhance commit signing tests (#30396)
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2024-07-26 10:35:49 +00:00
Sergei Zharinov b69416ce17 refactor(prettier): Force trailing commas (#25631) 2023-11-07 15:50:29 +00:00
Michael Kriese 84a97a62fa test(perf): improve test speed (#24323) 2023-09-08 11:40:04 +00:00
Rhys Arkins 36e2b328bb chore: update types reference 2023-08-15 11:31:15 +02:00
RahulGautamSingh 932012fa20 refactor(test): fix getConfig imports (#22819) 2023-06-16 17:57:34 +00:00
renovate[bot] 8bdae52772 chore(deps): update dependency @types/node to v18.16.1 (#21940)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2023-05-03 05:12:42 +00:00
Jamie Magee 176282e65f chore: use node: protocol imports (#21181) 2023-03-28 21:05:36 +00:00
RahulGautamSingh 352c9db904 test: add new wrapper for partial (#20618) 2023-02-25 06:46:32 +00:00
Markus Schulz dd6c8e5147 feat: Move some Git commands behind a PlatformScm interface (#19327)
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2023-02-22 08:18:53 +00:00
Mathieu Kniewallner 7cf131021a feat(presets/regex-managers): allow 'actions' in GitHub Actions preset (#19966) 2023-01-23 16:32:13 +00:00
RahulGautamSingh d6d9ee719d fix: make baseBranch type non-optional in BranchConfig (#17920)
Co-authored-by: Rhys Arkins <rhys@arkins.net>
2022-10-10 08:38:31 +02:00
renovate[bot] 582f77371c chore(deps): update jest monorepo (#17737)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2022-09-12 16:58:52 +02:00
Michael Kriese 4c52a27d83 test: modernize code (#17470)
Co-authored-by: Jamie Magee <jamie.magee@gmail.com>
2022-08-30 06:14:57 +00:00
Jamie Magee 3589d0e222 refactor: remove deprecated loadFixture calls (#16404)
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2022-07-04 04:18:53 +00:00
Michael Kriese 47385421e4 test: deprecate old loads fixtures functions (#15539) 2022-05-11 07:19:34 +00:00
Michael Kriese 5cf9123017 refactor: more strict null checks (#15140) 2022-04-16 06:32:17 +00:00
Rhys Arkins dca3418bbd refactor: lib/modules (#14488)
Moves datasource, manager, platform and versioning code from lib/ into new lib/modules/

BREAKING CHANGE: External tools must update paths to datasource, manager, platform and versioning
2022-03-04 09:04:02 +01:00
Oleg Krivtsov 6604de3aeb feat(manager/nuget): migrate fs.readFile to fs.readLocalFile (#14234)
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2022-02-25 11:07:31 +01:00
Michael Kriese 8dc4e6fbcc chore: fix type export (#13231) 2021-12-22 09:27:24 +01:00
Masaki Hara 48acb427b7 feat(rubygems): support GitHub Packages (#11107) 2021-08-20 04:24:48 +00:00
Sergei Zharinov 5f4b9f9a3a test: Fix test descriptions and enforce it via new linting rule (#11285) 2021-08-18 05:46:56 +00:00
Anbraten 7eb2c09b6e feat: pnpm workspaces (#10071) 2021-05-22 12:32:19 +00:00
renovate[bot] b8e36daa87 chore(deps): update dependency prettier to v2.3.0 (#10012)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Rhys Arkins <rhys@arkins.net>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2021-05-17 08:06:24 +00:00
Sergei Zharinov ce51f05cef feat(test): Detect test utils callers and simplify helpers (#9707) 2021-04-26 16:15:03 +02:00
Sergei Zharinov b255275632 refactor(test): Load fixtures with helpers (#9699)
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2021-04-23 16:58:48 +00:00
Sergei Zharinov b957d4afb7 refactor(config): Extract interfaces from "index.ts" to separate "types.ts" (#9629) 2021-04-20 10:52:57 +02:00
Florian Greinacher 71cf56eaf9 feat(dependency-dashboard): display logged repository problems (#6952)
Co-authored-by: Rhys Arkins <rhys@arkins.net>
2020-09-21 22:04:11 +02:00
Michael Kriese 6474dd49e5 chore: lint fixes (#7018)
Co-authored-by: Rhys Arkins <rhys@arkins.net>
2020-08-19 06:46:00 +02:00
Sergio Zharinov 1137112130 refactor: Separate 'git' and 'fs' util modules (#6665) 2020-07-03 16:47:00 +02:00
Sergio Zharinov 679176f26e test(git): Decouple 'gitfs/fs' and 'gitfs/git' in tests (#6661) 2020-07-03 15:08:16 +02:00
Rhys Arkins ec1598587c refactor: move util/fs under util/gitfs (#6618) 2020-06-28 11:57:57 +02:00
Michael Kriese df96e52417 test: cleanup mocking (#6322) 2020-05-25 16:26:09 +02:00
Michael Kriese ca71eddbdb test(gradle-wrapper): add mock test (#6233) 2020-05-15 13:30:36 +02:00
Rhys Arkins cc980cfd23 refactor: platform.getFile -> fs.readLocalFile (#6131) 2020-05-11 15:36:09 +02:00
Rhys Arkins 53ca91301f chore: import linting (#6105) 2020-05-01 18:03:48 +02:00
Michael Kriese da0181e074 fix: do not coerce gradle version (#5991) 2020-04-17 14:10:08 +02:00
renovate[bot] 4f59b62da4 chore(deps): update dependency prettier to v2 (#5952)
* chore(deps): update dependency prettier to v2

* Run prettier-fix

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Jamie Magee <jamie.magee@gmail.com>
2020-04-12 18:09:36 +02:00
Jamie Magee d4f6aa4bc5 fix: add missing await statements (#5918)
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2020-04-09 12:47:48 +02:00
Joshua Gleitze a323cf03b3 test(gradle): stop mocking the file system (#5826) 2020-04-03 09:44:32 +02:00
Michael Kriese e779d895f7 test(coverage): lib/config (#5656) 2020-03-07 11:27:10 +01:00
Michael Kriese eed923076f chore(test): fix gitlab tests (#5292) 2020-02-03 21:19:42 +01:00
Michael Kriese aae2519b0c fix(ts): convert worker/repository/init to typescript (#4975) 2019-12-17 07:56:42 +02:00