Giter VIP home page Giter VIP logo

pr-bumper's Introduction

pr-bumper
Travis Coveralls NPM

Use text from a pull request description to automatically bump the version number of a project upon merge. pr-bumper performs three main tasks:

  1. Check if an open pull request has the appropriate version bump scope in its description.
  2. Update the version of package.json when a pull request is merged based on the scope from the pull request.
  3. Create a tag of the new version after the bump commit.

There are also a number of additional tasks that can be enabled by setting the appropriate values in .pr-bumper.json See below for more info on the available optional features.

Pull Requests

pr-bumper uses Semantic Versioning.

Pull request descriptions must include a directive indicating the scope of the change being made (major/minor/patch/none). Directives are case insensitive and wrapped in # to avoid a description such as

Fixing a major bug in the code

being considered a major change.

We also support the aliases of breaking, feature, and fix.

In addition, pre-release tags on versions are supported, but only for the patch or none scope. When using minor or major with a pre-release tag, the pre-release tag will be cleared.

NOTE pr-bumper never introduces a pre-release tag, it only supports an existing pre-release tag. If you want to use a pre-release tag, you'll need to add it manually to the version in your package.json as part of your PR, then pr-bumper will be able to do a patch bump to increment the last number in the pre-release for you.

Starting Version Directive Ending Version
1.2.3 #none# 1.2.3
1.2.3-alpha.4 #none# 1.2.3-alpha.4
1.2.3 #patch# or #fix# 1.2.4
1.2.3-alpha.4 #patch# or #fix# 1.2.3-alpha.5
1.2.3-a.b.9 #patch# or #fix# 1.2.3-a.b.10
1.2.3 #minor# or #feature# 1.3.0
1.2.3-alpha.4 #minor# or #feature# 1.3.0
1.2.3 #major# or #breaking# 2.0.0
1.2.3-alpha.4 #major# or #breaking# 2.0.0

GFM Checklist support

You may also specify a list of possible scopes in a GFM checklist Example:

This project uses semver, please check the scope of this pr:

  • #none# - documentation fixes and/or test additions
  • #patch# - backwards-compatible bug fix
  • #minor# - adding functionality in a backwards-compatible manner
  • #major# - incompatible API change

Combined with Pull Request Templates, contributors who are unfamiliar with pr-bumper will know exactly what to do before the build fails.

Integrations

pr-bumper currently supports pull requests on GitHub, Bitbucket, and Bitbucket Server

It is also optimized to work with Travis CI out-of-the box, but can be configured to work with TeamCity or Bamboo as well using the .pr-bumper.json config file.

Installation

npm install -g pr-bumper@^3.0.0

The specific version range is important so that you don't pick up a breaking major version bump without meaning to, for example in your CI script.

Usage

You can check for the existence of a valid directive in the current (open) pr (during the pr build) by using

pr-bumper check

If you set config.features.coverage.enabled to true in your .pr-bumper.json, you can compare your current code coverage against the saved baseline in package.json by using:

pr-bumper check-coverage

NOTE You must wait until after your tests have run to perform the above check, or there will be no new coverage info for pr-bumper to check against the baseline.

You can perform the automated bump in the merge build by using:

pr-bumper bump

Configuration

If you're using Travis CI and public GitHub, pr-bumper will probably work well for you out-of-the-box. However, you can create a .pr-bumper.json file at the root of your repository to override any of the defaults. Here are the defaults that are provided by pr-bumper and can be overwritten by defining them in your own .pr-bumper.json file:

{
  "ci": {
    "env": {
      "branch": "TRAVIS_BRANCH",
      "buildNumber": "TRAVIS_BUILD_NUMBER",
      "pr": "TRAVIS_PULL_REQUEST",
      "repoSlug": "TRAVIS_REPO_SLUG"
    },
    "gitUser": {
      "email": "[email protected]",
      "name": "Travis CI"
    },
    "provider": "travis"
  },
  "features": {
    "changelog": {
      "enabled": false,
      "file": "CHANGELOG.md"
    },
    "comments": {
      "enabled": false
    },
    "compliance": {
      "enabled": false,
      "production": false,
      "output": {
        "requirementsFile": "js-requirements.json",
        "reposFile": "repos",
        "ignoreFile": "ignore"
      },
      "additionalRepos": []
    },
    "coverage": {
      "enabled": false,
      "file": "coverage/coverage-summary.json"
    },
    "dependencies": {
      "enabled": false,
      "snapshotFile": "dependency-snapshot.json"
    },
    "maxScope": {
      "enabled": false,
      "value": "major"
    },
    "logging": {
      "enabled": false,
      "file": "pr-bumper-log.json"
    }
  },
  "vcs": {
    "domain": "github.com",
    "env": {
      "readToken": "RO_GH_TOKEN",
      "writeToken": "GITHUB_TOKEN",
      "username": "",
      "password": ""
    },
    "provider": "github",
    "repository": {
      "name": "",
      "owner": ""
    }
  }
}

