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

Test/prerelease test yarn #77

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion test/helpers/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function isDirectory(path) {
// Creates testing files on all specified folders.
function createNewTestingFiles(folders, cwd) {
folders.forEach((fld) => {
writeFileSync(`${cwd}/${fld}test.txt`, fld);
writeFileSync(`${cwd}/${fld}test.txt`, `${fld}${Math.random()}`);
});
}

Expand Down
24 changes: 24 additions & 0 deletions test/lib/git.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,30 @@ test("Fetch only prerelease tags", async () => {

const tags = getTags("master", { cwd }, ["beta"]).sort();
expect(tags).toEqual(["[email protected]", "[email protected]"].sort());

// Add new testing files for a new release.
createNewTestingFiles(packages, cwd);
const shaPatch = gitCommitAll(cwd, "fix: add a patch");
expect(shaPatch).toBeTruthy();
gitPush(cwd);

// Capture output.
stdout = new WritableStreamBuffer();
stderr = new WritableStreamBuffer();

// Call multiSemanticRelease() for a second release
// Doesn't include plugins that actually publish.
// Change the master branch from release to prerelease to test bumping.
await multiSemanticRelease(
packages.map((folder) => `${folder}package.json`),
{
branches: [{ name: "master", prerelease: "beta" }, { name: "release" }],
},
{ cwd, stdout, stderr, env }
);

const tagsPatch = getTags("master", { cwd }, ["beta"]).sort();
expect(tagsPatch).toEqual(["[email protected]", "[email protected]", "[email protected]", "[email protected]"]);
});

test("Throws error if obtaining the tags fails", () => {
Expand Down
58 changes: 56 additions & 2 deletions test/lib/multiSemanticRelease.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ describe("multiSemanticRelease()", () => {
result = await multiSemanticRelease(
packages.map((folder) => `${folder}package.json`),
{
branches: [{ name: "master", prerelease: "beta" }, { name: "release" }],
branches: [{ name: "master", prerelease: "beta", channel: "beta" }, { name: "release" }],
},
{ cwd, stdout, stderr, env }
);
Expand Down Expand Up @@ -434,7 +434,61 @@ describe("multiSemanticRelease()", () => {
"msr-test-d": "2.0.0-beta.1",
},
});
}, 10000);

// Add new testing files for a new release.
createNewTestingFiles(packages, cwd);
const shaPatch = gitCommitAll(cwd, "fix: add a patch");
expect(shaPatch).toBeTruthy();
gitPush(cwd);

// Capture output.
stdout = new WritableStreamBuffer();
stderr = new WritableStreamBuffer();

// Call multiSemanticRelease() for a second release
// Doesn't include plugins that actually publish.
// Change the master branch from release to prerelease to test bumping.
result = await multiSemanticRelease(
packages.map((folder) => `${folder}package.json`),
{
branches: [{ name: "master", prerelease: "beta", channel: "beta" }, { name: "release" }],
},
{ cwd, stdout, stderr, env }
);

// Get stdout and stderr output.
const errpatch = stderr.getContentsAsString("utf8");
expect(errpatch).toBe(false);
const outpatch = stdout.getContentsAsString("utf8");
expect(outpatch).toMatch("Started multirelease! Loading 2 packages...");
expect(outpatch).toMatch("Loaded package msr-test-c");
expect(outpatch).toMatch("Loaded package msr-test-d");
expect(outpatch).toMatch("Queued 2 packages! Starting release...");
expect(outpatch).toMatch("Created tag [email protected]");
expect(outpatch).toMatch("Created tag [email protected]");
expect(outpatch).toMatch("Released 2 of 2 packages, semantically!");

expect(result[0].name).toBe("msr-test-c");
expect(result[0].result.nextRelease).toMatchObject({
gitHead: shaPatch,
gitTag: "[email protected]",
type: "patch",
version: "2.0.0-beta.2",
});

expect(result[1].result.nextRelease.notes).toMatch("# msr-test-d [2.0.0-beta.2]");

// ONLY 1 time.
expect(result).toHaveLength(2);

expect(require(`${cwd}/packages/c/package.json`)).toMatchObject({

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to me that this test case contains a problem with module caching. If you use readFileSync instead of require, test case won't fail. Does https://github.com/qiwi/multi-semantic-release/pull/76/files still reproduce your error?

dependencies: {
"msr-test-d": "2.0.0-beta.2",
},
});


}, 20000);
test("Two separate releases (changes in all packages with prereleases)", async () => {
const packages = ["packages/a/", "packages/b/", "packages/c/", "packages/d/"];

Expand Down