-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: improve algorithm to detect dependency changes (#74)
* fix: support merge workflows in generateNotes * fix: misalignment between manifest and notes * test: add failing missing dependency test case * fix: cyclic dependency errors * refactor: add helper to find highest release type
- Loading branch information
Showing
8 changed files
with
450 additions
and
196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "msr-test-yarn", | ||
"author": "Joost Reuzel", | ||
"version": "0.0.0-semantically-released", | ||
"private": true, | ||
"license": "0BSD", | ||
"engines": { | ||
"node": ">=8.3" | ||
}, | ||
"workspaces": [ | ||
"packages/*" | ||
], | ||
"release": { | ||
"plugins": [ | ||
"@semantic-release/commit-analyzer", | ||
"@semantic-release/release-notes-generator" | ||
], | ||
"noCi": true | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
test/fixtures/yarnWorkspacesMutualDependency/packages/a/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"name": "msr-test-a", | ||
"version": "1.0.0", | ||
"dependencies": { | ||
"msr-test-b": "1.0.0" | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
test/fixtures/yarnWorkspacesMutualDependency/packages/b/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"name": "msr-test-b", | ||
"version": "1.0.0", | ||
"dependencies": { | ||
"msr-test-a": "1.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1060,4 +1060,99 @@ describe("multiSemanticRelease()", () => { | |
message: expect.stringMatching("Package peerDependencies must be object"), | ||
}); | ||
}); | ||
|
||
test("Changes in packages with mutual dependency", async () => { | ||
// Create Git repo. | ||
const cwd = gitInit(); | ||
// Initial commit. | ||
copyDirectory(`test/fixtures/yarnWorkspacesMutualDependency/`, cwd); | ||
const sha1 = gitCommitAll(cwd, "feat: Initial release"); | ||
gitTag(cwd, "[email protected]"); | ||
gitTag(cwd, "[email protected]"); | ||
// Second commit. | ||
writeFileSync(`${cwd}/packages/a/aaa.txt`, "AAA"); | ||
const sha2 = gitCommitAll(cwd, "feat(aaa): Add missing text file"); | ||
const url = gitInitOrigin(cwd); | ||
gitPush(cwd); | ||
|
||
// Capture output. | ||
const stdout = new WritableStreamBuffer(); | ||
const stderr = new WritableStreamBuffer(); | ||
|
||
// Call multiSemanticRelease() | ||
// Doesn't include plugins that actually publish. | ||
const multiSemanticRelease = require("../../"); | ||
const result = await multiSemanticRelease( | ||
[`packages/a/package.json`, `packages/b/package.json`], | ||
{}, | ||
{ cwd, stdout, stderr }, | ||
{ deps: { bump: "satisfy" }, dryRun: false } | ||
); | ||
|
||
// Get stdout and stderr output. | ||
const err = stderr.getContentsAsString("utf8"); | ||
expect(err).toBe(false); | ||
const out = stdout.getContentsAsString("utf8"); | ||
expect(out).toMatch("Started multirelease! Loading 2 packages..."); | ||
expect(out).toMatch("Loaded package msr-test-a"); | ||
expect(out).toMatch("Loaded package msr-test-b"); | ||
expect(out).toMatch("Queued 2 packages! Starting release..."); | ||
expect(out).toMatch("Created tag [email protected]"); | ||
expect(out).toMatch("Created tag [email protected]"); | ||
expect(out).toMatch("Released 2 of 2 packages, semantically!"); | ||
|
||
const a = 0; | ||
const b = 1; | ||
// A. | ||
expect(result[a].name).toBe("msr-test-a"); | ||
expect(result[a].result.lastRelease).toMatchObject({ | ||
gitHead: sha1, | ||
gitTag: "[email protected]", | ||
version: "1.0.0", | ||
}); | ||
expect(result[a].result.nextRelease).toMatchObject({ | ||
gitHead: sha2, | ||
gitTag: "[email protected]", | ||
type: "minor", | ||
version: "1.1.0", | ||
}); | ||
expect(result[a].result.nextRelease.notes).toMatch("# msr-test-a [1.1.0]"); | ||
expect(result[a].result.nextRelease.notes).toMatch("### Features\n\n* **aaa:** Add missing text file"); | ||
expect(result[a].result.nextRelease.notes).toMatch("### Dependencies\n\n* **msr-test-b:** upgraded to 1.0.1"); | ||
|
||
// B. | ||
expect(result[b].name).toBe("msr-test-b"); | ||
expect(result[b].result.lastRelease).toEqual({ | ||
channels: [null], | ||
gitHead: sha1, | ||
gitTag: "[email protected]", | ||
name: "[email protected]", | ||
version: "1.0.0", | ||
}); | ||
expect(result[b].result.nextRelease).toMatchObject({ | ||
gitHead: sha2, | ||
gitTag: "[email protected]", | ||
type: "patch", | ||
version: "1.0.1", | ||
}); | ||
expect(result[b].result.nextRelease.notes).toMatch("# msr-test-b [1.0.1]"); | ||
expect(result[b].result.nextRelease.notes).not.toMatch("### Features"); | ||
expect(result[b].result.nextRelease.notes).not.toMatch("### Bug Fixes"); | ||
expect(result[b].result.nextRelease.notes).toMatch("### Dependencies\n\n* **msr-test-a:** upgraded to 1.1.0"); | ||
|
||
// ONLY 3 times. | ||
expect(result[2]).toBe(undefined); | ||
|
||
// Check manifests. | ||
expect(require(`${cwd}/packages/a/package.json`)).toMatchObject({ | ||
dependencies: { | ||
"msr-test-b": "1.0.1", | ||
}, | ||
}); | ||
expect(require(`${cwd}/packages/b/package.json`)).toMatchObject({ | ||
dependencies: { | ||
"msr-test-a": "1.1.0", | ||
}, | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.