You'll notice the data in .pr-bumper.json is separated into three top-level properties, ci, features and vcs. ci and vcs help pr-bumper work with your particular environment, while features allows you to enable and configure optional features within pr-bumper.

ci

Holds all the information pr-bumper needs to interact with your continuous integration system.

ci.env

Defines the names of the environment variables that pr-bumper needs to find out information about the current build.

ci.env.branch

The name of the environment variable that holds the current branch being built (on a merge build) or the target branch of a pull request (on a pr build).

The default is TRAVIS_BRANCH which is already set in Travis CI.

If you're using a provider of teamcity, you'll want to specify your own value here (e.g. TEAMCITY_BRANCH).

Don't forget you'll need to update your build step in TeamCity to set the variable as well:

export TEAMCITY_BRANCH="%teamcity.build.branch%"
ci.env.buildNumber

The name of the environment variable that holds the number of the current build.

The default is TRAVIS_BUILD_NUMBER which is already set in Travis CI.

If you're using a provider of teamcity, you'll want to specify your own value here (e.g. TEAMCITY_BUILD_NUMBER)

Don't forget you'll need to update your build step in TeamCity to set the variable as well:

export TEAMCITY_BUILD_NUMBER="%teamcity.build.id%"
ci.env.pr

The name of the environment variable that holds the number of the pull request (on a pr build) or false (on a merge build)

The default is TRAVIS_PULL_REQUEST which is already set in Travis CI.

If you're using a provider of teamcity or bamboo, you'll want to specify your own value here (e.g. TEAMCITY_PULL_REQUEST)

Don't forget you'll need to update your build step in TeamCity to set the variable as well:

stripped_branch=\$(echo "%teamcity.build.branch%" | sed -e "s/\/merge//")
re='^[0-9]+$'
if [[ \$stripped_branch =~ \$re ]]
then
    export TEAMCITY_PULL_REQUEST="\$stripped_branch"
else
    export TEAMCITY_PULL_REQUEST="false"
fi
ci.env.repoSlug

The name of the environment variable that holds the slug for the repository <owner>/<name>.

The default is TRAVIS_REPO_SLOG which is already set in Travis CI.

If you're using a provider of teamcity, there isn't a clean way of getting that information, so you can provide the owner of the repository (GitHub organization or Bitbucket project) via the vcs.repo.owner field. Similarly, you can provide the name of the repository via the vcs.repo.name field.

ci.gitUser

Information about the git user that will be used by pr-bumper to make the version bump commit and create the tag for the release.

ci.gitUser.email

You guessed it, the email address of the git user.

ci.gitUser.name

Surprisingly enough, the name of the git user.

ci.provider

pr-bumper currently supports travis (the default), teamcity and bamboo. When using travis, the only thing you'll probably want to configure is the ci.gitUser

features

Holds individual properties for configuring optional features of pr-bumper. None of them are enabled by default.

features.changelog

pr-bumper includes support for managing your CHANGELOG.md file for you. When this feature is enabled (by setting config.features.changelog.enabled to true) pr-bumper augments the behavior of some of its commands.

pr-bumper check

This command will now also check the PR description for the existence of a # CHANGELOG section, and throw an error if one is not found.

pr-bumper bump

This command will now also take all the content below the # CHANGELOG line, and prepend it to the CHANGELOG.md. It will give this new content a heading with the newly bumped version number, along with the date (in ISO yyyy-mm-dd format, based on UTC timezone)

So, if your project is at version 1.2.3 and you have a PR description that looks like:

This is a new #feature#

# CHANGELOG
 * **Added** the ability to do fizz-bang

that is merged on January 15th, 2017, pr-bumper will prepend your CHANGELOG.md with the following:

# 1.3.0 (2017-01-15)
 * **Added** the ability to do fizz-bang

features.changelog.enabled

Set this value to true to enable changelog processing

features.changelog.file

The file to prepend when adding the # CHANGELOG section of your pull request description (default is CHANGELOG.md).

features.comments

pr-bumper has the ability to post comments to the pull request in certain scenarios. Unfortunately, due to the fact that posting comments requires write permissions, and Travis CI does not allow access to secure environment variables during pull request builds (for good reason), posting comments to pull requests is not supported when using Travis CI.

If anyone has any ideas on how to make that work, permission-wise, we'd love to add that support.

For all others (which for now is just TeamCity), one can enable posting pull request comments by setting features.comments.enabled to true.

When that flag is set, pr-bumper will post comments to pull requests in the following situations:

  • If pr-bumper check fails because there is no valid PR scope is found in the PR description.
  • If pr-bumper check fails because there is no # CHANGELOG section is found in the PR description (only if features.changelog.enabled is true)
  • If pr-bumper check-coverage fails because code coverage decreases (only if features.coverage.enabled is true)
  • If pr-bumper check-coverage succeeds (only if features.coverage.enabled is true)
features.comments.enabled

