qiwi / multi-semantic-release

Proof of concept that wraps semantic-release to work with monorepos.
BSD Zero Clause License
86 stars 34 forks source link

MSR cannot run own tests if PR based on project branch #11

Closed antongolub closed 4 years ago

antongolub commented 4 years ago

env-ci relies on env=process.env and cwd, but the first has an advantage.

env-ci

configuration({env}) {
        // ...
        return {
                         ...
            prBranch: env.TRAVIS_PULL_REQUEST_BRANCH,
            slug: env.TRAVIS_REPO_SLUG,
            root: env.TRAVIS_BUILD_DIR,
        };

semantic-release

  const context = {
    cwd,
    env,
    stdout: stdout || process.stdout,
    stderr: stderr || process.stderr,
    envCi: envCi({env, cwd}),
  };
  // ...
  const {isCi, branch: ciBranch, isPr} = context.envCi;
  // ...
  // Verify config
  await verify(context);

  options.repositoryUrl = await getGitAuthUrl({...context, branch: {name: ciBranch}});
  context.branches = await getBranches(options.repositoryUrl, ciBranch, context);
  context.branch = context.branches.find(({name}) => name === ciBranch);

  if (!context.branch) {
    logger.log(
      `This test run was triggered on the branch ${ciBranch}, while semantic-release is configured to only publish from ${context.branches
        .map(({name}) => name)
        .join(', ')}, therefore a new version won’t be published.`
    );
    return false;
  }

jobs/353878770

FAIL test/lib/multiSemanticRelease.test.js
  ● multiSemanticRelease() › Initial commit (changes in all packages)
    expect(received).toMatch(expected)
    Expected substring: "Created tag msr-test-a@1.0.0"
    Received string:    "[9:52:11 AM] › 🎉  Started multirelease! Loading 4 packages...
    [9:52:11 AM] › ✔  Loaded package msr-test-a
    [9:52:11 AM] › ✔  Loaded package msr-test-b
    [9:52:11 AM] › ✔  Loaded package msr-test-c
    [9:52:11 AM] › ✔  Loaded package msr-test-d
    [9:52:11 AM] › 🎉  Queued 4 packages! Starting release...
    [9:52:11 AM] [msr-test-a] › ℹ  Running semantic-release version 17.1.1
    [9:52:11 AM] [msr-test-b] › ℹ  Running semantic-release version 17.1.1
    [9:52:11 AM] [msr-test-c] › ℹ  Running semantic-release version 17.1.1
    [9:52:11 AM] [msr-test-d] › ℹ  Running semantic-release version 17.1.1
    [9:52:12 AM] [msr-test-c] › ℹ  This test run was triggered on the branch upd, while semantic-release is configured to only publish from master, therefore a new version won’t be published.
    [9:52:12 AM] [msr-test-a] › ℹ  This test run was triggered on the branch upd, while semantic-release is configured to only publish from master, therefore a new version won’t be published.
    [9:52:12 AM] [msr-test-b] › ℹ  This test run was triggered on the branch upd, while semantic-release is configured to only publish from master, therefore a new version won’t be published.
    [9:52:12 AM] [msr-test-d] › ℹ  This test run was triggered on the branch upd, while semantic-release is configured to only publish from master, therefore a new version won’t be published.
    [9:52:12 AM] › 🎉  Released 0 of 4 packages, semantically!
qiwibot commented 4 years ago

:tada: This issue has been resolved in version 3.0.3 :tada:

The release is available on:

Your semantic-release bot :package::rocket: