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(changelogs): defer fetching until required #17149

Merged
merged 1 commit into from
Aug 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 0 additions & 8 deletions lib/workers/repository/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { deleteLocalFile, privateCacheDir } from '../../util/fs';
import * as queue from '../../util/http/queue';
import { addSplit, getSplits, splitInit } from '../../util/split';
import { setBranchCache } from './cache';
import { embedChangelogs } from './changelog';
import { ensureDependencyDashboard } from './dependency-dashboard';
import handleError from './error';
import { finaliseRepo } from './finalise';
Expand Down Expand Up @@ -49,13 +48,6 @@ export async function renovateRepository(
) {
await ensureOnboardingPr(config, packageFiles, branches);
addSplit('onboarding');
if (config.fetchReleaseNotes && config.repoIsOnboarded) {
logger.info('Fetching changelogs');
for (const branch of branches) {
await embedChangelogs(branch.upgrades);
}
}
addSplit('changelogs');
const res = await updateRepo(config, branches);
setMeta({ repository: config.repository });
addSplit('update');
Expand Down
6 changes: 6 additions & 0 deletions lib/workers/repository/update/branch/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
fs,
git,
mocked,
mockedFunction,
partial,
platform,
} from '../../../../../test/util';
Expand All @@ -24,6 +25,7 @@ import * as _sanitize from '../../../../util/sanitize';
import * as _limits from '../../../global/limits';
import type { BranchConfig, BranchUpgradeConfig } from '../../../types';
import { BranchResult } from '../../../types';
import { needsChangelogs } from '../../changelog';
import type { Pr } from '../../onboarding/branch/check';
import * as _prWorker from '../pr';
import type { ResultWithPr } from '../pr';
Expand Down Expand Up @@ -652,12 +654,16 @@ describe('workers/repository/update/branch/index', () => {
artifactErrors: [],
updatedArtifacts: [partial<FileChange>({})],
} as WriteExistingFilesResult);

mockedFunction(needsChangelogs).mockReturnValueOnce(true);

expect(
await branchWorker.processBranch({
...config,
ignoreTests: true,
prCreation: 'not-pending',
commitBody: '[skip-ci]',
fetchReleaseNotes: true,
})
).toEqual({
branchExists: true,
Expand Down
10 changes: 6 additions & 4 deletions lib/workers/repository/update/branch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import {
import * as template from '../../../../util/template';
import { Limit, isLimitReached } from '../../../global/limits';
import { BranchConfig, BranchResult, PrBlockedBy } from '../../../types';
import { embedChangelog, needsChangelogs } from '../../changelog';
// import { embedChangelog, needsChangelogs } from '../../changelog';
import { ensurePr, getPlatformPrOptions, updatePrDebugData } from '../pr';
import { checkAutoMerge } from '../pr/automerge';
Expand Down Expand Up @@ -487,10 +488,11 @@ export async function processBranch(

// compile commit message with body, which maybe needs changelogs
if (config.commitBody) {
// TODO: defer fetching changelogs (#17020)
// if (config.fetchReleaseNotes && needsChangelogs(config, ['commitBody'])) {
// await embedChangelog(config);
// }
if (config.fetchReleaseNotes && needsChangelogs(config, ['commitBody'])) {
// we only need first upgrade, the others are only needed on PR update
// we add it to first, so PR fetch can skip fetching for that update
await embedChangelog(config.upgrades[0]);
viceice marked this conversation as resolved.
Show resolved Hide resolved
}
// changelog is on first upgrade
config.commitMessage = `${config.commitMessage!}\n\n${template.compile(
config.commitBody,
Expand Down
2 changes: 2 additions & 0 deletions lib/workers/repository/update/pr/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ describe('workers/repository/update/pr/index', () => {
platform.createPr.mockResolvedValueOnce(pr);
limits.isLimitReached.mockReturnValueOnce(true);

config.fetchReleaseNotes = true;

const res = await ensurePr(config);

expect(res).toEqual({ type: 'without-pr', prBlockedBy: 'RateLimited' });
Expand Down
10 changes: 5 additions & 5 deletions lib/workers/repository/update/pr/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import type {
BranchUpgradeConfig,
PrBlockedBy,
} from '../../../types';
import { embedChangelogs } from '../../changelog';
// import { embedChangelogs } from '../../changelog';
import { resolveBranchStatus } from '../branch/status-checks';
import { getPrBody } from './body';
Expand Down Expand Up @@ -195,11 +196,10 @@ export async function ensurePr(
}`;
}

// TODO: defer fetching changelogs (#17020)
// if (config.fetchReleaseNotes) {
// // fetch changelogs when not already done;
// await embedChangelogs(upgrades);
// }
if (config.fetchReleaseNotes) {
// fetch changelogs when not already done;
await embedChangelogs(upgrades);
}

// Get changelog and then generate template strings
for (const upgrade of upgrades) {
Expand Down