Set this value to true to enable PR comments (everywhere but Travis CI)

features.compliance

pr-bumper has the ability to generate a report about what libraries your project is using and what licenses those libraries are published under.

features.compliance.enabled

Set this value to true to enable compliance reporting.

features.coverage

pr-bumper supports ensuring that code coverage is not decreasing because of a pull request. This is achieved by comparing the current code coverage against a saved "baseline" coverage percentage. Enabling this feature is done by setting features.coverage.enabled to true. The baseline coverage will be stored in package.json in the the following format:

"pr-bumper": {
  "coverage": 85.93
}

When enabling the coverage feature, you can either manually create the initial baseline percentage, or let pr-bumper do so after its first pr-bumper bump command.

Enabling this feature enables the following command:

pr-bumper check-coverage

This will compare your current coverage info against the baseline in package.json and throw an error if it is lower than the baseline.

It also augments the following command:

pr-bumper bump

This will now also update the baseline coverage in package.json or write it, if it doesn't yet exist.

features.coverage.enabled

Set this value to true to enable coverage checking. Don't forget you also need to add an entry in package.json for the baseline coverage to compare against.

features.coverage.file

The path to the coverage file to use when comparing against the baseline. The path is relative to the root of the repository (or, more accurately, wherever pr-bumper is being run from). It defaults to coverage/coverage-summary.json. While the location of the file is configurable, the format is not. It is assumed to be the format used by istanbul when using the json-summary reporter. There are a number of statistics available in the json-summary report, but the ones that pr-bumper looks at are:

  • total.statements.total
  • total.statements.covered
  • total.branches.total
  • total.branches.covered

Basically, it aggregates the statements and branches totals and calculates a covered/total percentage for that aggregation. This is so that both branches and statements are included in the single coverage number that pr-bumper deals with, to give it more accuracy than just checking a single statistic.

features.dependencies

pr-bumper has the ability to automatically use npm shrinkwrap to output a dependency-snapshot.json file for every release. This lets you see exactly what versions of all your dependencies were in use when that version was built.

When enabled, it will augment the following command:

pr-bumper bump

In the same commit that bumps the version, pr-bumper will use npm shrinkwrap to spit out a dependency snapshot at the time of that release, which will then be included in the tag for that release, providing a snapshot of exactly what versions of every nested dependency was used at the time of the build for that release. Such a snapshot can be very useful in trying to find out what downstream dependency changed to break your project.

features.dependencies.enabled

Set this value to true to enable the dependency snapshot feature.

features.dependencies.snapshotFile

The name of the file to generate when creating a dependency snapshot (default is dependency-snapshot.json)

features.maxScope

Make sure not to accept bumps of a higher scope than you want. Ideal for maintenance branches, to prevent a major bump that would conflict with the main branch. The order from least to greatest of scopes is:

  • none
  • patch
  • minor
  • major

So, if features.maxScope.value is major (the default), all bumps are allowed. If features.maxScope.value is patch, only none and patch are allowed. You get the idea.

features.maxScope.enabled

Set this value to true to enable the maxScope check.

features.maxScope.value

The value to use for the maximum scope (default is major), must be one of [major, minor, patch, none]

features.logging

Log what pr-bumper does during a bump to a file, so the information can be used by another tool later on.

The log file that will be created will look something like this:

{
  "changelog": "### Added\n- Some cool new feature",
  "pr": {
    "number": 123,
    "url": "https://github.com/ciena-blueplanet/pr-bumper/pull/123"
  },
  "scope": "minor",
  "version": "1.3.0",
}
  • changelog - The full text of the changelog that was added during this bump
  • pr.number - The pull request number that was merged for this bump
  • pr.url - The URL for the pull request that was merged for this bump
  • scope - the scope of the bump performed
  • version - the new version after the bump
features.logging.enabled

Set this value to true to enable the creation of the log file during a bump.

features.logging.file

The name of the file to create after a bump, the contents of the file will be json regardless of the name of the file given here.

vcs

Holds all the information pr-bumper needs to interact with your version control system.

vcs.domain

The domain of your VCS. This would be github.com (the default) if using public github, or the domain of your private GitHub Enterprise or Bitbucket Server instance.

vcs.env

Holds the names of environment variables pr-bumper uses to interact with your VCS.

vcs.env.readToken

The name of the environment variable that holds the read only access token to use when accessing the GitHub API. While one can access the GitHub API just fine without a token, there are rate-limits imposed on anonymous API requests. Since those rate-limits are based on the IP of the requester, you'd be sharing a limit with anyone else building in your CI, which, for Travis CI, could be quite a few people. So, if you specify a vcs.env.readToken and set the corresponding environment variable in your CI environment, pr-bumper will use that token when making API requests to find out information about pull requests. Since we need to be able to access RO_GH_TOKEN during a PR build, it cannot be encrypted, and thus will not be private. See travis docs for more info about encrypted environment variables.

