Skip to content

Commit

Permalink
chore: Add semantic-release for automatic package releases (#121)
Browse files Browse the repository at this point in the history
* npm install --save-dev semantic-release

* update CircleCI to run a release step

* test out new probot to check pr title

* generate a changelog automatically with @semantic-release/changelog

* npm install -d @semantic-release/git

* remove releasing script

* update releasing doc

* first pass at contributing doc

* edits to contributing guide

* add bit about draft pull requests and how to get PERCY_TOKEN
  • Loading branch information
djones authored Apr 3, 2019
1 parent 9405cbc commit 9876a31
Show file tree
Hide file tree
Showing 6 changed files with 4,979 additions and 337 deletions.
34 changes: 10 additions & 24 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,34 +30,20 @@ jobs:
<<: *test
docker:
- image: circleci/node:8-browsers
# release:
# <<: *test
# steps:
# - add_ssh_keys
# - checkout
# - restore_cache: *restore_cache
# - run: yarn global add @oclif/semantic-release@2 semantic-release@15
# - run: yarn --frozen-lockfile
# - run: |
# export PATH=/usr/local/share/.config/yarn/global/node_modules/.bin:$PATH
# semantic-release -e @oclif/semantic-release
# - save_cache:
# key: v1-yarn-{{checksum ".circleci/config.yml"}}-{{checksum "yarn.lock"}}
# paths:
# - ~/cli/node_modules
# - /usr/local/share/.cache/yarn
# - /usr/local/share/.config/yarn
release:
<<: *test
steps:
- checkout
- run: npm ci
- run: npx semantic-release

workflows:
version: 2
"@percy/agent":
jobs:
- node-10
- node-8
# - release:
# context: org-global
# filters:
# branches: {only: master}
# requires:
# - node-10
# - node-8
- release:
requires:
- node-10
- node-8
145 changes: 145 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
# Contributing to @percy/agent

✨ Thanks for contributing to **@percy/agent**! ✨

As a contributor, here are the guidelines we would like you to follow:
- [Submitting a Pull Request](#submitting-a-pull-request)
- [Coding rules](#coding-rules)
- [Working with the code](#working-with-the-code)

We also recommend that you read [How to Contribute to Open Source](https://opensource.guide/how-to-contribute).

## Submitting a Pull Request

Good pull requests, whether patches, improvements, or new features, are a fantastic help. They should remain focused in scope and avoid containing unrelated commits.

**Please ask first** before embarking on any significant pull requests (e.g. implementing features, refactoring code), otherwise you risk spending a lot of time working on something that the project's developers might not want to merge into the project.

If you have never created a pull request before, welcome 🎉 😄. [Here is a great tutorial](https://opensource.guide/how-to-contribute/#opening-a-pull-request) on how to send one :)

Here is a summary of the steps to follow:

1. [Set up the workspace](#set-up-the-workspace)
2. If you cloned a while ago, get the latest changes from upstream and update dependencies:
```bash
$ git checkout master
$ git pull upstream master
$ rm -rf node_modules
$ npm install
```
3. Create a new topic branch (off the main project development branch) to contain your feature, change, or fix:
```bash
$ git checkout -b <topic-branch-name>
```
4. Make your code changes, following the [Coding rules](#coding-rules)
5. Push your topic branch up to your fork:
```bash
$ git push origin <topic-branch-name>
```
6. [Open a Pull Request](https://help.github.com/articles/creating-a-pull-request/#creating-the-pull-request) with a clear title and description.

**Tips**:
- For ambitious tasks, open a [draft Pull Request](https://github.blog/2019-02-14-introducing-draft-pull-requests/), in order to get feedback and help from the community.
- [Allow @percy/agent maintainers to make changes to your Pull Request branch](https://help.github.com/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork). This way, we can rebase it and make some minor changes if necessary. All changes we make will be done in new commit and we'll ask for your approval before merging them.

## Coding rules

### Source code

To ensure consistency and quality throughout the source code, all code modifications must have:
- No [linting](#lint) errors
- A [test](#tests) for every possible case introduced by your code change
- **100%** test coverage
- [Valid commit message(s)](#commit-message-guidelines)

### Commit message guidelines

#### Atomic commits

If possible, make [atomic commits](https://en.wikipedia.org/wiki/Atomic_commit), which means:
- a commit should contain exactly one self-contained functional change
- a functional change should be contained in exactly one commit
- a commit should not create an inconsistent state (such as test errors, linting errors, partial fix, feature with documentation etc...)

A complex feature can be broken down into multiple commits as long as each one maintains a consistent state and consists of a self-contained change.

#### Type

The type must be one of the following:

| Type | Description |
|--------------|-------------------------------------------------------------------------------------------------------------|
| **build** | Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm) |
| **ci** | Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs) |
| **docs** | Documentation only changes |
| **feat** | A new feature |
| **fix** | A bug fix |
| **perf** | A code change that improves performance |
| **refactor** | A code change that neither fixes a bug nor adds a feature |
| **style** | Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc) |
| **test** | Adding missing tests or correcting existing tests |
#### Examples

```commit
fix: stop graphite breaking when too much pressure applied
```

```commit
feat: add 'graphiteWidth' option
Fix #42
```

```commit
perf: remove graphiteWidth option
BREAKING CHANGE: The graphiteWidth option has been removed.
The default graphite width of 10mm is always used for performance reasons.
```

## Working with the code

### Set up the workspace

[Fork](https://guides.github.com/activities/forking/#fork) the project, [clone](https://guides.github.com/activities/forking/#clone) your fork, configure the remotes and install the dependencies:

```bash
# Clone your fork of the repo into the current directory
$ git clone https://github.com/percy/percy-agent
# Navigate to the newly cloned directory
$ cd percy-agent
# Assign the original repo to a remote called "upstream"
$ git remote add upstream https://github.com/percy/percy-agent
# Install the dependencies
$ npm install
```

### Lint

[@percy/agent](https://github.com/percy/percy-agent) use [tslint](https://github.com/palantir/tslint) for linting.

Before pushing your code changes make sure there are no linting errors with `npm run lint`.

### Tests

You can run the tests with:

```bash
$ npm run test
```

You can test Percy Agent Client with

```bash
$ npm run test-client
```

And the integration tests can be run with:

```bash
$ PERCY_TOKEN=xxx npm run test-integration
```

You can find `PERCY_TOKEN` on your Percy project settings.

16 changes: 1 addition & 15 deletions RELEASING.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
# Releasing

1. `git checkout -b version-bump`
1. `npm login`
1. `npm version x.x.x` - enter new version
1. `git push origin version-bump`
1. Issue a PR for `version-bump` and merge.
1. `git push origin master`
1. `git push --tags`
1. Ensure tests have passed on that tag
1. [Update the release notes](https://github.com/percy/percy-agent/releases) on GitHub
1. `npm publish --access=public` (leave new version blank)
1. [Visit npm](https://www.npmjs.com/package/@percy/agent) and see the new version is live

* Announce the new release,
making sure to say "thank you" to the contributors
who helped shape this version!
Releasing of the `@percy/agent` package is handled automatically with the [semantic-release](https://github.com/semantic-release/semantic-release) package.
Loading

0 comments on commit 9876a31

Please sign in to comment.