Skip to content

Commit

Permalink
fix: override env.TRAVIS_PULL_REQUEST_BRANCH to fix PR checks on trav…
Browse files Browse the repository at this point in the history
…is-ci

closes #11
  • Loading branch information
antongolub committed Jun 26, 2020
1 parent a0329a8 commit e4b1929
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 37 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
],
"scripts": {
"watch": "jest --watchAll",
"jest": "jest --coverage",
"jest": "TRAVIS_PULL_REQUEST_BRANCH=master jest --coverage",
"lint": "eslint ./",
"lint:fix": "eslint --fix ./",
"test": "yarn lint && yarn jest",
Expand Down
23 changes: 0 additions & 23 deletions test/helpers/git.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const execa = require("execa");
const fileUrl = require("file-url");
const gitLogParser = require("git-log-parser");
const { array: getStreamArray } = require("get-stream");
const envCi = require("env-ci");

/**
* @typedef {Object} Commit
Expand Down Expand Up @@ -165,26 +164,6 @@ function gitPush(cwd, remote = "origin", branch = "master") {

// Branches.

/**
* Return current git branch.
* @param {string} cwd The CWD of the Git repository.
* @returns {execa.ExecaSyncReturnValue} Branch name
*/
function gitReleaseBranch() {
const ciCxt = envCi();
const { prBranch, isPr } = ciCxt;

return isPr ? prBranch : "master";
}

/**
* Return the list of release branches.
* @returns {string[]} Branch name
*/
function gitReleaseBranches() {
return ["master"];
}

/**
* Create a branch in a local Git repository.
*
Expand Down Expand Up @@ -336,6 +315,4 @@ module.exports = {
gitGetTagHash,
gitConfig,
gitGetConfig,
gitReleaseBranch,
gitReleaseBranches,
};
17 changes: 4 additions & 13 deletions test/lib/multiSemanticRelease.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const {
gitPush,
gitTag,
gitGetTags,
gitReleaseBranches,
} = require("../helpers/git");

// Clear mocks before tests.
Expand All @@ -26,7 +25,6 @@ describe("multiSemanticRelease()", () => {
test("Initial commit (changes in all packages)", async () => {
// Create Git repo with copy of Yarn workspaces fixture.
const cwd = gitInit();
const branches = gitReleaseBranches();
copyDirectory(`test/fixtures/yarnWorkspaces/`, cwd);
const sha = gitCommitAll(cwd, "feat: Initial release");
const url = gitInitOrigin(cwd);
Expand All @@ -46,7 +44,7 @@ describe("multiSemanticRelease()", () => {
`packages/c/package.json`,
`packages/d/package.json`,
],
{ branches },
{},
{ cwd, stdout, stderr }
);

Expand Down Expand Up @@ -147,7 +145,6 @@ describe("multiSemanticRelease()", () => {
test("No changes in any packages", async () => {
// Create Git repo with copy of Yarn workspaces fixture.
const cwd = gitInit();
const branches = gitReleaseBranches();
copyDirectory(`test/fixtures/yarnWorkspaces/`, cwd);
const sha = gitCommitAll(cwd, "feat: Initial release");
// Creating the four tags so there are no changes in any packages.
Expand All @@ -172,7 +169,7 @@ describe("multiSemanticRelease()", () => {
`packages/d/package.json`,
`packages/b/package.json`,
],
{ branches },
{},
{ cwd, stdout, stderr }
);

Expand Down Expand Up @@ -200,7 +197,6 @@ describe("multiSemanticRelease()", () => {
test("Changes in some packages", async () => {
// Create Git repo.
const cwd = gitInit();
const branches = gitReleaseBranches();
// Initial commit.
copyDirectory(`test/fixtures/yarnWorkspaces/`, cwd);
const sha1 = gitCommitAll(cwd, "feat: Initial release");
Expand Down Expand Up @@ -228,7 +224,7 @@ describe("multiSemanticRelease()", () => {
`packages/b/package.json`,
`packages/a/package.json`,
],
{ branches },
{},
{ cwd, stdout, stderr }
);

Expand Down Expand Up @@ -336,7 +332,6 @@ describe("multiSemanticRelease()", () => {
test("Error if release's local deps have no version number", async () => {
// Create Git repo with copy of Yarn workspaces fixture.
const cwd = gitInit();
const branches = gitReleaseBranches();
copyDirectory(`test/fixtures/yarnWorkspaces/`, cwd);
gitAdd(cwd, "packages/a/package.json");
const sha = gitCommit(cwd, "feat: Commit first package only");
Expand All @@ -352,7 +347,7 @@ describe("multiSemanticRelease()", () => {
const multiSemanticRelease = require("../../");
const result = await multiSemanticRelease(
[`packages/a/package.json`, `packages/c/package.json`],
{ branches },
{},
{ cwd, stdout, stderr }
);

Expand All @@ -365,7 +360,6 @@ describe("multiSemanticRelease()", () => {
test("Configured plugins are called as normal", async () => {
// Create Git repo with copy of Yarn workspaces fixture.
const cwd = gitInit();
const branches = gitReleaseBranches();
copyDirectory(`test/fixtures/yarnWorkspaces/`, cwd);
const sha = gitCommitAll(cwd, "feat: Initial release");
const url = gitInitOrigin(cwd);
Expand Down Expand Up @@ -394,7 +388,6 @@ describe("multiSemanticRelease()", () => {
// Override to add our own plugins.
plugins: ["@semantic-release/release-notes-generator", plugin],
analyzeCommits: ["@semantic-release/commit-analyzer"],
branches,
},
{ cwd, stdout, stderr }
);
Expand All @@ -411,7 +404,6 @@ describe("multiSemanticRelease()", () => {
test("Deep errors (e.g. in plugins) bubble up and out", async () => {
// Create Git repo with copy of Yarn workspaces fixture.
const cwd = gitInit();
const branches = gitReleaseBranches();
copyDirectory(`test/fixtures/yarnWorkspaces/`, cwd);
const sha = gitCommitAll(cwd, "feat: Initial release");
const url = gitInitOrigin(cwd);
Expand All @@ -438,7 +430,6 @@ describe("multiSemanticRelease()", () => {
},
},
],
branches,
},
{ cwd, stdout, stderr }
);
Expand Down

0 comments on commit e4b1929

Please sign in to comment.