NOTE Since RO_GH_TOKEN is not secure, it is printed directly into your Travis Logs!!! So, make sure it has only read access to your repository. Hence the name RO_GH_TOKEN (Read Only GitHub Token)

vcs.env.writeToken

The name of the environment variable that holds the write access token to use when pushing commits to your vcs (specifically GitHub). Since this environment variable stores a token with write access to your repository, it must be encrypted. The default value is GITHUB_TOKEN. Here's an example of how you can encrypt a GITHUB_TOKEN into your .travis.yml for use in Travis CI. If you have a private CI, you can probably just configure the environment variable.

In case you're unfamiliar, GitHub allows users to create Personal Access Tokens to allow various levels of access to external systems. The public_repo access is sufficient for pr-bumper to be able to push commits and create tags on your behalf. You'll want to create this token on whatever GitHub user you want to be responsible for your version bump commits and automatic release tags. Once you've got a Personal Access Token with the correct permissions, you'll want to encrypt it into .travis.yml to let it be accessible in your merge builds, but not publicly available.

You can do so by using the Travis Client to travis encrypt your token.

First, you'll need to authenticate with travis (you can use the same token for that)

travis login --github-token <your-token>
travis encrypt GITHUB_TOKEN=<your-token> --add -r <owner>/<repo>

If you do not use a fork workflow and your origin is the main repository, you can skip the -r <owner>/<repo> part. Otherwise, replace the <owner>/<repo> with the organization and name of your upstream repository.

vcs.env.username and vcs.env.password

The names of the environment variables that hold credentials for a Bitbucket Server user with write permissions on your repository. This is necessary when using a provider of bitbucket-server since Bitbucket Server doesn't have a Personal Access Token concept like GitHub and GitHub Enterprise do.

vcs.provider

pr-bumper currently supports three VCS providers: github (the default), github-enterprise, and bitbucket-server. When using github the defaults should be sufficient, when using github-enterprise make sure to remember to set vcs.domain to point to your GitHub Enterprise instance. When using bitbucket-server, make sure to set the following:

  • vcs.domain
  • vcs.env.username
  • vcs.env.password
  • vcs.repository.name
  • vcs.repository.owner

vcs.repository

Holds info about the name and organization of the repository. Not required when using a travis CI, but necessary when using a teamcity CI.

vcs.repository.name

The name of the repository (no matter what kind of VCS you have).

vcs.repository.owner

The name of the project that holds your repository (in Bitbucket Server), or the name of the organization that holds your repository (in GitHub and GitHub Enterprise).

Integrations

Travis CI

pr-bumper is optimized to work with Travis CI and by default uses Travis CI environment variables for configuration.

Add the following snippet to your .travis.yml file to integrate pr-bumper

before_install:
  - npm install -g pr-bumper@^3.0.0

install:
  - $(npm root -g)/pr-bumper/.travis/maybe-install.sh

before_script:
  - $(npm root -g)/pr-bumper/.travis/maybe-check-scope.sh

script:
  - $(npm root -g)/pr-bumper/.travis/maybe-test.sh
  - $(npm root -g)/pr-bumper/.travis/maybe-bump-version.sh

after_success:
  - $(npm root -g)/pr-bumper/.travis/maybe-publish-coverage.sh

deploy:
  on:
    all_branches: true
    node: '6.11.0'
    tags: true

This will allow pr-bumper to be installed for your build, allow it to check for the existence of version-bump comments on your PRs, as well as allow it to automatically version-bump and git tag your releases before you deploy them. You'll notice that in the deploy section we tell Travis to deploy for all branches when a tag is part of the commit. The way this works is when you merge a pull request the merge build will run the tests as well as the pr-bumper bump command. As part of this build a new commit will be pushed back to your VCS firing off two new builds, one for the branch and one for the tag. The build for the branch will be exited as soon as possible as we don't care about that build. The build for the tag is where the actual deployment to npm will occur.

NOTE: The above snippet uses the scripts from this project itself which may or may not suite your needs. If you find one of the scripts doesn't do exactly what you need, then copy it directly into your project, modify it, and update the Travis config to run you modified copy instead.

Bitbucket / TeamCity

You can now configure pr-bumper to work with something other than Travis CI and GitHub. The only other configuration that has been tested is TeamCity and Bitbucket Server. Example TeamCity and Bitbucket Server configuration:

{
  "config": {
    "ci": {
      "env": {
        "branch": "TEAMCITY_BRANCH",
        "buildNumber": "TEAMCITY_BUILD_NUMBER",
        "pr": "TEAMCITY_PULL_REQUEST"
      },
      "gitUser": {
        "email": "ci-user",
        "name": "[email protected]"
      },
      "provider": "teamcity",
      "repository": {
        "owner": "my-bitbucket-project",
        "name": "my-bitbucket-repository"
      }
    },
    "vcs": {
      "domain": "bitbucket.my-company-domain.com",
      "env": {
        "username": "BITBUCKET_USERNAME",
        "password": "BITBUCKET_PASSWORD"
      },
      "provider": "bitbucket-server"
    }
  }
}

