Compare commits
14
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6b5b02ea75 | ||
|
|
28b54800cd | ||
|
|
3739ab5f34 | ||
|
|
11665b214d | ||
|
|
0785a844fa | ||
|
|
152bf452e1 | ||
|
|
3ba8f2a929 | ||
|
|
a8c747d592 | ||
|
|
fc70726d90 | ||
|
|
fc7205d659 | ||
|
|
9772563a22 | ||
|
|
61665be9ec | ||
|
|
a8747c4f86 | ||
|
|
9a1af4de44 |
@@ -65,8 +65,8 @@ For each [release step](../../README.md#release-steps) the plugins that implemen
|
||||
With this configuration **semantic-release** will:
|
||||
- execute the `verifyConditions` implementation of `@semantic-release/npm` then `@semantic-release/git`
|
||||
- execute the `analyzeCommits` implementation of `@semantic-release/commit-analyzer`
|
||||
- execute the `prepare` implementation of `@semantic-release/npm` then `@semantic-release/git`
|
||||
- execute the `generateNotes` implementation of `@semantic-release/release-notes-generator`
|
||||
- execute the `prepare` implementation of `@semantic-release/npm` then `@semantic-release/git`
|
||||
- execute the `publish` implementation of `@semantic-release/npm`
|
||||
|
||||
## Plugin options configuration
|
||||
|
||||
@@ -26,7 +26,7 @@ marked.setOptions({renderer: new TerminalRenderer()});
|
||||
/* eslint complexity: off */
|
||||
async function run(context, plugins) {
|
||||
const {cwd, env, options, logger} = context;
|
||||
const {isCi, branch: ciBranch, isPr} = envCi({env, cwd});
|
||||
const {isCi, branch: ciBranch, isPr} = context.envCi;
|
||||
|
||||
if (!isCi && !options.dryRun && !options.noCi) {
|
||||
logger.warn('This run was not triggered in a known CI environment, running in dry-run mode.');
|
||||
@@ -112,7 +112,11 @@ async function run(context, plugins) {
|
||||
await addNote({channels: [...currentRelease.channels, nextRelease.channel]}, nextRelease.gitHead, {cwd, env});
|
||||
await push(options.repositoryUrl, {cwd, env});
|
||||
await pushNotes(options.repositoryUrl, {cwd, env});
|
||||
logger.success(`Add channel ${nextRelease.channel} to tag ${nextRelease.gitTag}`);
|
||||
logger.success(
|
||||
`Add ${nextRelease.channel ? `channel ${nextRelease.channel}` : 'default channel'} to tag ${
|
||||
nextRelease.gitTag
|
||||
}`
|
||||
);
|
||||
}
|
||||
|
||||
context.branch.tags.push({
|
||||
@@ -132,7 +136,7 @@ async function run(context, plugins) {
|
||||
throw new AggregateError(errors);
|
||||
}
|
||||
|
||||
context.lastRelease = await getLastRelease(context);
|
||||
context.lastRelease = getLastRelease(context);
|
||||
if (context.lastRelease.gitHead) {
|
||||
context.lastRelease.gitHead = await getTagHead(context.lastRelease.gitHead, {cwd, env});
|
||||
}
|
||||
@@ -237,7 +241,13 @@ module.exports = async (opts = {}, {cwd = process.cwd(), env = process.env, stdo
|
||||
{silent: false, streams: [process.stdout, process.stderr, stdout, stderr].filter(Boolean)},
|
||||
hideSensitive(env)
|
||||
);
|
||||
const context = {cwd, env, stdout: stdout || process.stdout, stderr: stderr || process.stderr};
|
||||
const context = {
|
||||
cwd,
|
||||
env,
|
||||
stdout: stdout || process.stdout,
|
||||
stderr: stderr || process.stderr,
|
||||
envCi: envCi({env, cwd}),
|
||||
};
|
||||
context.logger = getLogger(context);
|
||||
context.logger.log(`Running ${pkg.name} version ${pkg.version}`);
|
||||
try {
|
||||
|
||||
@@ -14,7 +14,9 @@ module.exports = ({branch, nextRelease: {type, channel}, lastRelease, logger}) =
|
||||
) {
|
||||
version = highest(
|
||||
semver.inc(lastRelease.version, 'prerelease'),
|
||||
`${semver.inc(getLatestVersion(tagsToVersions(branch.tags)), type)}-${branch.prerelease}.${FIRSTPRERELEASE}`
|
||||
`${semver.inc(getLatestVersion(tagsToVersions(branch.tags), {withPrerelease: true}), type)}-${
|
||||
branch.prerelease
|
||||
}.${FIRSTPRERELEASE}`
|
||||
);
|
||||
} else {
|
||||
version = `${semver.inc(`${major}.${minor}.${patch}`, type)}-${branch.prerelease}.${FIRSTPRERELEASE}`;
|
||||
|
||||
+16
-39
@@ -69,33 +69,6 @@ async function getBranches(repositoryUrl, execaOpts) {
|
||||
.filter(Boolean);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if the `ref` is in the direct history of a given branch.
|
||||
*
|
||||
* @param {String} ref The reference to look for.
|
||||
* @param {String} branch The branch for which to check if the `ref` is in history.
|
||||
* @param {Object} [execaOpts] Options to pass to `execa`.
|
||||
*
|
||||
* @return {Boolean} `true` if the reference is in the history of the current branch, falsy otherwise.
|
||||
*/
|
||||
async function isRefInHistory(ref, branch, execaOpts) {
|
||||
if (!(await isRefExists(branch, execaOpts))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
await execa('git', ['merge-base', '--is-ancestor', ref, branch], execaOpts);
|
||||
return true;
|
||||
} catch (error) {
|
||||
if (error.exitCode === 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
debug(error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if the `ref` exits
|
||||
*
|
||||
@@ -113,15 +86,22 @@ async function isRefExists(ref, execaOpts) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Unshallow the git repository if necessary and fetch all the tags.
|
||||
* Fetch all the tags from a branch. Unshallow if necessary.
|
||||
* This will update the local branch from the latest on the remote if:
|
||||
* - The branch is not the one that triggered the CI
|
||||
* - The CI created a detached head
|
||||
*
|
||||
* Otherwise it just calls `git fetch` without specifying the `refspec` option to avoid overwritting the head commit set by the CI.
|
||||
*
|
||||
* The goal is to retrieve the informations on all the release branches without "disturbing" the CI, leaving the trigger branch or the detached head intact.
|
||||
*
|
||||
* @param {String} repositoryUrl The remote repository URL.
|
||||
* @param {String} branch The repository branch to fetch.
|
||||
* @param {Object} [execaOpts] Options to pass to `execa`.
|
||||
*/
|
||||
async function fetch(repositoryUrl, branch, ciBranch, execaOpts) {
|
||||
const isLocalExists =
|
||||
(await execa('git', ['rev-parse', '--verify', branch], {...execaOpts, reject: false})).exitCode === 0;
|
||||
const isDetachedHead =
|
||||
(await execa('git', ['rev-parse', '--abbrev-ref', 'HEAD'], {...execaOpts, reject: false})).stdout === 'HEAD';
|
||||
|
||||
try {
|
||||
await execa(
|
||||
@@ -130,7 +110,7 @@ async function fetch(repositoryUrl, branch, ciBranch, execaOpts) {
|
||||
'fetch',
|
||||
'--unshallow',
|
||||
'--tags',
|
||||
...(branch === ciBranch && isLocalExists
|
||||
...(branch === ciBranch && !isDetachedHead
|
||||
? [repositoryUrl]
|
||||
: ['--update-head-ok', repositoryUrl, `+refs/heads/${branch}:refs/heads/${branch}`]),
|
||||
],
|
||||
@@ -142,7 +122,7 @@ async function fetch(repositoryUrl, branch, ciBranch, execaOpts) {
|
||||
[
|
||||
'fetch',
|
||||
'--tags',
|
||||
...(branch === ciBranch && isLocalExists
|
||||
...(branch === ciBranch && !isDetachedHead
|
||||
? [repositoryUrl]
|
||||
: ['--update-head-ok', repositoryUrl, `+refs/heads/${branch}:refs/heads/${branch}`]),
|
||||
],
|
||||
@@ -310,12 +290,10 @@ async function verifyBranchName(branch, execaOpts) {
|
||||
* @return {Boolean} `true` is the HEAD of the current local branch is the same as the HEAD of the remote branch, falsy otherwise.
|
||||
*/
|
||||
async function isBranchUpToDate(repositoryUrl, branch, execaOpts) {
|
||||
const {stdout: remoteHead} = await execa('git', ['ls-remote', '--heads', repositoryUrl, branch], execaOpts);
|
||||
try {
|
||||
return await isRefInHistory(remoteHead.match(/^(?<ref>\w+)?/)[1], branch, execaOpts);
|
||||
} catch (error) {
|
||||
debug(error);
|
||||
}
|
||||
return (
|
||||
(await getGitHead(execaOpts)) ===
|
||||
(await execa('git', ['ls-remote', '--heads', repositoryUrl, branch], execaOpts)).stdout.match(/^(?<ref>\w+)?/)[1]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -355,7 +333,6 @@ module.exports = {
|
||||
getTags,
|
||||
getCommits,
|
||||
getBranches,
|
||||
isRefInHistory,
|
||||
isRefExists,
|
||||
fetch,
|
||||
fetchNotes,
|
||||
|
||||
+10
-10
@@ -22,16 +22,16 @@
|
||||
"Pierre Vanduynslager (https://twitter.com/@pvdlg_)"
|
||||
],
|
||||
"dependencies": {
|
||||
"@semantic-release/commit-analyzer": "^7.0.0-beta",
|
||||
"@semantic-release/commit-analyzer": "^7.0.0",
|
||||
"@semantic-release/error": "^2.2.0",
|
||||
"@semantic-release/github": "^5.6.0-beta",
|
||||
"@semantic-release/npm": "^6.0.0-beta",
|
||||
"@semantic-release/github": "^6.0.0",
|
||||
"@semantic-release/npm": "^6.0.0",
|
||||
"@semantic-release/release-notes-generator": "^7.1.2",
|
||||
"aggregate-error": "^3.0.0",
|
||||
"cosmiconfig": "^6.0.0",
|
||||
"debug": "^4.0.0",
|
||||
"env-ci": "^4.0.0",
|
||||
"execa": "^3.2.0",
|
||||
"env-ci": "^5.0.0",
|
||||
"execa": "^4.0.0",
|
||||
"figures": "^3.0.0",
|
||||
"find-versions": "^3.0.0",
|
||||
"get-stream": "^5.0.0",
|
||||
@@ -39,14 +39,14 @@
|
||||
"hook-std": "^2.0.0",
|
||||
"hosted-git-info": "^3.0.0",
|
||||
"lodash": "^4.17.15",
|
||||
"marked": "^0.7.0",
|
||||
"marked": "^0.8.0",
|
||||
"marked-terminal": "^3.2.0",
|
||||
"micromatch": "^4.0.2",
|
||||
"p-each-series": "^2.1.0",
|
||||
"p-reduce": "^2.0.0",
|
||||
"read-pkg-up": "^7.0.0",
|
||||
"resolve-from": "^5.0.0",
|
||||
"semver": "^6.0.0",
|
||||
"semver": "^7.1.1",
|
||||
"semver-diff": "^3.1.1",
|
||||
"signale": "^1.2.1",
|
||||
"yargs": "^15.0.1"
|
||||
@@ -59,14 +59,14 @@
|
||||
"dockerode": "^3.0.0",
|
||||
"file-url": "^3.0.0",
|
||||
"fs-extra": "^8.0.0",
|
||||
"got": "^9.0.0",
|
||||
"got": "^10.2.1",
|
||||
"js-yaml": "^3.10.0",
|
||||
"mockserver-client": "^5.1.1",
|
||||
"nock": "^11.1.0",
|
||||
"nyc": "^14.0.0",
|
||||
"nyc": "^15.0.0",
|
||||
"p-retry": "^4.0.0",
|
||||
"proxyquire": "^2.0.0",
|
||||
"sinon": "^7.2.7",
|
||||
"sinon": "^8.0.4",
|
||||
"stream-buffers": "^3.0.2",
|
||||
"tempy": "^0.3.0",
|
||||
"xo": "^0.25.0"
|
||||
|
||||
@@ -258,3 +258,20 @@ test('Increase version for release on prerelease branch based on highest commit
|
||||
'2.0.0-beta.1'
|
||||
);
|
||||
});
|
||||
|
||||
test('Increase version for release on prerelease branch when there is no regular releases on other branches', t => {
|
||||
t.is(
|
||||
getNextVersion({
|
||||
branch: {
|
||||
name: 'beta',
|
||||
type: 'prerelease',
|
||||
prerelease: 'beta',
|
||||
tags: [{gitTag: 'v1.0.0-beta.1', version: '1.0.0-beta.1', channels: ['beta']}],
|
||||
},
|
||||
nextRelease: {type: 'minor', channel: 'beta'},
|
||||
lastRelease: {version: 'v1.0.0-beta.1', channels: ['beta']},
|
||||
logger: t.context.logger,
|
||||
}),
|
||||
'1.0.0-beta.2'
|
||||
);
|
||||
});
|
||||
|
||||
+36
-22
@@ -2,7 +2,6 @@ import test from 'ava';
|
||||
import tempy from 'tempy';
|
||||
import {
|
||||
getTagHead,
|
||||
isRefInHistory,
|
||||
isRefExists,
|
||||
fetch,
|
||||
getGitHead,
|
||||
@@ -33,6 +32,7 @@ import {
|
||||
gitDetachedHeadFromBranch,
|
||||
gitAddNote,
|
||||
gitGetNote,
|
||||
gitFetch,
|
||||
} from './helpers/git-utils';
|
||||
|
||||
test('Get the last commit sha', async t => {
|
||||
@@ -100,7 +100,7 @@ test('Fetch all tags on a detached head repository', async t => {
|
||||
t.deepEqual((await getTags('master', {cwd})).sort(), ['v1.0.0', 'v1.0.1', 'v1.1.0'].sort());
|
||||
});
|
||||
|
||||
test('Fetch all tags on a repository with a detached head from branch', async t => {
|
||||
test('Fetch all tags on a repository with a detached head from branch (CircleCI)', async t => {
|
||||
let {cwd, repositoryUrl} = await gitRepo();
|
||||
|
||||
await gitCommits(['First'], {cwd});
|
||||
@@ -125,21 +125,32 @@ test('Fetch all tags on a repository with a detached head from branch', async t
|
||||
t.deepEqual((await getTags('master', {cwd})).sort(), ['v1.0.0', 'v1.0.1', 'v1.1.0', 'v2.0.0'].sort());
|
||||
});
|
||||
|
||||
test('Verify if the commit `sha` is in the direct history of the current branch', async t => {
|
||||
// Create a git repository, set the current working directory at the root of the repo
|
||||
const {cwd} = await gitRepo();
|
||||
// Add commits to the master branch
|
||||
const commits = await gitCommits(['First'], {cwd});
|
||||
// Create the new branch 'other-branch' from master
|
||||
await gitCheckout('other-branch', true, {cwd});
|
||||
// Add commits to the 'other-branch' branch
|
||||
const otherCommits = await gitCommits(['Second'], {cwd});
|
||||
await gitCheckout('master', false, {cwd});
|
||||
test('Fetch all tags on a detached head repository with outdated cached repo (GitLab CI)', async t => {
|
||||
const {cwd, repositoryUrl} = await gitRepo();
|
||||
|
||||
t.true(await isRefInHistory(commits[0].hash, 'master', {cwd}));
|
||||
t.falsy(await isRefInHistory(otherCommits[0].hash, 'master', {cwd}));
|
||||
t.falsy(await isRefInHistory(otherCommits[0].hash, 'missing-branch', {cwd}));
|
||||
await t.throwsAsync(isRefInHistory('non-existant-sha', 'master', {cwd}));
|
||||
await gitCommits(['First'], {cwd});
|
||||
await gitTagVersion('v1.0.0', undefined, {cwd});
|
||||
await gitCommits(['Second'], {cwd});
|
||||
await gitTagVersion('v1.0.1', undefined, {cwd});
|
||||
let [commit] = await gitCommits(['Third'], {cwd});
|
||||
await gitTagVersion('v1.1.0', undefined, {cwd});
|
||||
await gitPush(repositoryUrl, 'master', {cwd});
|
||||
|
||||
// Create a clone (as first CI run would)
|
||||
const cloneCwd = await gitShallowClone(repositoryUrl);
|
||||
await gitFetch(repositoryUrl, {cwd: cloneCwd});
|
||||
await gitCheckout(commit.hash, false, {cwd: cloneCwd});
|
||||
|
||||
// Push tag to remote
|
||||
[commit] = await gitCommits(['Fourth'], {cwd});
|
||||
await gitTagVersion('v1.2.0', undefined, {cwd});
|
||||
await gitPush(repositoryUrl, 'master', {cwd});
|
||||
|
||||
// Fetch on the cached repo and make detached head, leaving master outdated
|
||||
await fetch(repositoryUrl, 'master', 'master', {cwd: cloneCwd});
|
||||
await gitCheckout(commit.hash, false, {cwd: cloneCwd});
|
||||
|
||||
t.deepEqual((await getTags('master', {cwd: cloneCwd})).sort(), ['v1.0.0', 'v1.0.1', 'v1.1.0', 'v1.2.0'].sort());
|
||||
});
|
||||
|
||||
test('Verify if a branch exists', async t => {
|
||||
@@ -299,13 +310,16 @@ test('Return falsy if repository is not up to date', async t => {
|
||||
t.falsy(await isBranchUpToDate(repositoryUrl, 'master', {cwd}));
|
||||
});
|
||||
|
||||
test('Return "true" if local repository is ahead', async t => {
|
||||
const {cwd, repositoryUrl} = await gitRepo(true);
|
||||
await gitCommits(['First'], {cwd});
|
||||
await gitPush(repositoryUrl, 'master', {cwd});
|
||||
await gitCommits(['Second'], {cwd});
|
||||
test('Return falsy if detached head repository is not up to date', async t => {
|
||||
let {cwd, repositoryUrl} = await gitRepo();
|
||||
|
||||
t.true(await isBranchUpToDate(repositoryUrl, 'master', {cwd}));
|
||||
const [commit] = await gitCommits(['First'], {cwd});
|
||||
await gitCommits(['Second'], {cwd});
|
||||
await gitPush(repositoryUrl, 'master', {cwd});
|
||||
cwd = await gitDetachedHead(repositoryUrl, commit.hash);
|
||||
await fetch(repositoryUrl, 'master', 'master', {cwd});
|
||||
|
||||
t.falsy(await isBranchUpToDate(repositoryUrl, 'master', {cwd}));
|
||||
});
|
||||
|
||||
test('Get a commit note', async t => {
|
||||
|
||||
@@ -109,6 +109,16 @@ export async function gitCheckout(branch, create, execaOpts) {
|
||||
await execa('git', create ? ['checkout', '-b', branch] : ['checkout', branch], execaOpts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch current git repository.
|
||||
*
|
||||
* @param {String} repositoryUrl The repository remote URL.
|
||||
* @param {Object} [execaOpts] Options to pass to `execa`.
|
||||
*/
|
||||
export async function gitFetch(repositoryUrl, execaOpts) {
|
||||
await execa('git', ['fetch', repositoryUrl], execaOpts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the HEAD sha.
|
||||
*
|
||||
|
||||
@@ -45,10 +45,10 @@ async function start() {
|
||||
|
||||
// Create user
|
||||
await got(`http://${SERVER_HOST}:${SERVER_PORT}/_users/org.couchdb.user:${NPM_USERNAME}`, {
|
||||
json: true,
|
||||
auth: `${COUCHDB_USER}:${COUCHDB_PASSWORD}`,
|
||||
username: COUCHDB_USER,
|
||||
password: COUCHDB_PASSWORD,
|
||||
method: 'PUT',
|
||||
body: {
|
||||
json: {
|
||||
_id: `org.couchdb.user:${NPM_USERNAME}`,
|
||||
name: NPM_USERNAME,
|
||||
roles: [],
|
||||
|
||||
+31
-8
@@ -126,6 +126,7 @@ test('Plugins are called with expected values', async t => {
|
||||
publish: [publish, pluginNoop],
|
||||
success,
|
||||
};
|
||||
const envCi = {branch: 'master', isCi: true, isPr: false};
|
||||
|
||||
const releases = [
|
||||
{
|
||||
@@ -144,7 +145,7 @@ test('Plugins are called with expected values', async t => {
|
||||
|
||||
const semanticRelease = requireNoCache('..', {
|
||||
'./lib/get-logger': () => t.context.logger,
|
||||
'env-ci': () => ({isCi: true, branch: 'master', isPr: false}),
|
||||
'env-ci': () => envCi,
|
||||
});
|
||||
const result = await semanticRelease(options, {
|
||||
cwd,
|
||||
@@ -160,6 +161,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.is(verifyConditions2.callCount, 1);
|
||||
t.deepEqual(verifyConditions2.args[0][0], config);
|
||||
t.deepEqual(verifyConditions2.args[0][1].cwd, cwd);
|
||||
@@ -167,6 +169,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.is(generateNotes1.callCount, 2);
|
||||
t.is(generateNotes2.callCount, 2);
|
||||
@@ -188,6 +191,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][0], config);
|
||||
t.deepEqual(generateNotes2.args[0][1].options, options);
|
||||
@@ -206,6 +210,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(generateNotes3.args[0][0], config);
|
||||
t.deepEqual(generateNotes3.args[0][1].options, options);
|
||||
@@ -224,6 +229,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);
|
||||
|
||||
branch.tags.push({
|
||||
version: '1.0.0',
|
||||
@@ -251,6 +257,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.is(analyzeCommits.callCount, 1);
|
||||
t.deepEqual(analyzeCommits.args[0][0], config);
|
||||
@@ -261,6 +268,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.is(verifyRelease.callCount, 1);
|
||||
t.deepEqual(verifyRelease.args[0][0], config);
|
||||
@@ -272,6 +280,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(generateNotes1.args[1][0], config);
|
||||
t.deepEqual(generateNotes1.args[1][1].options, options);
|
||||
@@ -282,6 +291,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(generateNotes2.args[1][0], config);
|
||||
t.deepEqual(generateNotes2.args[1][1].options, options);
|
||||
@@ -292,6 +302,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(generateNotes3.args[1][0], config);
|
||||
t.deepEqual(generateNotes3.args[1][1].options, options);
|
||||
@@ -302,6 +313,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.is(prepare.callCount, 1);
|
||||
t.deepEqual(prepare.args[0][0], config);
|
||||
@@ -313,6 +325,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.is(publish.callCount, 1);
|
||||
t.deepEqual(publish.args[0][0], config);
|
||||
@@ -324,6 +337,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.is(success.callCount, 2);
|
||||
t.deepEqual(success.args[0][0], config);
|
||||
@@ -344,6 +358,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[1][0], config);
|
||||
t.deepEqual(success.args[1][1].options, options);
|
||||
@@ -355,6 +370,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(result, {
|
||||
lastRelease,
|
||||
@@ -785,7 +801,14 @@ async function addChannelMacro(t, mergeFunction) {
|
||||
const publish = stub().resolves();
|
||||
const success = stub().resolves();
|
||||
|
||||
const config = {branches: [{name: 'master'}, {name: 'next'}], repositoryUrl, tagFormat: `v\${version}`};
|
||||
const config = {
|
||||
branches: [
|
||||
{name: 'master', channel: 'latest'},
|
||||
{name: 'next', channel: 'next'},
|
||||
],
|
||||
repositoryUrl,
|
||||
tagFormat: `v\${version}`,
|
||||
};
|
||||
const options = {
|
||||
...config,
|
||||
verifyConditions,
|
||||
@@ -796,11 +819,11 @@ async function addChannelMacro(t, mergeFunction) {
|
||||
publish,
|
||||
success,
|
||||
};
|
||||
const nextRelease2 = {
|
||||
const nextRelease = {
|
||||
name: 'v2.0.1',
|
||||
type: 'patch',
|
||||
version: '2.0.1',
|
||||
channel: null,
|
||||
channel: 'latest',
|
||||
gitTag: 'v2.0.1',
|
||||
gitHead: commits[2].hash,
|
||||
};
|
||||
@@ -812,13 +835,13 @@ async function addChannelMacro(t, mergeFunction) {
|
||||
const result = await semanticRelease(options, {cwd, env: {}, stdout: {write: () => {}}, stderr: {write: () => {}}});
|
||||
|
||||
t.deepEqual(result.releases, [
|
||||
{...nextRelease2, ...release1, notes, pluginName: '[Function: functionStub]'},
|
||||
{...nextRelease2, notes, pluginName: '[Function: functionStub]'},
|
||||
{...nextRelease, ...release1, notes, pluginName: '[Function: functionStub]'},
|
||||
{...nextRelease, notes, pluginName: '[Function: functionStub]'},
|
||||
]);
|
||||
|
||||
// Verify the tag has been created on the local and remote repo and reference
|
||||
t.is(await gitTagHead(nextRelease2.gitTag, {cwd}), nextRelease2.gitHead);
|
||||
t.is(await gitRemoteTagHead(repositoryUrl, nextRelease2.gitTag, {cwd}), nextRelease2.gitHead);
|
||||
t.is(await gitTagHead(nextRelease.gitTag, {cwd}), nextRelease.gitHead);
|
||||
t.is(await gitRemoteTagHead(repositoryUrl, nextRelease.gitTag, {cwd}), nextRelease.gitHead);
|
||||
}
|
||||
|
||||
addChannelMacro.title = providedTitle => `Add version to a channel after a merge (${providedTitle})`;
|
||||
|
||||
Reference in New Issue
Block a user