Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: internalChecksAsSuccess #20572

Merged
merged 44 commits into from
Mar 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
26acf2c
feat(config)!: add new option `constraintsFiltering` (#19992)
RahulGautamSingh Jan 28, 2023
dfd52ac
feat!: default to rangeStrategy=auto, prefer update-lockfile (#19942)
rarkins Jan 28, 2023
8214646
feat(config)!: non-zero defaults for PR concurrent, hourly limits (#1…
rarkins Jan 28, 2023
4bdd48c
feat(cache): default cacheHardTtlMinutes to 24 hours (#20079)
rarkins Jan 28, 2023
895cc26
feat(go)!: default GOPROXY (#20081)
rarkins Jan 29, 2023
8846efe
fix(regex): don’t escape forward slash in fileMatch (#19314)
rarkins Jan 30, 2023
62db658
feat(cache): file cache cleanup (#20061)
rarkins Feb 1, 2023
f320601
feat(config): default `dockerImagePrefix` to `containerbase` (#20150)
viceice Feb 1, 2023
6e8c6c6
chore: fix artifacts tests
rarkins Feb 11, 2023
c24ed82
fix(versioning)!: bump short ranges to version (#20494)
rarkins Feb 20, 2023
b0f8f6f
refactor!: use packageName and not depName for datasource lookups (#2…
rarkins Feb 21, 2023
fd06afa
feat!: internalChecksAsSuccess
rarkins Feb 22, 2023
eaea772
Update lib/modules/platform/github/index.ts
rarkins Feb 22, 2023
826545d
review updates
rarkins Feb 22, 2023
9603edc
shorten ifs
rarkins Feb 22, 2023
a42fe41
feat(config)!: add new option `constraintsFiltering` (#19992)
RahulGautamSingh Jan 28, 2023
ffbf279
feat!: default to rangeStrategy=auto, prefer update-lockfile (#19942)
rarkins Jan 28, 2023
b784f61
feat(config)!: non-zero defaults for PR concurrent, hourly limits (#1…
rarkins Jan 28, 2023
0c681f7
feat(cache): default cacheHardTtlMinutes to 24 hours (#20079)
rarkins Jan 28, 2023
1b58035
feat(go)!: default GOPROXY (#20081)
rarkins Jan 29, 2023
885ce79
fix(regex): don’t escape forward slash in fileMatch (#19314)
rarkins Jan 30, 2023
88cb161
feat(cache): file cache cleanup (#20061)
rarkins Feb 1, 2023
81c0531
feat(config): default `dockerImagePrefix` to `containerbase` (#20150)
viceice Feb 1, 2023
3a7597b
chore: fix artifacts tests
rarkins Feb 11, 2023
9fbe4a2
fix(versioning)!: bump short ranges to version (#20494)
rarkins Feb 20, 2023
0592942
refactor!: use packageName and not depName for datasource lookups (#2…
rarkins Feb 21, 2023
fd279f0
feat!: update `github-releases` datasource digest computation to use …
devversion Feb 22, 2023
b2ae684
Merge branch 'v35' into feat/7800-internalChecksAsSuccess
rarkins Feb 23, 2023
3125af9
feat(config)!: add new option `constraintsFiltering` (#19992)
RahulGautamSingh Jan 28, 2023
ab17816
feat!: default to rangeStrategy=auto, prefer update-lockfile (#19942)
rarkins Jan 28, 2023
46ca5a4
feat(config)!: non-zero defaults for PR concurrent, hourly limits (#1…
rarkins Jan 28, 2023
f4adef9
feat(cache): default cacheHardTtlMinutes to 24 hours (#20079)
rarkins Jan 28, 2023
0282067
feat(go)!: default GOPROXY (#20081)
rarkins Jan 29, 2023
333f5c2
fix(regex): don’t escape forward slash in fileMatch (#19314)
rarkins Jan 30, 2023
34e4fa7
feat(cache): file cache cleanup (#20061)
rarkins Feb 1, 2023
550afb1
feat(config): default `dockerImagePrefix` to `containerbase` (#20150)
viceice Feb 1, 2023
feeefe1
chore: fix artifacts tests
rarkins Feb 11, 2023
0ac2bf6
fix(versioning)!: bump short ranges to version (#20494)
rarkins Feb 20, 2023
6474aa6
refactor!: use packageName and not depName for datasource lookups (#2…
rarkins Feb 21, 2023
612ab32
feat!: update `github-releases` datasource digest computation to use …
devversion Feb 22, 2023
491f0eb
feat!: default to semver-coerced instead of semver (#20573)
secustor Feb 25, 2023
ff39531
Merge branch 'v35' into feat/7800-internalChecksAsSuccess
rarkins Mar 4, 2023
a0e4ce6
Merge branch 'v35' into feat/7800-internalChecksAsSuccess
rarkins Mar 4, 2023
e574db2
Merge branch 'v35' into feat/7800-internalChecksAsSuccess
rarkins Mar 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/usage/configuration-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -1432,6 +1432,16 @@ If you wish for Renovate to process only select paths in the repository, use `in
Alternatively, if you need to just _exclude_ certain paths in the repository then consider `ignorePaths` instead.
If you are more interested in including only certain package managers (e.g. `npm`), then consider `enabledManagers` instead.

## internalChecksAsSuccess

By default, internal Renovate checks such as `renovate/stability-days` are not counted towards a branch being "green" or not.
This is primarily to prevent automerge when the only check is a passing Renovate check.

Internal checks will always be counted/considered if they are in pending or failed states.
If there are multiple passing checks for a branch, including non-Renovate ones, then this setting won't make any difference.

Change this setting to `true` if you want to use internal Renovate checks towards a passing branch result.

## internalChecksFilter

This setting determines whether Renovate controls when and how filtering of internal checks are performed, particularly when multiple versions of the same update type are available.
Expand Down
7 changes: 7 additions & 0 deletions lib/config/options/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1547,6 +1547,13 @@ const options: RenovateOptions[] = [
type: 'integer',
default: 0,
},
{
name: 'internalChecksAsSuccess',
description:
'Whether to consider passing internal checks such as stabilityDays when determining branch status.',
type: 'boolean',
default: false,
},
/*
* Undocumented experimental feature
{
Expand Down
1 change: 1 addition & 0 deletions lib/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export interface RenovateSharedConfig {
ignoreDeps?: string[];
ignorePaths?: string[];
ignoreTests?: boolean;
internalChecksAsSuccess?: boolean;
labels?: string[];
addLabels?: string[];
dependencyDashboardApproval?: boolean;
Expand Down
26 changes: 22 additions & 4 deletions lib/modules/platform/azure/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -577,10 +577,28 @@ describe('modules/platform/azure/index', () => {
]),
} as any)
);
const res = await azure.getBranchStatus('somebranch');
const res = await azure.getBranchStatus('somebranch', true);
expect(res).toBe('green');
});

it('should not treat internal checks as success', async () => {
await initRepo({ repository: 'some/repo' });
azureApi.gitApi.mockImplementationOnce(
() =>
({
getBranch: jest.fn(() => ({ commit: { commitId: 'abcd1234' } })),
getStatuses: jest.fn(() => [
{
state: GitStatusState.Succeeded,
context: { genre: 'renovate' },
},
]),
} as any)
);
const res = await azure.getBranchStatus('somebranch', false);
expect(res).toBe('yellow');
});

it('should pass through failed', async () => {
await initRepo({ repository: 'some/repo' });
azureApi.gitApi.mockImplementationOnce(
Expand All @@ -590,7 +608,7 @@ describe('modules/platform/azure/index', () => {
getStatuses: jest.fn(() => [{ state: GitStatusState.Error }]),
} as any)
);
const res = await azure.getBranchStatus('somebranch');
const res = await azure.getBranchStatus('somebranch', true);
expect(res).toBe('red');
});

Expand All @@ -603,7 +621,7 @@ describe('modules/platform/azure/index', () => {
getStatuses: jest.fn(() => [{ state: GitStatusState.Pending }]),
} as any)
);
const res = await azure.getBranchStatus('somebranch');
const res = await azure.getBranchStatus('somebranch', true);
expect(res).toBe('yellow');
});

Expand All @@ -616,7 +634,7 @@ describe('modules/platform/azure/index', () => {
getStatuses: jest.fn(() => []),
} as any)
);
const res = await azure.getBranchStatus('somebranch');
const res = await azure.getBranchStatus('somebranch', true);
expect(res).toBe('yellow');
});
});
Expand Down
16 changes: 15 additions & 1 deletion lib/modules/platform/azure/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,8 @@ export async function getBranchStatusCheck(
}

export async function getBranchStatus(
branchName: string
branchName: string,
internalChecksAsSuccess: boolean
): Promise<BranchStatus> {
logger.debug(`getBranchStatus(${branchName})`);
const statuses = await getStatusCheck(branchName);
Expand All @@ -406,6 +407,19 @@ export async function getBranchStatus(
if (noOfPending) {
return 'yellow';
}
if (
!internalChecksAsSuccess &&
statuses.every(
(status) =>
status.state === GitStatusState.Succeeded &&
status.context?.genre === 'renovate'
)
) {
logger.debug(
'Successful checks are all internal renovate/ checks, so returning "pending" branch status'
);
return 'yellow';
}
return 'green';
}

Expand Down
26 changes: 18 additions & 8 deletions lib/modules/platform/bitbucket-server/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1749,7 +1749,9 @@ Followed by some information.
failed: 0,
});

expect(await bitbucket.getBranchStatus('somebranch')).toBe('green');
expect(await bitbucket.getBranchStatus('somebranch', true)).toBe(
'green'
);
});

it('should be pending', async () => {
Expand All @@ -1764,7 +1766,9 @@ Followed by some information.
failed: 0,
});

expect(await bitbucket.getBranchStatus('somebranch')).toBe('yellow');
expect(await bitbucket.getBranchStatus('somebranch', true)).toBe(
'yellow'
);

scope
.get(
Expand All @@ -1776,7 +1780,9 @@ Followed by some information.
failed: 0,
});

expect(await bitbucket.getBranchStatus('somebranch')).toBe('yellow');
expect(await bitbucket.getBranchStatus('somebranch', true)).toBe(
'yellow'
);
});

it('should be failed', async () => {
Expand All @@ -1791,23 +1797,27 @@ Followed by some information.
failed: 1,
});

expect(await bitbucket.getBranchStatus('somebranch')).toBe('red');
expect(await bitbucket.getBranchStatus('somebranch', true)).toBe(
'red'
);

scope
.get(
`${urlPath}/rest/build-status/1.0/commits/stats/0d9c7726c3d628b7e28af234595cfd20febdbf8e`
)
.replyWithError('requst-failed');

expect(await bitbucket.getBranchStatus('somebranch')).toBe('red');
expect(await bitbucket.getBranchStatus('somebranch', true)).toBe(
'red'
);
});

it('throws repository-changed', async () => {
git.branchExists.mockReturnValue(false);
await initRepo();
await expect(bitbucket.getBranchStatus('somebranch')).rejects.toThrow(
REPOSITORY_CHANGED
);
await expect(
bitbucket.getBranchStatus('somebranch', true)
).rejects.toThrow(REPOSITORY_CHANGED);
});
});

Expand Down
39 changes: 33 additions & 6 deletions lib/modules/platform/bitbucket/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ describe('modules/platform/bitbucket/index', () => {
},
],
});
expect(await bitbucket.getBranchStatus('master')).toBe('red');
expect(await bitbucket.getBranchStatus('master', true)).toBe('red');
});

it('getBranchStatus 4', async () => {
Expand All @@ -250,7 +250,7 @@ describe('modules/platform/bitbucket/index', () => {
},
],
});
expect(await bitbucket.getBranchStatus('branch')).toBe('green');
expect(await bitbucket.getBranchStatus('branch', true)).toBe('green');
});

it('getBranchStatus 5', async () => {
Expand All @@ -275,7 +275,9 @@ describe('modules/platform/bitbucket/index', () => {
},
],
});
expect(await bitbucket.getBranchStatus('pending/branch')).toBe('yellow');
expect(await bitbucket.getBranchStatus('pending/branch', true)).toBe(
'yellow'
);
});

it('getBranchStatus 6', async () => {
Expand All @@ -297,9 +299,34 @@ describe('modules/platform/bitbucket/index', () => {
.reply(200, {
values: [],
});
expect(await bitbucket.getBranchStatus('branch-with-empty-status')).toBe(
'yellow'
);
expect(
await bitbucket.getBranchStatus('branch-with-empty-status', true)
).toBe('yellow');
});

it('getBranchStatus 7', async () => {
const scope = await initRepoMock();
scope
.get('/2.0/repositories/some/repo/refs/branches/branch')
.reply(200, {
name: 'branch',
target: {
hash: 'branch_hash',
parents: [{ hash: 'master_hash' }],
},
})
.get(
'/2.0/repositories/some/repo/commit/branch_hash/statuses?pagelen=100'
)
.reply(200, {
values: [
{
key: 'renovate/stability-days',
state: 'SUCCESSFUL',
},
],
});
expect(await bitbucket.getBranchStatus('branch', false)).toBe('yellow');
});
});

Expand Down
15 changes: 14 additions & 1 deletion lib/modules/platform/bitbucket/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,8 @@ async function getStatus(
}
// Returns the combined status for a branch.
export async function getBranchStatus(
branchName: string
branchName: string,
internalChecksAsSuccess: boolean
): Promise<BranchStatus> {
logger.debug(`getBranchStatus(${branchName})`);
const statuses = await getStatus(branchName);
Expand All @@ -377,6 +378,18 @@ export async function getBranchStatus(
if (noOfPending) {
return 'yellow';
}
if (
!internalChecksAsSuccess &&
statuses.every(
(status) =>
status.state === 'SUCCESSFUL' && status.key?.startsWith('renovate/')
)
) {
logger.debug(
'Successful checks are all internal renovate/ checks, so returning "pending" branch status'
);
return 'yellow';
}
return 'green';
}

Expand Down
43 changes: 40 additions & 3 deletions lib/modules/platform/gitea/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ describe('modules/platform/gitea/index', () => {
})
);

return gitea.getBranchStatus('some-branch');
return gitea.getBranchStatus('some-branch', true);
};

it('should return yellow for unknown result', async () => {
Expand All @@ -654,7 +654,7 @@ describe('modules/platform/gitea/index', () => {
it('should abort when branch status returns 404', async () => {
helper.getCombinedCommitStatus.mockRejectedValueOnce({ statusCode: 404 });

await expect(gitea.getBranchStatus('some-branch')).rejects.toThrow(
await expect(gitea.getBranchStatus('some-branch', true)).rejects.toThrow(
REPOSITORY_CHANGED
);
});
Expand All @@ -664,10 +664,47 @@ describe('modules/platform/gitea/index', () => {
new Error('getCombinedCommitStatus()')
);

await expect(gitea.getBranchStatus('some-branch')).rejects.toThrow(
await expect(gitea.getBranchStatus('some-branch', true)).rejects.toThrow(
'getCombinedCommitStatus()'
);
});

it('should treat internal checks as success', async () => {
helper.getCombinedCommitStatus.mockResolvedValueOnce({
worstStatus: 'success',
statuses: [
{
id: 1,
status: 'success',
context: 'renovate/stability-days',
description: 'internal check',
target_url: '',
created_at: '',
},
],
});
expect(await gitea.getBranchStatus('some-branch', true)).toBe('green');
});

it('should not treat internal checks as success', async () => {
await initFakeRepo();
helper.getCombinedCommitStatus.mockResolvedValueOnce(
partial<CombinedCommitStatus>({
worstStatus: 'success',
statuses: [
{
id: 1,
status: 'success',
context: 'renovate/stability-days',
description: 'internal check',
target_url: '',
created_at: '',
},
],
})
);
expect(await gitea.getBranchStatus('some-branch', false)).toBe('yellow');
});
});

describe('getBranchStatusCheck', () => {
Expand Down
16 changes: 15 additions & 1 deletion lib/modules/platform/gitea/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,10 @@ const platform: Platform = {
}
},

async getBranchStatus(branchName: string): Promise<BranchStatus> {
async getBranchStatus(
branchName: string,
internalChecksAsSuccess: boolean
): Promise<BranchStatus> {
let ccs: CombinedCommitStatus;
try {
ccs = await helper.getCombinedCommitStatus(config.repository, branchName);
Expand All @@ -404,6 +407,17 @@ const platform: Platform = {
}

logger.debug({ ccs }, 'Branch status check result');
if (
!internalChecksAsSuccess &&
ccs.worstStatus === 'success' &&
ccs.statuses.every((status) => status.context?.startsWith('renovate/'))
) {
logger.debug(
'Successful checks are all internal renovate/ checks, so returning "pending" branch status'
);
return 'yellow';
}

return helper.giteaToRenovateStatusMapping[ccs.worstStatus] ?? 'yellow';
},

Expand Down
Loading