Example Bamboo and Bitbucket configuration:

  {
    "config": {
      "ci": {
        "env": {
          "branch": "$bamboo_BRANCH",
          "buildNumber": "$bamboo_BUILD_NUMBER",
          "pr": "$bamboo_PULL_REQUEST"
        },
        "gitUser": {
          "email": "ci-user",
          "name": "[email protected]"
        },
        "provider": "bamboo",
        "repository": {
          "owner": "my-bitbucket-project",
          "name": "my-bitbucket-repository"
        }
      },
      "vcs": {
        "domain": "api.bitbucket.org",
        "env": {
          "username": "$bamboo_BITBUCKET_USERNAME",
          "password": "$bamboo_BITBUCKET_PASSWORD"
        },
        "provider": "bitbucket"
      }
    }
  }

pr-bumper's People

Contributors

cstolli avatar dafortin avatar ewhite613 avatar iftachk avatar job13er avatar juwara0 avatar notmessenger avatar quincyle avatar sandersky avatar sglanzer avatar sophypal avatar travis-ci-ciena avatar zakhenry avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pr-bumper's Issues

Update docs to specify required RO_GH_TOKEN

I think this may have been a change in travis or something, but the RO_GH_TOKEN now needs to be added in addition to the GITHUB_TOKEN. Also note that they should be different and the ro token should have no claims granted as it is echoed to the travis log (!)

Allow option to make #CHANGELOG section in description mandatory

On the opposite side of the spectrum from #43, it would also be nice to be able to configure pr-bumper to fail if someone leaves off the #CHANGELOG section (for folks who want to enforce it).

This would be nice to combine with #25 so that both failures can make comments on the PR to indicate what failed.

Handle out-of-sequence PR merges

Currently, the pr-bumper assumes that the commit immediately previous to the Merge commit is the commit in the PR. That's not always the case. Sometimes another PR may have been merged between the last commit of a PR and it getting merged.

A better way may be looking for the most recent Merge commit and parsing out the PR # from that commit message to fetch the description of the PR.

GFM Checklist support does not support the "*" character for lists, only "-"

We can either modify the regex here -

const gfmCheckbockRegex = /-\s\[x\].*?#(\w+)#/gi
- to accept either or indicate in this section of the README - https://github.com/ciena-blueplanet/pr-bumper#gfm-checklist-support - that you can only create the lists with the - character.

We should modify the regex to support both to lessen the burden on the user, unless there is a reason we cannot do this that I am unaware of.

PROPOSAL: Capture information during the bump process and make it available to other processes

While a new PR is being released information such as the version, scope, changelog, etc is gathered by pr-bumper. I propose that as this information is gathered it is held onto until completion of publishing and then it makes it available as an object on an environment variable. This way other process running in the CI environment can then utilize this information without have to obtain it on their own.

[Feature Request] support GFM checkboxes to detect the scope

It would be handy to be able to have a list of options defined in a pull request template that the requester can just tick rather than having to remember the syntax.

For example in the PR template

Check the scope of this pr:

  • #patch# - bugfix, dependency update
  • #minor# - new feature, backwards compatible
  • #major# - major feature, probably breaking API
  • #breaking# - any change that breaks the API

I think this would be best placed in the catch case where more than one scope is detected - https://github.com/ciena-blueplanet/pr-bumper/blob/master/lib/utils.js#L160

Here is an example regex I put together to test the concept

const [match, scope] = /-\s\[x\].*?#(\w+)#/g.exec(`
### Check the scope of this pr:
- [ ] #patch# - bugfix, dependency update
- [x] #minor# - new feature, backwards compatible
- [ ] #major# - major feature, probably breaking API
- [ ] #breaking# - any change that breaks the API`);
> match
"- [x] #minor#"
> scope
"minor"

Happy to create a PR for it, just want to know if there is interest in the feature before I bother

Commits to master branch cause version releases to be messed up

