Skip to content

Commit

Permalink
Merge branch 'main' into feat-23410
Browse files Browse the repository at this point in the history
* main:
  docs(versioning): fix types and tests (renovatebot#33958)
  feat(gitlab): add branch status check attemps (renovatebot#32692)
  feat(versioning): aws-eks-addon versioning added (renovatebot#33301)
  feat(nix): rework to work with all flake inputs (renovatebot#31921)
  fix(deps): update dependency mkdocs-material to v9.6.1 (renovatebot#33956)
  fix(deps): update dependency mkdocs-material to v9.6.0 (renovatebot#33955)
  fix(deps): update ghcr.io/renovatebot/base-image docker tag to v9.38.3 (renovatebot#33954)
  fix(deps): update ghcr.io/renovatebot/base-image docker tag to v9.38.2 (renovatebot#33953)
  feat(logger): Add `withMeta` helper (renovatebot#33948)
  feat(schema): Add logging utilities for catch calls (renovatebot#33950)
  • Loading branch information
ivankatliarchuk committed Jan 31, 2025
2 parents 5eda62a + 7819d02 commit 568d2aa
Show file tree
Hide file tree
Showing 22 changed files with 1,243 additions and 117 deletions.
9 changes: 9 additions & 0 deletions docs/usage/self-hosted-experimental.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ The formula for the delay between attempts is `RENOVATE_X_GITLAB_MERGE_REQUEST_D

Default value: `5` (attempts results in max. 13.75 seconds timeout).

## `RENOVATE_X_GITLAB_BRANCH_STATUS_CHECK_ATTEMPTS`

If set to a positive integer, Renovate will use this as the number of attempts to check branch status before trying to add a status check.
The delay between attempts is `RENOVATE_X_GITLAB_BRANCH_STATUS_DELAY` milliseconds.

Default value: `2` (attempts results in maximum 2 seconds timeout).

!!! warning Increasing this value too much penalizes projects that do not have defined pipelines, Renovate will systematically wait `RENOVATE_X_GITLAB_BRANCH_STATUS_CHECK_ATTEMPTS * RENOVATE_X_GITLAB_BRANCH_STATUS_DELAY` milliseconds on these projects and slow down the Renovate analyzes.

## `RENOVATE_X_GITLAB_BRANCH_STATUS_DELAY`

Adjust default time (in milliseconds) given to GitLab to create pipelines for a commit pushed by Renovate.
Expand Down
38 changes: 38 additions & 0 deletions lib/logger/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
removeMeta,
setContext,
setMeta,
withMeta,
} from '.';

const initialContext = 'initial_context';
Expand Down Expand Up @@ -121,6 +122,43 @@ describe('logger/index', () => {
);
expect(bunyanDebugSpy).toHaveBeenCalledTimes(2);
});

it('withMeta adds and removes metadata correctly', () => {
const logMeta = { foo: 'foo' };
const tempMeta = { bar: 'bar' };

withMeta(tempMeta, () => {
logger.debug(logMeta, '');
expect(bunyanDebugSpy).toHaveBeenCalledWith(
{ logContext: initialContext, ...tempMeta, ...logMeta },
'',
);
});

logger.debug(logMeta, '');
expect(bunyanDebugSpy).toHaveBeenCalledWith(
{ logContext: initialContext, ...logMeta },
'',
);
});

it('withMeta handles cleanup when callback throws', () => {
const logMeta = { foo: 'foo' };
const tempMeta = { bar: 'bar' };

expect(() =>
withMeta(tempMeta, () => {
logger.debug(logMeta, '');
throw new Error('test error');
}),
).toThrow('test error');

logger.debug(logMeta, '');
expect(bunyanDebugSpy).toHaveBeenCalledWith(
{ logContext: initialContext, ...logMeta },
'',
);
});
});

it('sets level', () => {
Expand Down
9 changes: 9 additions & 0 deletions lib/logger/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,15 @@ export function removeMeta(fields: string[]): void {
loggerInternal.removeMeta(fields);
}

export function withMeta<T>(obj: Record<string, unknown>, cb: () => T): T {
setMeta(obj);
try {
return cb();
} finally {
removeMeta(Object.keys(obj));
}
}

export /* istanbul ignore next */ function addStream(
stream: bunyan.Stream,
): void {
Expand Down
19 changes: 10 additions & 9 deletions lib/modules/manager/composer/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import { z } from 'zod';
import { logger } from '../../../logger';
import { readLocalFile } from '../../../util/fs';
import { regEx } from '../../../util/regex';
import { Json, LooseArray, LooseRecord } from '../../../util/schema-utils';
import {
Json,
LooseArray,
LooseRecord,
withDebugMessage,
} from '../../../util/schema-utils';
import { BitbucketTagsDatasource } from '../../datasource/bitbucket-tags';
import { GitTagsDatasource } from '../../datasource/git-tags';
import { GithubTagsDatasource } from '../../datasource/github-tags';
Expand Down Expand Up @@ -126,10 +131,7 @@ export type ReposArray = z.infer<typeof ReposArray>;
export const Repos = z
.union([ReposRecord, ReposArray])
.default([]) // Prevents warnings for packages without repositories field
.catch(({ error: err }) => {
logger.debug({ err }, 'Composer: invalid "repositories" field');
return [];
})
.catch(withDebugMessage([], 'Composer: invalid "repositories" field'))
.transform((repos) => {
let packagist = true;
const repoUrls: string[] = [];
Expand Down Expand Up @@ -242,10 +244,9 @@ export const ComposerExtract = z
.pipe(Json)
.pipe(Lockfile)
.nullable()
.catch(({ error: err }) => {
logger.debug({ err }, 'Composer: lockfile parsing error');
return null;
}),
.catch(
withDebugMessage(null, 'Composer: lockfile parsing error'),
),
]),
),
}),
Expand Down
Loading

0 comments on commit 568d2aa

Please sign in to comment.