test(index): forced plugins to use semantic-release beta

which deduped env-ci to the esm-only version, allowing test double to stub properly
This commit is contained in:
Matt Travi
2022-11-11 11:01:16 -06:00
parent 9eab1adb9d
commit f7c85e3fff
5 changed files with 131 additions and 585 deletions
+92 -75
View File
@@ -125,7 +125,7 @@ test('Plugins are called with expected values', async (t) => {
publish: [publish, pluginNoop],
success,
};
const envCi = {branch: 'master', isCi: true, isPr: false};
const envCiResults = {branch: 'master', isCi: true, isPr: false};
const releases = [
{
@@ -143,7 +143,8 @@ test('Plugins are called with expected values', async (t) => {
];
await td.replaceEsm('../lib/get-logger.js', null, () => t.context.logger);
await td.replaceEsm('env-ci', null, () => envCi);
const envCi = (await td.replaceEsm('env-ci')).default;
td.when(envCi({env, cwd})).thenReturn(envCiResults);
const semanticRelease = (await import('../index.js')).default;
const result = await semanticRelease(options, {
cwd,
@@ -159,7 +160,7 @@ test('Plugins are called with expected values', async (t) => {
t.deepEqual(verifyConditions1.args[0][1].branch, branch);
t.deepEqual(verifyConditions1.args[0][1].branches, branches);
t.deepEqual(verifyConditions1.args[0][1].logger, t.context.logger);
t.deepEqual(verifyConditions1.args[0][1].envCi, envCi);
t.deepEqual(verifyConditions1.args[0][1].envCi, envCiResults);
t.is(verifyConditions2.callCount, 1);
t.deepEqual(verifyConditions2.args[0][0], config);
t.deepEqual(verifyConditions2.args[0][1].cwd, cwd);
@@ -167,7 +168,7 @@ test('Plugins are called with expected values', async (t) => {
t.deepEqual(verifyConditions2.args[0][1].branch, branch);
t.deepEqual(verifyConditions2.args[0][1].branches, branches);
t.deepEqual(verifyConditions2.args[0][1].logger, t.context.logger);
t.deepEqual(verifyConditions2.args[0][1].envCi, envCi);
t.deepEqual(verifyConditions2.args[0][1].envCi, envCiResults);
t.is(generateNotes1.callCount, 2);
t.is(generateNotes2.callCount, 2);
@@ -189,7 +190,7 @@ test('Plugins are called with expected values', async (t) => {
gitTag: 'v1.0.0',
name: 'v1.0.0',
});
t.deepEqual(generateNotes2.args[0][1].envCi, envCi);
t.deepEqual(generateNotes2.args[0][1].envCi, envCiResults);
t.deepEqual(generateNotes2.args[0][0], config);
t.deepEqual(generateNotes2.args[0][1].options, options);
@@ -208,7 +209,7 @@ test('Plugins are called with expected values', async (t) => {
name: 'v1.0.0',
notes: notes1,
});
t.deepEqual(generateNotes2.args[0][1].envCi, envCi);
t.deepEqual(generateNotes2.args[0][1].envCi, envCiResults);
t.deepEqual(generateNotes3.args[0][0], config);
t.deepEqual(generateNotes3.args[0][1].options, options);
@@ -227,7 +228,7 @@ test('Plugins are called with expected values', async (t) => {
name: 'v1.0.0',
notes: `${notes1}\n\n${notes2}`,
});
t.deepEqual(generateNotes3.args[0][1].envCi, envCi);
t.deepEqual(generateNotes3.args[0][1].envCi, envCiResults);
branch.tags.push({
version: '1.0.0',
@@ -255,7 +256,7 @@ test('Plugins are called with expected values', async (t) => {
});
t.deepEqual(addChannel.args[0][1].commits[0].hash, commits[1].hash);
t.deepEqual(addChannel.args[0][1].commits[0].message, commits[1].message);
t.deepEqual(addChannel.args[0][1].envCi, envCi);
t.deepEqual(addChannel.args[0][1].envCi, envCiResults);
t.is(analyzeCommits.callCount, 1);
t.deepEqual(analyzeCommits.args[0][0], config);
@@ -266,7 +267,7 @@ test('Plugins are called with expected values', async (t) => {
t.deepEqual(analyzeCommits.args[0][1].lastRelease, lastRelease);
t.deepEqual(analyzeCommits.args[0][1].commits[0].hash, commits[0].hash);
t.deepEqual(analyzeCommits.args[0][1].commits[0].message, commits[0].message);
t.deepEqual(analyzeCommits.args[0][1].envCi, envCi);
t.deepEqual(analyzeCommits.args[0][1].envCi, envCiResults);
t.is(verifyRelease.callCount, 1);
t.deepEqual(verifyRelease.args[0][0], config);
@@ -278,7 +279,7 @@ test('Plugins are called with expected values', async (t) => {
t.deepEqual(verifyRelease.args[0][1].commits[0].hash, commits[0].hash);
t.deepEqual(verifyRelease.args[0][1].commits[0].message, commits[0].message);
t.deepEqual(verifyRelease.args[0][1].nextRelease, nextRelease);
t.deepEqual(verifyRelease.args[0][1].envCi, envCi);
t.deepEqual(verifyRelease.args[0][1].envCi, envCiResults);
t.deepEqual(generateNotes1.args[1][0], config);
t.deepEqual(generateNotes1.args[1][1].options, options);
@@ -289,7 +290,7 @@ test('Plugins are called with expected values', async (t) => {
t.deepEqual(generateNotes1.args[1][1].commits[0].hash, commits[0].hash);
t.deepEqual(generateNotes1.args[1][1].commits[0].message, commits[0].message);
t.deepEqual(generateNotes1.args[1][1].nextRelease, nextRelease);
t.deepEqual(generateNotes1.args[1][1].envCi, envCi);
t.deepEqual(generateNotes1.args[1][1].envCi, envCiResults);
t.deepEqual(generateNotes2.args[1][0], config);
t.deepEqual(generateNotes2.args[1][1].options, options);
@@ -300,7 +301,7 @@ test('Plugins are called with expected values', async (t) => {
t.deepEqual(generateNotes2.args[1][1].commits[0].hash, commits[0].hash);
t.deepEqual(generateNotes2.args[1][1].commits[0].message, commits[0].message);
t.deepEqual(generateNotes2.args[1][1].nextRelease, {...nextRelease, notes: notes1});
t.deepEqual(generateNotes2.args[1][1].envCi, envCi);
t.deepEqual(generateNotes2.args[1][1].envCi, envCiResults);
t.deepEqual(generateNotes3.args[1][0], config);
t.deepEqual(generateNotes3.args[1][1].options, options);
@@ -311,7 +312,7 @@ test('Plugins are called with expected values', async (t) => {
t.deepEqual(generateNotes3.args[1][1].commits[0].hash, commits[0].hash);
t.deepEqual(generateNotes3.args[1][1].commits[0].message, commits[0].message);
t.deepEqual(generateNotes3.args[1][1].nextRelease, {...nextRelease, notes: `${notes1}\n\n${notes2}`});
t.deepEqual(generateNotes3.args[1][1].envCi, envCi);
t.deepEqual(generateNotes3.args[1][1].envCi, envCiResults);
t.is(prepare.callCount, 1);
t.deepEqual(prepare.args[0][0], config);
@@ -323,7 +324,7 @@ test('Plugins are called with expected values', async (t) => {
t.deepEqual(prepare.args[0][1].commits[0].hash, commits[0].hash);
t.deepEqual(prepare.args[0][1].commits[0].message, commits[0].message);
t.deepEqual(prepare.args[0][1].nextRelease, {...nextRelease, notes: `${notes1}\n\n${notes2}\n\n${notes3}`});
t.deepEqual(prepare.args[0][1].envCi, envCi);
t.deepEqual(prepare.args[0][1].envCi, envCiResults);
t.is(publish.callCount, 1);
t.deepEqual(publish.args[0][0], config);
@@ -335,7 +336,7 @@ test('Plugins are called with expected values', async (t) => {
t.deepEqual(publish.args[0][1].commits[0].hash, commits[0].hash);
t.deepEqual(publish.args[0][1].commits[0].message, commits[0].message);
t.deepEqual(publish.args[0][1].nextRelease, {...nextRelease, notes: `${notes1}\n\n${notes2}\n\n${notes3}`});
t.deepEqual(publish.args[0][1].envCi, envCi);
t.deepEqual(publish.args[0][1].envCi, envCiResults);
t.is(success.callCount, 2);
t.deepEqual(success.args[0][0], config);
@@ -356,7 +357,7 @@ test('Plugins are called with expected values', async (t) => {
notes: `${notes1}\n\n${notes2}\n\n${notes3}`,
});
t.deepEqual(success.args[0][1].releases, [releases[0]]);
t.deepEqual(success.args[0][1].envCi, envCi);
t.deepEqual(success.args[0][1].envCi, envCiResults);
t.deepEqual(success.args[1][0], config);
t.deepEqual(success.args[1][1].options, options);
@@ -368,7 +369,7 @@ test('Plugins are called with expected values', async (t) => {
t.deepEqual(success.args[1][1].commits[0].message, commits[0].message);
t.deepEqual(success.args[1][1].nextRelease, {...nextRelease, notes: `${notes1}\n\n${notes2}\n\n${notes3}`});
t.deepEqual(success.args[1][1].releases, [releases[1], releases[2]]);
t.deepEqual(success.args[1][1].envCi, envCi);
t.deepEqual(success.args[1][1].envCi, envCiResults);
t.deepEqual(result, {
lastRelease,
@@ -388,7 +389,7 @@ test('Plugins are called with expected values', async (t) => {
t.is(env.GIT_COMMITTER_EMAIL, COMMIT_EMAIL);
});
test('Use custom tag format', async (t) => {
test.serial('Use custom tag format', async (t) => {
const {cwd, repositoryUrl} = await gitRepo(true);
await gitCommits(['First'], {cwd});
await gitTagVersion('test-1.0.0', undefined, {cwd});
@@ -434,7 +435,7 @@ test('Use custom tag format', async (t) => {
t.is(await gitRemoteTagHead(repositoryUrl, nextRelease.gitTag, {cwd}), nextRelease.gitHead);
});
test('Use new gitHead, and recreate release notes if a prepare plugin create a commit', async (t) => {
test.serial('Use new gitHead, and recreate release notes if a prepare plugin create a commit', async (t) => {
// Create a git repository, set the current working directory at the root of the repo
const {cwd, repositoryUrl} = await gitRepo(true);
// Add commits to the master branch
@@ -507,7 +508,7 @@ test('Use new gitHead, and recreate release notes if a prepare plugin create a c
t.is(await gitRemoteTagHead(repositoryUrl, nextRelease.gitTag, {cwd}), commits[0].hash);
});
test('Make a new release when a commit is forward-ported to an upper branch', async (t) => {
test.serial('Make a new release when a commit is forward-ported to an upper branch', async (t) => {
const {cwd, repositoryUrl} = await gitRepo(true);
await gitCommits(['feat: initial release'], {cwd});
await gitTagVersion('v1.0.0', undefined, {cwd});
@@ -553,7 +554,7 @@ test('Make a new release when a commit is forward-ported to an upper branch', as
t.is(success.callCount, 1);
});
test('Publish a pre-release version', async (t) => {
test.serial('Publish a pre-release version', async (t) => {
const {cwd, repositoryUrl} = await gitRepo(true);
await gitCommits(['feat: initial commit'], {cwd});
await gitTagVersion('v1.0.0', undefined, {cwd});
@@ -575,8 +576,10 @@ test('Publish a pre-release version', async (t) => {
fail: stub().resolves(),
};
const env = {};
await td.replaceEsm('../lib/get-logger.js', null, () => t.context.logger);
await td.replaceEsm('env-ci', null, () => ({isCi: true, branch: 'beta', isPr: false}));
const envCi = (await td.replaceEsm('env-ci')).default;
td.when(envCi({env, cwd})).thenReturn({isCi: true, branch: 'beta', isPr: false});
const semanticRelease = (await import('../index.js')).default;
let {releases} = await semanticRelease(options, {cwd, env: {}, stdout: {write: () => {}}, stderr: {write: () => {}}});
@@ -588,7 +591,7 @@ test('Publish a pre-release version', async (t) => {
await gitCommits(['fix: a fix'], {cwd});
({releases} = await semanticRelease(options, {
cwd,
env: {},
env,
stdout: {write: () => {}},
stderr: {write: () => {}},
}));
@@ -599,7 +602,7 @@ test('Publish a pre-release version', async (t) => {
t.is(await gitGetNote('v1.1.0-beta.2', {cwd}), '{"channels":["beta"]}');
});
test('Publish releases from different branch on the same channel', async (t) => {
test.serial('Publish releases from different branch on the same channel', async (t) => {
const {cwd, repositoryUrl} = await gitRepo(true);
await gitCommits(['feat: initial commit'], {cwd});
await gitTagVersion('v1.0.0', undefined, {cwd});
@@ -627,10 +630,12 @@ test('Publish releases from different branch on the same channel', async (t) =>
fail: stub().resolves(),
};
const env = {};
await td.replaceEsm('../lib/get-logger.js', null, () => t.context.logger);
await td.replaceEsm('env-ci', null, () => ({isCi: true, branch: 'next', isPr: false}));
const envCi = (await td.replaceEsm('env-ci')).default;
td.when(envCi({env, cwd})).thenReturn({isCi: true, branch: 'next', isPr: false});
let semanticRelease = (await import('../index.js')).default;
let {releases} = await semanticRelease(options, {cwd, env: {}, stdout: {write: () => {}}, stderr: {write: () => {}}});
let {releases} = await semanticRelease(options, {cwd, env, stdout: {write: () => {}}, stderr: {write: () => {}}});
t.is(releases.length, 1);
t.is(releases[0].version, '1.1.0');
@@ -639,7 +644,7 @@ test('Publish releases from different branch on the same channel', async (t) =>
await gitCommits(['fix: a fix'], {cwd});
({releases} = await semanticRelease(options, {
cwd,
env: {},
env,
stdout: {write: () => {}},
stderr: {write: () => {}},
}));
@@ -660,7 +665,7 @@ test('Publish releases from different branch on the same channel', async (t) =>
t.is(addChannel.callCount, 0);
});
test('Publish pre-releases the same channel as regular releases', async (t) => {
test.serial('Publish pre-releases the same channel as regular releases', async (t) => {
const {cwd, repositoryUrl} = await gitRepo(true);
await gitCommits(['feat: initial commit'], {cwd});
await gitTagVersion('v1.0.0', undefined, {cwd});
@@ -685,10 +690,12 @@ test('Publish pre-releases the same channel as regular releases', async (t) => {
fail: stub().resolves(),
};
const env = {};
await td.replaceEsm('../lib/get-logger.js', null, () => t.context.logger);
await td.replaceEsm('env-ci', null, () => ({isCi: true, branch: 'beta', isPr: false}));
const envCi = (await td.replaceEsm('env-ci')).default;
td.when(envCi({cwd, env})).thenReturn({isCi: true, branch: 'beta', isPr: false});
const semanticRelease = (await import('../index.js')).default;
let {releases} = await semanticRelease(options, {cwd, env: {}, stdout: {write: () => {}}, stderr: {write: () => {}}});
let {releases} = await semanticRelease(options, {cwd, env, stdout: {write: () => {}}, stderr: {write: () => {}}});
t.is(releases.length, 1);
t.is(releases[0].version, '1.1.0-beta.1');
@@ -697,7 +704,7 @@ test('Publish pre-releases the same channel as regular releases', async (t) => {
await gitCommits(['fix: a fix'], {cwd});
({releases} = await semanticRelease(options, {
cwd,
env: {},
env,
stdout: {write: () => {}},
stderr: {write: () => {}},
}));
@@ -707,7 +714,7 @@ test('Publish pre-releases the same channel as regular releases', async (t) => {
t.is(releases[0].gitTag, 'v1.1.0-beta.2');
});
test('Do not add pre-releases to a different channel', async (t) => {
test.serial('Do not add pre-releases to a different channel', async (t) => {
const {cwd, repositoryUrl} = await gitRepo(true);
await gitCommits(['feat: initial release'], {cwd});
await gitTagVersion('v1.0.0', undefined, {cwd});
@@ -750,10 +757,12 @@ test('Do not add pre-releases to a different channel', async (t) => {
success,
};
const env = {};
await td.replaceEsm('../lib/get-logger.js', null, () => t.context.logger);
await td.replaceEsm('env-ci', null, () => ({isCi: true, branch: 'master', isPr: false}));
const envCi = (await td.replaceEsm('env-ci')).default;
td.when(envCi({cwd, env})).thenReturn({isCi: true, branch: 'master', isPr: false});
const semanticRelease = (await import('../index.js')).default;
t.truthy(await semanticRelease(options, {cwd, env: {}, stdout: {write: () => {}}, stderr: {write: () => {}}}));
t.truthy(await semanticRelease(options, {cwd, env, stdout: {write: () => {}}, stderr: {write: () => {}}}));
t.is(addChannel.callCount, 0);
});
@@ -818,10 +827,12 @@ async function addChannelMacro(t, mergeFunction) {
gitHead: commits[2].hash,
};
const env = {};
await td.replaceEsm('../lib/get-logger.js', null, () => t.context.logger);
await td.replaceEsm('env-ci', null, () => ({isCi: true, branch: 'master', isPr: false}));
const envCi = (await td.replaceEsm('env-ci')).default;
td.when(envCi({env, cwd})).thenReturn({isCi: true, branch: 'master', isPr: false});
const semanticRelease = (await import('../index.js')).default;
const result = await semanticRelease(options, {cwd, env: {}, stdout: {write: () => {}}, stderr: {write: () => {}}});
const result = await semanticRelease(options, {cwd, env, stdout: {write: () => {}}, stderr: {write: () => {}}});
t.deepEqual(result.releases, [
{...nextRelease, ...release1, notes, pluginName: '[Function: functionStub]'},
@@ -835,11 +846,11 @@ async function addChannelMacro(t, mergeFunction) {
addChannelMacro.title = (providedTitle) => `Add version to a channel after a merge (${providedTitle})`;
test('fast-forward', addChannelMacro, mergeFf);
test('non fast-forward', addChannelMacro, merge);
test('rebase', addChannelMacro, rebase);
test.serial('fast-forward', addChannelMacro, mergeFf);
test.serial('non fast-forward', addChannelMacro, merge);
test.serial('rebase', addChannelMacro, rebase);
test('Call all "success" plugins even if one errors out', async (t) => {
test.serial('Call all "success" plugins even if one errors out', async (t) => {
// Create a git repository, set the current working directory at the root of the repo
const {cwd, repositoryUrl} = await gitRepo(true);
// Add commits to the master branch
@@ -884,12 +895,14 @@ test('Call all "success" plugins even if one errors out', async (t) => {
success: [success1, success2],
};
const env = {};
await td.replaceEsm('../lib/get-logger.js', null, () => t.context.logger);
await td.replaceEsm('env-ci', null, () => ({isCi: true, branch: 'master', isPr: false}));
const envCi = (await td.replaceEsm('env-ci')).default;
td.when(envCi({cwd, env})).thenReturn({isCi: true, branch: 'master', isPr: false});
const semanticRelease = (await import('../index.js')).default;
await t.throwsAsync(
semanticRelease(options, {cwd, env: {}, stdout: new WritableStreamBuffer(), stderr: new WritableStreamBuffer()})
semanticRelease(options, {cwd, env, stdout: new WritableStreamBuffer(), stderr: new WritableStreamBuffer()})
);
t.is(success1.callCount, 1);
@@ -904,7 +917,7 @@ test('Call all "success" plugins even if one errors out', async (t) => {
]);
});
test('Log all "verifyConditions" errors', async (t) => {
test.serial('Log all "verifyConditions" errors', async (t) => {
// Create a git repository, set the current working directory at the root of the repo
const {cwd, repositoryUrl} = await gitRepo(true);
// Add commits to the master branch
@@ -934,7 +947,7 @@ test('Log all "verifyConditions" errors', async (t) => {
const errors = [
...(await t.throwsAsync(
semanticRelease(options, {cwd, env: {}, stdout: new WritableStreamBuffer(), stderr: new WritableStreamBuffer()})
)),
)).errors,
];
t.deepEqual(sortBy(errors, ['message']), sortBy([error1, error2, error3], ['message']));
@@ -949,7 +962,7 @@ test('Log all "verifyConditions" errors', async (t) => {
t.deepEqual(fail.args[0][1].errors, [error2, error3]);
});
test('Log all "verifyRelease" errors', async (t) => {
test.serial('Log all "verifyRelease" errors', async (t) => {
// Create a git repository, set the current working directory at the root of the repo
const {cwd, repositoryUrl} = await gitRepo(true);
// Add commits to the master branch
@@ -978,7 +991,7 @@ test('Log all "verifyRelease" errors', async (t) => {
const errors = [
...(await t.throwsAsync(
semanticRelease(options, {cwd, env: {}, stdout: new WritableStreamBuffer(), stderr: new WritableStreamBuffer()})
)),
)).errors,
];
t.deepEqual(sortBy(errors, ['message']), sortBy([error1, error2], ['message']));
@@ -989,7 +1002,7 @@ test('Log all "verifyRelease" errors', async (t) => {
t.deepEqual(fail.args[0][1].errors, [error1, error2]);
});
test('Dry-run skips addChannel, prepare, publish and success', async (t) => {
test.serial('Dry-run skips addChannel, prepare, publish and success', async (t) => {
const {cwd, repositoryUrl} = await gitRepo(true);
await gitCommits(['First'], {cwd});
await gitTagVersion('v1.0.0', undefined, {cwd});
@@ -1054,7 +1067,7 @@ test('Dry-run skips addChannel, prepare, publish and success', async (t) => {
t.true(t.context.warn.calledWith(`Skip step "success" of plugin "[Function: ${success.name}]" in dry-run mode`));
});
test('Dry-run skips fail', async (t) => {
test.serial('Dry-run skips fail', async (t) => {
// Create a git repository, set the current working directory at the root of the repo
const {cwd, repositoryUrl} = await gitRepo(true);
// Add commits to the master branch
@@ -1083,7 +1096,7 @@ test('Dry-run skips fail', async (t) => {
const errors = [
...(await t.throwsAsync(
semanticRelease(options, {cwd, env: {}, stdout: new WritableStreamBuffer(), stderr: new WritableStreamBuffer()})
)),
)).errors,
];
t.deepEqual(sortBy(errors, ['message']), sortBy([error1, error2], ['message']));
@@ -1093,7 +1106,7 @@ test('Dry-run skips fail', async (t) => {
t.true(t.context.warn.calledWith(`Skip step "fail" of plugin "[Function: ${fail.name}]" in dry-run mode`));
});
test('Force a dry-run if not on a CI and "noCi" is not explicitly set', async (t) => {
test.serial('Force a dry-run if not on a CI and "noCi" is not explicitly set', async (t) => {
// Create a git repository, set the current working directory at the root of the repo
const {cwd, repositoryUrl} = await gitRepo(true);
// Add commits to the master branch
@@ -1157,7 +1170,7 @@ test('Force a dry-run if not on a CI and "noCi" is not explicitly set', async (t
t.is(success.callCount, 0);
});
test('Dry-run does not print changelog if "generateNotes" return "undefined"', async (t) => {
test.serial('Dry-run does not print changelog if "generateNotes" return "undefined"', async (t) => {
// Create a git repository, set the current working directory at the root of the repo
const {cwd, repositoryUrl} = await gitRepo(true);
// Add commits to the master branch
@@ -1200,7 +1213,7 @@ test('Dry-run does not print changelog if "generateNotes" return "undefined"', a
t.deepEqual(t.context.log.args[t.context.log.args.length - 1], ['Release note for version 2.0.0:']);
});
test('Allow local releases with "noCi" option', async (t) => {
test.serial('Allow local releases with "noCi" option', async (t) => {
// Create a git repository, set the current working directory at the root of the repo
const {cwd, repositoryUrl} = await gitRepo(true);
// Add commits to the master branch
@@ -1268,7 +1281,7 @@ test('Allow local releases with "noCi" option', async (t) => {
t.is(success.callCount, 1);
});
test('Accept "undefined" value returned by "generateNotes" and "false" by "publish" and "addChannel"', async (t) => {
test.serial('Accept "undefined" value returned by "generateNotes" and "false" by "publish" and "addChannel"', async (t) => {
const {cwd, repositoryUrl} = await gitRepo(true);
await gitCommits(['First'], {cwd});
await gitTagVersion('v1.0.0', undefined, {cwd});
@@ -1336,7 +1349,7 @@ test('Accept "undefined" value returned by "generateNotes" and "false" by "publi
t.deepEqual(success.args[1][1].releases, [{pluginName: '[Function: functionStub]'}]);
});
test('Returns false if triggered by a PR', async (t) => {
test.serial('Returns false if triggered by a PR', async (t) => {
// Create a git repository, set the current working directory at the root of the repo
const {cwd, repositoryUrl} = await gitRepo(true);
@@ -1356,7 +1369,7 @@ test('Returns false if triggered by a PR', async (t) => {
);
});
test('Throws "EINVALIDNEXTVERSION" if next release is out of range of the current maintenance branch', async (t) => {
test.serial('Throws "EINVALIDNEXTVERSION" if next release is out of range of the current maintenance branch', async (t) => {
const {cwd, repositoryUrl} = await gitRepo(true);
await gitCommits(['feat: initial commit'], {cwd});
await gitTagVersion('v1.0.0', undefined, {cwd});
@@ -1392,12 +1405,14 @@ test('Throws "EINVALIDNEXTVERSION" if next release is out of range of the curren
success,
};
const env = {};
await td.replaceEsm('../lib/get-logger.js', null, () => t.context.logger);
await td.replaceEsm('env-ci', null, () => ({isCi: true, branch: '1.x', isPr: false}));
const envCi = (await td.replaceEsm('env-ci')).default;
td.when(envCi({cwd, env})).thenReturn({isCi: true, branch: '1.x', isPr: false});
const semanticRelease = (await import('../index.js')).default;
const error = await t.throwsAsync(
semanticRelease(options, {cwd, env: {}, stdout: {write: () => {}}, stderr: {write: () => {}}})
semanticRelease(options, {cwd, env, stdout: {write: () => {}}, stderr: {write: () => {}}})
);
t.is(error.code, 'EINVALIDNEXTVERSION');
@@ -1406,7 +1421,7 @@ test('Throws "EINVALIDNEXTVERSION" if next release is out of range of the curren
t.regex(error.details, /A valid branch could be `master`./);
});
test('Throws "EINVALIDNEXTVERSION" if next release is out of range of the current release branch', async (t) => {
test.serial('Throws "EINVALIDNEXTVERSION" if next release is out of range of the current release branch', async (t) => {
const {cwd, repositoryUrl} = await gitRepo(true);
await gitCommits(['feat: initial commit'], {cwd});
await gitTagVersion('v1.0.0', undefined, {cwd});
@@ -1457,7 +1472,7 @@ test('Throws "EINVALIDNEXTVERSION" if next release is out of range of the curren
t.regex(error.details, /A valid branch could be `next` or `next-major`./);
});
test('Throws "EINVALIDMAINTENANCEMERGE" if merge an out of range release in a maintenance branch', async (t) => {
test.serial('Throws "EINVALIDMAINTENANCEMERGE" if merge an out of range release in a maintenance branch', async (t) => {
const {cwd, repositoryUrl} = await gitRepo(true);
await gitCommits(['First'], {cwd});
await gitTagVersion('v1.0.0', undefined, {cwd});
@@ -1504,11 +1519,11 @@ test('Throws "EINVALIDMAINTENANCEMERGE" if merge an out of range release in a ma
await td.replaceEsm('../lib/get-logger.js', null, () => t.context.logger);
await td.replaceEsm('env-ci', null, () => ({isCi: true, branch: '1.1.x', isPr: false}));
const semanticRelease = await import('../index.js');
const semanticRelease = (await import('../index.js')).default;
const errors = [
...(await t.throwsAsync(
semanticRelease(options, {cwd, env: {}, stdout: {write: () => {}}, stderr: {write: () => {}}})
)),
)).errors,
];
t.is(addChannel.callCount, 0);
@@ -1526,7 +1541,7 @@ test('Throws "EINVALIDMAINTENANCEMERGE" if merge an out of range release in a ma
t.truthy(errors[0].details);
});
test('Returns false value if triggered on an outdated clone', async (t) => {
test.serial('Returns false value if triggered on an outdated clone', async (t) => {
// Create a git repository, set the current working directory at the root of the repo
let {cwd, repositoryUrl} = await gitRepo(true);
const repoDir = cwd;
@@ -1553,7 +1568,7 @@ test('Returns false value if triggered on an outdated clone', async (t) => {
]);
});
test('Returns false if not running from the configured branch', async (t) => {
test.serial('Returns false if not running from the configured branch', async (t) => {
// Create a git repository, set the current working directory at the root of the repo
const {cwd, repositoryUrl} = await gitRepo(true);
const options = {
@@ -1588,7 +1603,7 @@ test('Returns false if not running from the configured branch', async (t) => {
);
});
test('Returns false if there is no relevant changes', async (t) => {
test.serial('Returns false if there is no relevant changes', async (t) => {
// Create a git repository, set the current working directory at the root of the repo
const {cwd, repositoryUrl} = await gitRepo(true);
// Add commits to the master branch
@@ -1636,7 +1651,7 @@ test('Returns false if there is no relevant changes', async (t) => {
);
});
test('Exclude commits with [skip release] or [release skip] from analysis', async (t) => {
test.serial('Exclude commits with [skip release] or [release skip] from analysis', async (t) => {
// Create a git repository, set the current working directory at the root of the repo
const {cwd, repositoryUrl} = await gitRepo(true);
// Add commits to the master branch
@@ -1669,12 +1684,14 @@ test('Exclude commits with [skip release] or [release skip] from analysis', asyn
fail: stub().resolves(),
};
const env = {};
await td.replaceEsm('../lib/get-logger.js', null, () => t.context.logger);
await td.replaceEsm('env-ci', null, () => ({isCi: true, branch: 'master', isPr: false}));
const envCi = (await td.replaceEsm('env-ci')).default;
td.when(envCi({env, cwd})).thenReturn({isCi: true, branch: 'master', isPr: false});
const semanticRelease = (await import('../index.js')).default;
await semanticRelease(options, {
cwd,
env: {},
env,
stdout: new WritableStreamBuffer(),
stderr: new WritableStreamBuffer(),
});
@@ -1684,7 +1701,7 @@ test('Exclude commits with [skip release] or [release skip] from analysis', asyn
t.deepEqual(analyzeCommits.args[0][1].commits[0], commits[commits.length - 1]);
});
test('Log both plugins errors and errors thrown by "fail" plugin', async (t) => {
test.serial('Log both plugins errors and errors thrown by "fail" plugin', async (t) => {
const {cwd, repositoryUrl} = await gitRepo(true);
const pluginError = new SemanticReleaseError('Plugin error', 'ERR');
const failError1 = new Error('Fail error 1');
@@ -1709,7 +1726,7 @@ test('Log both plugins errors and errors thrown by "fail" plugin', async (t) =>
t.is(t.context.error.args[t.context.error.args.length - 2][1], failError2);
});
test('Call "fail" only if a plugin returns a SemanticReleaseError', async (t) => {
test.serial('Call "fail" only if a plugin returns a SemanticReleaseError', async (t) => {
const {cwd, repositoryUrl} = await gitRepo(true);
const pluginError = new Error('Plugin error');
const fail = stub().resolves();
@@ -1732,7 +1749,7 @@ test('Call "fail" only if a plugin returns a SemanticReleaseError', async (t) =>
t.is(t.context.error.args[t.context.error.args.length - 1][1], pluginError);
});
test('Throw SemanticReleaseError if repositoryUrl is not set and cannot be found from repo config', async (t) => {
test.serial('Throw SemanticReleaseError if repositoryUrl is not set and cannot be found from repo config', async (t) => {
// Create a git repository, set the current working directory at the root of the repo
const {cwd} = await gitRepo();
@@ -1742,7 +1759,7 @@ test('Throw SemanticReleaseError if repositoryUrl is not set and cannot be found
const errors = [
...(await t.throwsAsync(
semanticRelease({}, {cwd, env: {}, stdout: new WritableStreamBuffer(), stderr: new WritableStreamBuffer()})
)),
)).errors,
];
// Verify error code and type
@@ -1752,7 +1769,7 @@ test('Throw SemanticReleaseError if repositoryUrl is not set and cannot be found
t.truthy(errors[0].details);
});
test('Throw an Error if plugin returns an unexpected value', async (t) => {
test.serial('Throw an Error if plugin returns an unexpected value', async (t) => {
// Create a git repository, set the current working directory at the root of the repo
const {cwd, repositoryUrl} = await gitRepo(true);
// Add commits to the master branch
@@ -1785,7 +1802,7 @@ test('Throw an Error if plugin returns an unexpected value', async (t) => {
t.regex(error.details, /string/);
});
test('Hide sensitive information passed to "fail" plugin', async (t) => {
test.serial('Hide sensitive information passed to "fail" plugin', async (t) => {
const {cwd, repositoryUrl} = await gitRepo(true);
const fail = stub().resolves();
@@ -1823,7 +1840,7 @@ test('Hide sensitive information passed to "fail" plugin', async (t) => {
});
});
test('Hide sensitive information passed to "success" plugin', async (t) => {
test.serial('Hide sensitive information passed to "success" plugin', async (t) => {
const {cwd, repositoryUrl} = await gitRepo(true);
await gitCommits(['feat: initial release'], {cwd});
await gitTagVersion('v1.0.0', undefined, {cwd});
@@ -1865,7 +1882,7 @@ test('Hide sensitive information passed to "success" plugin', async (t) => {
});
});
test('Get all commits including the ones not in the shallow clone', async (t) => {
test.serial('Get all commits including the ones not in the shallow clone', async (t) => {
let {cwd, repositoryUrl} = await gitRepo(true);
await gitTagVersion('v1.0.0', undefined, {cwd});
await gitCommits(['First', 'Second', 'Third'], {cwd});
-2
View File
@@ -659,8 +659,6 @@ test('Hide sensitive environment variable values from the logs', async (t) => {
extendEnv: false,
});
console.log({stderr})
t.regex(stdout, new RegExp(`Console: Exposing token ${escapeRegExp(SECRET_REPLACEMENT)}`));
t.regex(stdout, new RegExp(`Log: Exposing token ${escapeRegExp(SECRET_REPLACEMENT)}`));
t.regex(stderr, new RegExp(`Error: Console token ${escapeRegExp(SECRET_REPLACEMENT)}`));