Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feat/ipfs-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kernelwhisperer committed May 23, 2019
2 parents a5816fa + da08e78 commit 6349189
Show file tree
Hide file tree
Showing 13 changed files with 290 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ install:
script:
- npm run link
- npm run lint
- npm run test
- travis_wait 30 npm run test
after_success:
- ./node_modules/.bin/nyc report --reporter=text-lcov | ./node_modules/.bin/coveralls
61 changes: 61 additions & 0 deletions docs-internal/Reviewing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Reviewing

## A pull request created from a fork

Due to preference or push permissions, some contributors create pull requests from a different
remote than `origin`, i.e. a fork. For example: `aragon:master` < `satoshi:feat/add-consensus`.

### Testing locally (read-only)

- Fetch the branch using a PR reference, and switch to it:

```sh
git fetch origin pull/ID/head:BRANCHNAME
git checkout BRANCHNAME
```

Where:
- `ID` is the PR number (e.g.: `5`)
- `BRANCHNAME` the branch of the PR (e.g.: `feat/add-consensus`)

Note: the remote `refs/pulls` is read-only, we cannot push commits.

### Testing and adding commits

If the pull request creator has [allowed edits from maintaners][allow-edits-docs], and we wish to
add some commits as well, we can proceed like this:

- Add a new remote and switch to a branch tracking it:

```sh
git remote add REMOTE_NAME [email protected]:USER/REPO.git
git checkout -t REMOTE_NAME/BRANCHNAME
```

Where:
- `USER` is the GH account (e.g.: `satoshi`)
- `REPO` the repository (e.g.: `aragon-cli`)
- `REMOTE_NAME` can be anything, but we recommend it to be the same as `USER`

Tips:
- to see the current remotes: `git remote --verbose`
- to remove a remote: `git remote remove <name>`

- Make changes, commit, and push as usual

### Testing and adding commits using `hub`

Alternatively, if we are using the git extension called [hub][hub-ext], which allows us to use
GitHub from the command-line, we can proceed like this:

- Switch to a branch that is tracking the remote using a PR reference:

```sh
hub pr checkout ID
```

Where:
- `ID` is the PR number (e.g.: `5`)

[allow-edits-docs]: https://help.github.com/en/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork#enabling-repository-maintainer-permissions-on-existing-pull-requests
[hub-ext]: https://hub.github.com/
5 changes: 3 additions & 2 deletions packages/aragon-cli/.babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
[
"@babel/preset-env",
{
"useBuiltIns": "entry"
"useBuiltIns": "entry",
"corejs": "2"
}
]
],
"plugins": [
"@babel/plugin-proposal-object-rest-spread"
]
}
}
25 changes: 18 additions & 7 deletions packages/aragon-cli/src/commands/apm_cmds/versions.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,34 @@
const { ensureWeb3 } = require('../../helpers/web3-fallback')
const APM = require('@aragon/apm')
const defaultAPMName = require('../../helpers/default-apm')

exports.command = 'versions'
exports.command = 'versions [apmRepo]'

exports.describe = 'List all versions of the package'
exports.describe = 'List all versions published of the package'

exports.builder = function(yargs) {
return yargs.option('apmRepo', {
description: 'The repo to inspect',
type: 'string',
default: null,
})
}