Whenever a repository has changes made to the master branch (either via 1) changes made directly via the GitHub.com UI, 2) changes made in the master branch and pushed and a PR merged, or 3) changes made in the master branch of a fork and a PR merged (such as in ciena-frost/ember-frost-info-bar#89)) a new MAJOR version is released regardless of the Semver value provided in the PR description and the previous version's CHANGELOG.md contents are used.

See ciena-frost/ember-frost-info-bar#90 as an example of the cause and the problems created and ciena-frost/ember-frost-info-bar#91 as an example of how have to clean it up.

https://github.com/ciena-blueplanet/ciena-devops-testbed can be used to troubleshoot and address this issue.

Doesn't work with squashed commits

Github has a merge and squash feature, which this project doesn't play well with. In lib/utils.js _getLastPr() makes the assumption that ALL merged pull requests commits will contain pull request # but for a squash and merge commit this doesn't hold true. See below for an example:

screen shot 2018-03-02 at 8 48 23 pm

In the above example pr-bumper will always skip over my squash and merge commits and thus it isn't using the correct pull request info for bumping.

Don't assume master branch

Currently PR bumper only works on the master branch as it tries to push to the master branch explicitly. Instead it should be smarter and allow pushing to whatever branch is currently being bumped.

Add safeguard from MAJOR bumping in a maintenance branch

We want to support branches like 1.x and being able to submit patches or minor changes to those, but should guard agains MAJOR bumps occurring when the target is a maintenance branch.

Quickest and dirtiest way to do this would be to error when a major is requested against anything but master

Slightly less dirty is to allow overriding what the "main" branch is in .pr-bumper.json

Add documentation about not making changes directly to master branch or performing squash merges or rebase merges

Per the conversation in #142 making changes directly to the master branch of a repo without the use of a PR or the merging of a PR as either a squash merge or a rebase merge will cause a new version to released with the previous PR's scope and CHANGELOG.md contents to be used. This is not desirable, but per #142 (comment) it has not yet been determined how this can be prevented programmatically so in the meantime it should be noted in the README.md that this behavior should be avoided.

Configuration setting to pr-bumper to always assume #PATCH#

In our workflow, we use pr-bumper to version our application which only ever sees #PATCH# releases unless it's time to do a release to a customer, which happens very seldom. If a developer accidentally puts a #MINOR# on the PR and another developer doesn't catch it, then Bad Things Happen: we have to manually revert the version, we have to clear out tags, and we have to get Special Permission from devops to clear out the build artifacts.

It would be nice if pr-bumper could be configured to never accept anything other than a #PATCH# — or better yet, to just always assume #PATCH#. Then if we need to do #MINOR# releases, we could just manually bump package.json

Figure out what's up with codecov

Seems like codecov data is messed up b/c we're not getting diffs anymore. Something about not having a base number or something. We should look into why that is and resolve it.

PROPOSAL: Support dynamic Node version

Currently we look for a hard-coded Node version in various scripts, for example if [[ ! "${PUBLISH_NODE_VERSION:-8.1.2}" =~ ^$TRAVIS_NODE_VERSION ]] in https://github.com/ciena-blueplanet/pr-bumper/blob/master/.travis/maybe-bump-version.sh#L10

I propose that we support the ability for the Node version to be set via a property so that when present it will be used in the scripts and when it is not then a/the default value is used. A likely candidate for where this property could be set is in the .pr-bumper.json file.

This will reduce the need for having to update the version of pr-bumper used in order to get a version of Node only if pr-bumper was released against/for the version desired.

Don't require exact node version for deploy

Update maybe-bump-version.sh and maybe-publish-coverage.sh to work with non-exact Node versions for the deploy part of a Travis config. For example instead of:

deploy:
  provider: npm
  email: [email protected]
  skip_cleanup: true
  on:
    all_branches: true
    node: '8.1.2'
    tags: true

I should be able to do:

deploy:
  provider: npm
  email: [email protected]
  skip_cleanup: true
  on:
    all_branches: true
    node: '8'
    tags: true

This allows you to write Travis configs that always use the latest minor/patch version for a given major.

[Discussion] Should there be a `#none#` directive?

Not sure of the actual keyword, but I was wondering if it would be a good idea to have support for a directive that passes the validation, but does not cause a version bump.

The rationale behind this is that sometimes there may be some changes to a package that result in no code change at all (files that are never pushed to an npm registry). An example would be changes to documentation files that are .npmignored. Or changes to the .travis.yml file.

Normally I would just issue a #patch# change, but this is somewhat problematic when integrating with dependency updating like https://greenkeeper.io or https://gemnasium.com as they will report that an update needs to be made, despite the package having no relevant changes.

I'm on the fence with what is the right answer, so interested to see what others think.

Next MAJOR Release

A place to collect what we'd like to include in the next MAJOR release of pr-bumper (breaking changes)

Please include links to individual issues we'd like to include, specifically the breaking changes, since any MINOR/PATCH changes don't have to go into the MAJOR bump.

Error in CI when running dependencies feature

BUG REPORT

  • I have ensured that the issue isn't already reported
  • I have confirmed that the issue is reproducible with the latest released version
  • I have deleted the FEATURE REQUEST / CODE CHANGE section

Summary

  • Provide a general summary of the issue in the title above

During the merge build of this repo I received an error that npm prune failed.

https://travis-ci.org/ciena-blueplanet/pr-bumper/builds/397363016#L1738

I tracked this down to possibly being from here:

return exec('npm prune')

I have disabled the dependency feature in this repo for the time being:

https://github.com/ciena-blueplanet/pr-bumper#featuresdependencies

Removed:

"dependencies": {

  •  "enabled": true		
    
  • },

from .pr-bumper.josn in PR: #152

Expected Behavior

  • What should happen? The build should not error

Actual Behavior

  • What happens instead of the expected behavior?
  • Is something broken, or not behaving as you expected?
  • Attach a screenshot or recording as appropriate.

The build errors: https://travis-ci.org/ciena-blueplanet/pr-bumper/builds/397363016#L1738

Possible Solution

  • Not obligatory, but suggest a fix/reason for the bug

I tracked this down to possibly being from here:

return exec('npm prune')

Steps to Reproduce

  • How would you describe your issue to someone who doesn’t know you or your project?
  • Try to write a sequence of steps that anybody can repeat to see the issue.
  • Be specific! If the bug cannot be reproduced, your issue may be closed.
  • Provide a link to a live example, include code to reproduce, or direct us to any relevant files as applicable
  • This guide has some additional good information: https://stackoverflow.com/help/mcve

  • Include the contents of your package.json file
  • Steps to reproduce:
    1.
    2.
    3.
    4.
    ...

Context

  • How has this issue affected you? What are you trying to accomplish?
  • Providing context helps us come up with a solution that is most useful in the real world.

Environment

(answer all that are applicable)

  • I am using the latest released version (can check with npm ls <package-name>)
  • My version of Node is: 8.6.0
  • My version of npm is: 5.3.0
  • My OS is:
  • Include the contents of your package.json file

pr-bumper check passing with invalid config

We've seen multiple instances now of improper configured .pr-bumper.json files making it past pr-bumper check only to fail at pr-bumper bump with 404s. We should be failing with the same 404s in pr-bumper check.

We also need to make the error messages more informative:

pr-bumper: ERROR: 404: {}

Is not very informative.

Support "Keep a Changelog" format?

Should we update (or allow a configuration change to enable) supporting the Changelog format suggested in Keep a Changelog?

The main differences between their suggestions and how pr-bumper currently handles things:

  1. Using ## instead of # for each release section
  2. Allowing for an arbitrary top-level # and description above version sections (this means we have to be a little smarter than just pre-pending to the file).

The rest of the conventions have to do with the actual contents of the changelog section for the version. Those could possibly be validated by pr-bumper but I'd leave that as a potential, separate feature, as it would require quite a bit more effort and configuration in .pr-bumper.json likely.

Create a branch whenever a new major release is made

We want to make performing maintenance builds on previous releases as easy as possible. To facilitate this, we should have pr-bumper automatically create a maintenance branch on the previous major version whenever a major bump is made. For example, during the merge build of a #MAJOR# change that will bump the version of a package from 1.4.5 to 2.0.0, the pr-bumper would create a 1.x branch based on the tag of 1.4.5 just after bumping master to 2.0.0

Care will simply need to be taken by developers to not use a #MAJOR# bump on a maintenance release branch, as it would cause confusion and likely errors if/when it collided with the main release stream that had already moved to the next major version.

This is the feature @sglanzer requested and @EWhite613 started in #37, but that needed a little work and was held back so I could do some refactoring in #36. I didn't want to forget about it, just in case it proves more difficult than I first thought and doesn't make it in with the bitbucket server changes.

[BREAKING CHANGE] Update code coverage to look at additional coverage data

The total percentage of statements covered, or total.statements.pct is what is currently considered, per https://github.com/ciena-blueplanet/pr-bumper#code-coverage, however total.branches.pct should be considered as well. The reason for this is because even though a statement of code may be evaluated, not all of the code branches inside of it may be.

An example of this scenario that has been encountered is:

return {
  label: testPoint.get(displayFormat) || '',
  value: testPoint.get('id') || ''
}

where the || '' conditions where never being tested but the statement was reported as being covered.

The pr-bumper.coverage property in the package.json file needs to remain a % value less than 100 so we cannot simply add these two numbers together but instead should average them. This assumes that the averaging of these two numbers gives us an accurate representation of what we are after. If this approach is chosen, it needs to be determined if the combined value would still accurately reflect an improvement in code coverage without the value decreasing.

Updating coverage info in `package.json` overwrites the version bump!

Version 1.6.0 (which was never published due to this bug) introduced a bug where the updating of coverage data in package.json undid the versiony version bump in package.json

I believe this was due to the use of require instead of fs.readFile to read the contents of package.json and not receiving the latest data that had been written to that file.

Coverage is reported as decreased in PRs when it really isn't

(Sorry for the reference to Ciena-internal PR numbers but they might be needed for additional context in the research of this, and I have included screenshots of the relevant information for discussion of this in an open manner since this is an open-source repository)

ISSUE

In MCP-UI PRs the coverage numbers are sometimes being presented as having decreased when in reality they have not ("SCENARIO 1" below). This is occurring when a PR is rebuilt because of merges into the master branch. Sometimes after another rebuild then it reports that there has been no change.

In other scenarios ("SCENARIO 2" below) a PR is submitted that makes changes to a config file, nothing that would affect coverage percentages, and it will report that coverage has dropped but then it is rebuilt and it does not report the same.

SUSPECTED CAUSE

Based on the patterns in the reporting numbers, some of which are presented below, and the scenarios described above, I suspect that this is due to a rounding error either in our code when we make the comparisons or in the underlying code generating the coverage reporting statistics.

SCENARIO 1: MCP PR 583

screen shot 2017-04-21 at 10 13 43 am

The first message written of

Code Coverage: 47.54% (increased 0.09% from 47.45%)

reflects the coverage reporting for this PR and everything is as expected.

The second message written of

Code Coverage: 47.52% (no change)

is the result of this PR being rebuilt due to an update to the master branch. Sometimes these numbers might change, sometimes they might not - just depends on what the change was. So this is an expected result as well.

The third message written of

Code Coverage: 47.52% (increased 0.02% from 47.50%)

gets a little interesting because I would not have expected to have seen the "from 47.50%" text but instead "from 47.52%". If the coverage number from the master branch is what is being used (because that is what is being merged in during the build) then it should have been the 47.52% from the second message written.

The fourth message written of

Code Coverage: 47.51% (dropped 0.01% from 47.52%)

is the one that causes me to suspect a rounding bug because this is the number reported, which represent the current code in the master branch combined with the code in this PR. Yet when the master branch is then merged into this PR and the coverage number are ran again there is no longer a drop of 0.01%. This same discrepancy plays itself out in "Scenario 2" below as well.

SCENARIO 2: MCP PR 584

screen shot 2017-04-21 at 10 47 59 am

This PR changed a value in the package.json file and the first message written of

Code Coverage: 47.51% (dropped 0.01% from 47.52%)

indicates the coverage has decreased, which should not be the case, as well as it is the same 0.01% difference seen in the fourth message written of "Scenario 1".

The second message written of

Code Coverage: 47.50% (dropped 0.02% from 47.52%)

was a result of the PR being rebuilt due to a manual request to do so (in order to clear the previous build failure due to coverage reporting) and not due to any changes in the master branch. This means that the code being evaluated is EXACTLY IDENTICAL yet the code coverage reporting yields different results.

At the time of this issue being created this PR was undergoing its 3rd build, without any changes to the master build, so the outcome of it can be checked at a later time, but there is enough information currently present and captured to represent the scenario.

Commit bump is happening on #none# bump when no change to code coverage has occurred

#Issue Description:

This issue was encountered with pr-bumper version 3.

A PR was created and merged with #none# as the semver. This repo also has code coverage validation enabled. (ciena-frost/ember-frost-core#550)

https://github.com/ciena-frost/ember-frost-core/blob/b58b91d279a23b8c563d363c37c6a306f2cb84dc/.pr-bumper.json#L6-L8

https://github.com/ciena-frost/ember-frost-core/blob/b58b91d279a23b8c563d363c37c6a306f2cb84dc/package.json#L99-L101

screen shot 2018-03-19 at 1 52 45 pm

Error message while running merge build

https://travis-ci.org/ciena-frost/ember-frost-core/jobs/355431705

The command "$(npm root -g)/pr-bumper/.travis/maybe-test.sh" exited with 0.
0.49s$ .travis/maybe-check-coverage.sh
pr-bumper: Code Coverage: `94.22%` (no change)
The command ".travis/maybe-check-coverage.sh" exited with 0.
1.12s$ .travis/maybe-bump-version.sh
pr-bumper: ERROR: Command failed: git commit -m "[pr-bumper] Automated code coverage update" -m "From CI build 1380"
The command ".travis/maybe-bump-version.sh" exited with 1.
cache.2
store build cache
0.01s
15.73schanges detected, packing new archive
.
.
uploading archive
Done. Your build exited with 1.

It appears that what might be happening is that the code coverage information is being written back to the package.json file even when the coverage pct number did not change. This would cause the info.modifiedFiles.length not be equal to 0. (https://github.com/ciena-blueplanet/pr-bumper/blob/master/lib/bumper.js#L339)

A possible fix might be to check to see if the coverage pct changed, and if not, do not write out and update modifiedFiles: In this stanza here: https://github.com/ciena-blueplanet/pr-bumper/blob/master/lib/bumper.js#L532-L535 there should probably be a check to see if it changed, and, if not, don’t write it out and update modifiedFiles

Better error reporting when missing a version-bump directive

It appears that the current version (at least when using bitbucket-server as the vcs), is showing:

Cannot read property 'match' of undefined

when there's no PR description at all (and thus no version-bump directive).

We should have a better error message there.

Re-opening a closed PR causes pr-bumper to not find the PR sha

Sometimes when you start a PR the Travis build won't start automatically. A quick fix for this is to close the PR and reopen the same PR, which starts the travis build. It must change the sha for the PR though, because pr-bumper was unable to find the PR.

Wish I had the log for this - will come back and paste it in the next time it happens.

Allow global yarn install of pr-bumper

pr-bumper works when using using npm install -g pr-bumper but not when using yarn global add pr-bumper. I suspect the yarn global bin isn't on the path while the npm global bin is, but it'd be nice if pr-bumper just supports both ways out-of-box.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.