Skip to content

Commit

Permalink
Set-up Continuous Deployment (#513)
Browse files Browse the repository at this point in the history
  • Loading branch information
kernelwhisperer authored and 0xGabi committed Jun 13, 2019
1 parent 79b42a1 commit 24431bc
Show file tree
Hide file tree
Showing 12 changed files with 177 additions and 18 deletions.
14 changes: 14 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,17 @@ script:
- travis_wait 30 npm run test:e2e
after_success:
- npm run report-coverage
before_deploy:
- echo 'Preparing to deploy to NPM'
- echo 'Cleaning any uncommitted changes'
- echo 'git --no-pager diff'
- git stash
- echo 'Setting up the npm auth token'
- echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" >> $HOME/.npmrc
deploy:
skip_cleanup: true
provider: script
script: 'npm run publish:nightly'
on:
node_js: '11'
tags: true
36 changes: 30 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,35 @@
</h4>
</div>

# aragonCLI Basic Overview
# aragonCLI

The aragonCLI (Command Line Interface) is used to create and develop Aragon apps.
The aragonCLI (Command Line Interface) is used to create and develop Aragon Apps, as well as to
interact with DAOs (create, install apps, inspect permissions, etc.).

| Package | Version | Downloads |
| ----------------------- | --------- | ----------- |
| `@aragon/cli` | [![NPM version](https://img.shields.io/npm/v/@aragon/cli.svg?style=flat-square)](https://npmjs.org/package/@aragon/cli) | [![Downloads](https://img.shields.io/npm/dm/@aragon/cli.svg?style=flat-square)](https://npmjs.org/package/@aragon/cli) |
| `create-aragon-app` | [![NPM version](https://img.shields.io/npm/v/create-aragon-app.svg?style=flat-square)](https://npmjs.org/package/create-aragon-app) | [![Downloads](https://img.shields.io/npm/dm/create-aragon-app.svg?style=flat-square)](https://npmjs.org/package/create-aragon-app) |
## Nightly builds

Nightly builds may contain features in their early stages, expect things to break!

**Get a sneak peek at the next version of the CLI, and help us making it better in the process!**
**Please try it out and let us know early and often if you find any bugs or regressions. Thanks!**

```sh
npm install @aragon/cli@nightly
```

## Stable builds

Periodically, after some testing has been done, we mark `nightly` builds as `stable`.
This build is recommended to most people, especially devs that are getting started and not familiar
with the stack, or anyone who values stability over the bleeding-edge features.

```sh
npm install @aragon/cli
```

## Package overview

| Package | Version (latest/stable) | Version (nightly) | Downloads |
| ------- | ----------------------- | ----------------- | --------- |
| `@aragon/cli` | [![NPM version](https://img.shields.io/npm/v/@aragon/cli/latest.svg?style=flat-square)](https://npmjs.org/package/@aragon/cli) | [![NPM version](https://img.shields.io/npm/v/@aragon/cli/nightly.svg?style=flat-square)](https://npmjs.org/package/@aragon/cli) | [![Downloads](https://img.shields.io/npm/dm/@aragon/cli.svg?style=flat-square)](https://npmjs.org/package/@aragon/cli) |
| `create-aragon-app` | [![NPM version](https://img.shields.io/npm/v/create-aragon-app/latest.svg?style=flat-square)](https://npmjs.org/package/create-aragon-app) | [![NPM version](https://img.shields.io/npm/v/create-aragon-app/nightly.svg?style=flat-square)](https://npmjs.org/package/create-aragon-app) | [![Downloads](https://img.shields.io/npm/dm/create-aragon-app.svg?style=flat-square)](https://npmjs.org/package/create-aragon-app) |
47 changes: 47 additions & 0 deletions docs-internal/Continuous-deployment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Continuous Deployment

Having CD configured in an automated way, allows us to:

- make the release task less time-consuming and less prone to human errors
- decrease the attack surface by not needing maintainers to have publish access

## Setup

### Travis CI

The configuration file is located at `.travis.yml`.

Requirements: this configuration assumes a `NPM_TOKEN` environment variable defined in Travis's
settings. (see [travis docs about env vars][travis-docs-env-vars])

Notes:

- `before_deploy`

This hook runs after the build and testing steps have finished, and is purpose is twofold:

1. Clean-up uncommitted changes resulted from installing or building, e.g.: lockfiles
2. Grant the `npm` agent publish access

- `deploy`

The deploy step uses lerna to publish packages that have been released, but not deployed on `npm`:

```json
"publish:nightly": "lerna publish from-package --dist-tag nightly --yes"
```

The `skip_cleanup` flag tells Travis not to delete files not tracked by git,
such as the build directory of the packages: `dist`.

This step runs only on the v11 of `Node` whenever there are new tags.
(see [`Releasing.md`](/docs-internal/Releasing.md))

## Useful readings

- [lerna publish docs](https://github.com/lerna/lerna/tree/master/commands/publish)
(in particular the `from-package` positional and the `--dist-tag` and `--yes` flags)
- [lerna + travis setup demo](https://github.com/geut/lerna-travis-demo)
- [travis deployment docs](https://docs.travis-ci.com/user/deployment/)

[travis-docs-env-vars]: https://docs.travis-ci.com/user/environment-variables/#defining-variables-in-repository-settings
4 changes: 2 additions & 2 deletions docs-internal/Continuous-integration.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Continuous Integration

Having automated CI setup allows us to:
Having CI configured in an automated way, allows us to:

- reduce the feedback loop between the contributor and the reviewer
- make the reviewing task less time-consuming and less prone to human errors
- reduce the feedback loop between the contributor and the reviewer

## Setup

Expand Down
68 changes: 68 additions & 0 deletions docs-internal/Releasing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Releasing

Terminology for this context:

- Releasing: marking (tagging) a new software version
- Publishing: uploading a new build to the package manager
- Deploying: same as publishing

The act of making a new release is a manual step, as we need to assess whether we should bump a new
major, minor or patch. (see [semver docs](https://semver.org/))

## Preparing

Before releasing let's make sure we are including the latest changes by updating the local branch:

1. `git checkout master`
2. `git pull`
3. `git checkout release/v6.0.0` (the next tag of the `@aragon/cli` package)

Prepare the release notes:

1. Draft a new release on GitHub: <https://github.com/aragon/aragon-cli/releases>
2. Summarize the changes since the last release: <https://github.com/aragon/aragon-cli/commits/master>

## Release all packages that have been updated

1. Run `npm run version` and bump the versions according to the release summary.
2. On GitHub Releases, choose the project-wide tag (`@aragon/cli`'s version) and publish.
3. Wait for the CD agent to finish the automatic deployment. (see [`Continuous-deployment.md`](/docs-internal/Continuous-deployment.md))
4. Make some noise on the `#dev` channel.

## Distribution tags

The tags we use are: `latest`, `stable`, `nightly`.

> By default, `npm install <pkg>` (without any `@<version>` or `@<tag>` specifier) installs the `latest` tag.
>
> By default, other than `latest`, no tag has any special significance to `npm` itself.
To mark a `nightly` build as latest stable:

```sh
npm dist-tag add @aragon/[email protected] stable
npm dist-tag add @aragon/[email protected] latest
```

## Something went wrong

- Revert the last commit:

```sh
git revert HEAD~ --hard
git push --force
```

- Delete the tags, locally and on the remote, i.e.:

```sh
git tag --delete @aragon/[email protected] [email protected]
git push --delete origin @aragon/[email protected] [email protected]
```

Note: you cannot redeploy the same version to npm, a new version must be used.
(see [npm unpublish docs](https://docs.npmjs.com/cli/unpublish))

## Useful readings

- [npm dist tag docs](https://docs.npmjs.com/cli/dist-tag)
4 changes: 2 additions & 2 deletions docs-internal/next/Specification.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ Data viz:
### Devchain API

- `ensureConnection`
- `hasAragonDeployements`
- `hasAragonDeployments`
- `deployAragon`
- `start` -- should save stdout and stderr in some files to be outputed by `aragon devchain output`
- `start` -- should save stdout and stderr in some files to be outputted by `aragon devchain output`

## Web3 `@aragon/web3-utils`

Expand Down
7 changes: 6 additions & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@
"packages": [
"packages/*"
],
"version": "independent"
"version": "independent",
"command": {
"version": {
"allowBranch": ["release/*"]
}
}
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"test:e2e": "lerna run test --scope @aragon/e2e-tests",
"test:coverage": "lerna run test:coverage:ci --ignore @aragon/e2e-tests",
"report-coverage": "lcov-result-merger 'packages/*/coverage/lcov.info' | coveralls",
"publish": "lerna publish"
"release": "lerna version",
"publish:nightly": "lerna publish from-package --dist-tag nightly --yes"
}
}
2 changes: 1 addition & 1 deletion packages/aragon-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"lint": "eslint src test/commands && documentation lint src",
"test": "nyc ava",
"test:watch": "ava --watch",
"test:coverage:ci": "nyc --all --reporter=lcovonly --exclude 'config/**' ava"
"test:coverage:ci": "nyc --all --reporter=lcovonly --exclude 'config/**' --exclude '**/*.test.js' ava"
},
"repository": {
"type": "git",
Expand Down
8 changes: 4 additions & 4 deletions packages/e2e-tests/src/cli/run.test.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ Generated by [AVA](https://ava.li).
Prepare files for publishing [completed]␊
Generate application artifact [started]␊
Generate application artifact [completed]␊
Publish foobarfoo.aragonpm.eth [started]␊
Publish foobarfoo.open.aragonpm.eth [started]␊
Generating transaction [started]␊
→ Fetching DAO at 0x983b4Df4E8458D56CFDC51B9d2149381AF80308A...␊
→ Fetching DAO at 0x9a348D0c3f55c2B3f6A400CC1BE71c882Ff1bdC3...␊
Generating transaction [completed]␊
Sending transaction [started]␊
→ Waiting for transaction to be mined...␊
Sending transaction [completed]␊
Publish foobarfoo.aragonpm.eth [completed]␊
Publish foobarfoo.open.aragonpm.eth [completed]␊
Fetch published repo [started]␊
Fetch published repo [completed]␊
Publish app to APM [completed]␊
Expand Down Expand Up @@ -88,7 +88,7 @@ Generated by [AVA](https://ava.li).
i This is the configuration for your development deployment:␊
Ethereum Node: ws://localhost:8545␊
ENS registry: 0x5f6f7e8cc7346a11ca2def8f827b7a0b612c56a1␊
APM registry: aragonpm.eth␊
APM registry: open.aragonpm.eth␊
DAO address: 0xe5ac265B0FFE4b47C8386D7d715f3a3f6F8fb5B9␊
Opening http://localhost:3000/#/0xe5ac265B0FFE4b47C8386D7d715f3a3f6F8fb5B9 to view your DAO`
Expand Down
Binary file modified packages/e2e-tests/src/cli/run.test.js.snap
Binary file not shown.
2 changes: 1 addition & 1 deletion packages/e2e-tests/src/create-aragon-app/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ test('should create a new aragon app', async t => {
t.falsy(await fs.pathExists(repoPath))
t.falsy(fs.pathExistsSync(licensePath))
t.is(undefined, packageJson.license)
t.is(`${name}.aragonpm.eth`, arapp.environments.default.appName)
t.is(`${name}.open.aragonpm.eth`, arapp.environments.default.appName)
t.is(`${name}.open.aragonpm.eth`, arapp.environments.rinkeby.appName)
t.is(`${name}.open.aragonpm.eth`, arapp.environments.mainnet.appName)
})

0 comments on commit 24431bc

Please sign in to comment.