exports.handler = async function({
reporter,
apmRepo,
module,
bump,
cwd,
network,
apm: apmOptions,
}) {
const web3 = await ensureWeb3(network)

const repoName = apmRepo ? defaultAPMName(apmRepo) : module.appName
apmOptions.ensRegistryAddress = apmOptions['ens-registry']
const versions = await APM(web3, apmOptions).getAllVersions(module.appName)
reporter.info(`${module.appName} has ${versions.length} published versions`)

const versions = await APM(web3, apmOptions).getAllVersions(repoName)

reporter.info(`${repoName} has ${versions.length} published versions`)

versions.map(version => {
if (version && version.content) {
reporter.success(
Expand Down
5 changes: 3 additions & 2 deletions packages/create-aragon-app/.babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
[
"@babel/preset-env",
{
"useBuiltIns": "entry"
"useBuiltIns": "entry",
"corejs": "2"
}
]
],
"plugins": [
"@babel/plugin-proposal-object-rest-spread"
]
}
}
3 changes: 2 additions & 1 deletion packages/e2e-tests/.babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
[
"@babel/preset-env",
{
"useBuiltIns": "entry"
"useBuiltIns": "entry",
"corejs": "2"
}
]
],
Expand Down
2 changes: 1 addition & 1 deletion packages/e2e-tests/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# End-to-end tests

To test only one file, try:
`npm test -- src/cli/ipfs.js`
`npm test -- src/cli/ipfs.test.js`
6 changes: 5 additions & 1 deletion packages/e2e-tests/src/cli/ipfs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ test('should spawn ipfs', async t => {
t.plan(2)

// act
const { exit, stdout } = await startBackgroundProcess('aragon', ['ipfs', '--debug'], 'IPFS daemon is now running.')
const { exit, stdout } = await startBackgroundProcess({
cmd: 'aragon',
args: ['ipfs', '--debug'],
readyOutput: 'IPFS daemon is now running.'
})
const res = await fetch('http://localhost:5001/api/v0/version')
const body = await res.text()

Expand Down
65 changes: 65 additions & 0 deletions packages/e2e-tests/src/cli/run.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import test from 'ava'
import fs from 'fs-extra'
import fetch from 'node-fetch'
import execa from 'execa'
import { startBackgroundProcess, normalizeOutput } from '../util'

const testSandbox = './.tmp/run'

test.beforeEach(() => {
fs.ensureDirSync(testSandbox)
})

test.afterEach(() => {
fs.removeSync(testSandbox)
})

test('should create a new aragon app and run it successfully', async t => {
t.plan(3)

// arrange
const projectName = 'foobarfoo'
await execa('create-aragon-app', [projectName], { cwd: testSandbox })
// hack, we need to install the dependencies of the app
await execa('npm', ['install'], { cwd: `${testSandbox}/${projectName}/app` })

// act
const runProcess = await startBackgroundProcess({
cmd: 'aragon',
args: ['run', '--debug', '--reset'],
execaOpts: { cwd: `${testSandbox}/${projectName}` },
readyOutput: 'Opening http://localhost:3000/#/',
})

// hack so the wrapper has time to start
await new Promise(resolve => setTimeout(resolve, 2 * 60 * 1000))

// finding the DAO address
const daoAddress = runProcess.stdout.match(/DAO address: (0x[a-fA-F0-9]{40})/)[1]

// TODO fetch the counter app instead
const fetchResult = await fetch(`http://localhost:3000/#/${daoAddress}`)
const fetchBody = await fetchResult.text()

// cleanup
await runProcess.exit()

// delete some output sections that are not deterministic
const appBuildOutput = runProcess.stdout.substring(
runProcess.stdout.indexOf('Building frontend [started]'),
runProcess.stdout.indexOf('Building frontend [completed]')
)
const wrapperInstallOutput = runProcess.stdout.substring(
runProcess.stdout.indexOf('Downloading wrapper [started]'),
runProcess.stdout.indexOf('Starting Aragon client [started]')
)

const outputToSnapshot = runProcess.stdout
.replace(appBuildOutput, '')
.replace(wrapperInstallOutput, '')

// assert
t.snapshot(normalizeOutput(outputToSnapshot))
t.snapshot(fetchResult.status)
t.snapshot(fetchBody)
})
123 changes: 123 additions & 0 deletions packages/e2e-tests/src/cli/run.test.js.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# Snapshot report for `src/cli/run.test.js`

The actual snapshot is saved in `run.test.js.snap`.

Generated by [AVA](https://ava.li).

## should create a new aragon app and run it successfully

> Snapshot 1
`[?25lStart a local Ethereum network [started]␊
Setting up a new chain from latest Aragon snapshot [started]␊
Setting up a new chain from latest Aragon snapshot [completed]␊
Starting a local chain from snapshot [started]␊
Local chain started at port 8545 [title changed]␊
Local chain started at port 8545 [completed]␊
Start a local Ethereum network [completed]␊
Check IPFS [started]␊
Start IPFS [started]␊
→ Starting IPFS at port: 5001␊
Start IPFS [completed]␊
Add local files [started]␊
Add local files [completed]␊
Check IPFS [completed]␊
Publish app to APM [started]␊
Applying version bump (major) [started]␊
Applying version bump (major) [completed]␊
Deploy contract [started]␊
Compile contracts [started]␊
Compile contracts [completed]␊
Deploy 'CounterApp' to network [started]␊
→ Deploying 'CounterApp' to network␊
Deploy 'CounterApp' to network [completed]␊
Generate deployment artifacts [started]␊
Generate deployment artifacts [completed]␊
Deploy contract [completed]␊
Determine contract address for version [started]␊
Determine contract address for version [completed]␊
Building frontend [completed]␊
Prepare files for publishing [started]␊
Prepare files for publishing [completed]␊
Generate application artifact [started]␊
Generate application artifact [completed]␊
Publish foobarfoo.aragonpm.eth [started]␊
Generating transaction [started]␊
→ Fetching DAO at 0x983b4Df4E8458D56CFDC51B9d2149381AF80308A...␊
Generating transaction [completed]␊
Sending transaction [started]␊
→ Waiting for transaction to be mined...␊
Sending transaction [completed]␊
Publish foobarfoo.aragonpm.eth [completed]␊
Fetch published repo [started]␊
Fetch published repo [completed]␊
Publish app to APM [completed]␊
Create DAO [started]␊
Fetching template bare-kit.aragonpm.eth@latest [started]␊
Fetching template bare-kit.aragonpm.eth@latest [completed]␊
Create new DAO from template [started]␊
Create new DAO from template [completed]␊
Checking DAO [started]␊
Checking DAO [completed]␊
Create DAO [completed]␊
Open DAO [started]␊
Starting Aragon client [started]␊
→ Starting Aragon client...␊
Starting Aragon client [completed]␊
Opening wrapper [started]␊
→ Opening wrapper␊
Opening wrapper [completed]␊
Open DAO [completed]␊
[?25h i You are now ready to open your app in Aragon.␊
i Here are some Ethereum accounts you can use.␊
The first one will be used for all the actions the CLI performs.␊
You can use your favorite Ethereum provider or wallet to import their private keys.␊
Address #1: 0xb4124cEB3451635DAcedd11767f004d8a28c6eE7 (this account is used to deploy DAOs, it has more permissions)␊
Private key: a8a54b2d8197bc0b19bb8a084031be71835580a01e70a45a13babd16c9bc1563␊
Address #2: 0x8401Eb5ff34cc943f096A32EF3d5113FEbE8D4Eb ␊
Private key: ce8e3bda3b44269c147747a373646393b1504bfcbb73fc9564f5d753d8116608␊
i The accounts were generated from the following mnemonic phrase:␊
explain tackle mirror kit van hammer degree position ginger unfair soup bonus␊
⚠ The devchain was reset, some steps need to be done to prevent issues:␊
- Reset the application cache in Aragon Core by going to Settings > Troubleshooting.␊
- If using Metamask: switch to a different network, and then switch back to the 'Private Network' (this will clear the nonce cache and prevent errors when sending transactions) ␊
i This is the configuration for your development deployment:␊
Ethereum Node: ws://localhost:8545␊
ENS registry: 0x5f6f7e8cc7346a11ca2def8f827b7a0b612c56a1␊
APM registry: aragonpm.eth␊
DAO address: 0xb84dFbdc18069a83af4D5506096f5e7AC7554183␊
Opening http://localhost:3000/#/0xb84dFbdc18069a83af4D5506096f5e7AC7554183 to view your DAO`

> Snapshot 2
200

> Snapshot 3
`<!DOCTYPE html>␊
<html lang="en">␊
<head>␊
<meta charset="utf-8">␊
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, maximum-scale=1, user-scalable=no">␊
<link rel="shortcut icon" type="image/svg+xml" href="/favicon.caf9c731.svg">␊
<link rel="shortcut icon" type="image/png" href="/favicon.6d47dbe5.png">␊
<title>Aragon</title>␊
<style>html, body {␊
height: 100%;␊
overflow: hidden;␊
}</style>␊
</head>␊
<body>␊
<noscript>␊
You need to enable JavaScript to run this app.␊
</noscript>␊
<div id="root"></div>␊
<script src="/src.e31bb0bc.js"></script>␊
</body>␊
</html>␊
`
Binary file added packages/e2e-tests/src/cli/run.test.js.snap
Binary file not shown.
10 changes: 4 additions & 6 deletions packages/e2e-tests/src/create-aragon-app/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import test from 'ava'
import execa from 'execa'
import fs from 'fs-extra'

const testSandbox = './.tmp/'
const testSandbox = './.tmp/create-aragon-app'

test.beforeEach(() => {
fs.ensureDirSync(testSandbox)
Expand All @@ -17,7 +17,7 @@ test('should create a new aragon app', async t => {

// arrange
const name = 'foobar'
const projectPath = `${testSandbox}${name}`
const projectPath = `${testSandbox}/${name}`
const repoPath = `${projectPath}/.git`
const arappPath = `${projectPath}/arapp.json`
const packageJsonPath = `${projectPath}/package.json`
Expand All @@ -36,8 +36,6 @@ test('should create a new aragon app', async t => {
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.staging.appName)
t.is(`${name}.open.aragonpm.eth`, arapp.environments.production.appName)

// TODO we can try aragon run with startBackgroundProcess and assert that the app loads
t.is(`${name}.open.aragonpm.eth`, arapp.environments.rinkeby.appName)
t.is(`${name}.open.aragonpm.eth`, arapp.environments.mainnet.appName)
})
Loading

0 comments on commit 6349189

Please sign in to comment.