Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Refactor out sol-cov, sol-profiler and sol-trace into their separate packages #1492

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ jobs:
- run: yarn wsrun test:circleci @0x/order-utils
- run: yarn wsrun test:circleci @0x/order-watcher
- run: yarn wsrun test:circleci @0x/sol-compiler
- run: yarn wsrun test:circleci @0x/sol-cov
- run: yarn wsrun test:circleci @0x/sol-trace-based-tools-common
- run: yarn wsrun test:circleci @0x/sol-doc
- run: yarn wsrun test:circleci @0x/subproviders
- run: yarn wsrun test:circleci @0x/web3-wrapper
Expand Down Expand Up @@ -169,9 +169,9 @@ jobs:
paths:
- ~/repo/packages/sol-compiler/coverage/lcov.info
- save_cache:
key: coverage-sol-cov-{{ .Environment.CIRCLE_SHA1 }}
key: coverage-sol-trace-based-tools-common-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/packages/sol-cov/coverage/lcov.info
- ~/repo/packages/sol-trace-based-tools-common/coverage/lcov.info
- save_cache:
key: coverage-sol-doc-{{ .Environment.CIRCLE_SHA1 }}
paths:
Expand Down Expand Up @@ -342,7 +342,7 @@ jobs:
- coverage-sol-compiler-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-sol-cov-{{ .Environment.CIRCLE_SHA1 }}
- coverage-sol-trace-based-tools-common-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-sol-doc-{{ .Environment.CIRCLE_SHA1 }}
Expand Down
5 changes: 4 additions & 1 deletion .github/autolabeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ instant: ['packages/instant']
abi-gen-templates: ['packages/abi-gen-templates']
abi-gen: ['packages/abi-gen']
website: ['packages/website']
sol-cov: ['packages/sol-cov']
sol-coverage: ['packages/sol-coverage']
sol-profiler: ['packages/sol-profiler']
sol-trace: ['packages/sol-trace']
sol-trace-based-tools-common: ['packages/sol-trace-based-tools-common']
utils: ['packages/utils']
tslint-config: ['packages/tslint-config']
asset-buyer: ['packages/asset-buyer']
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ contracts/interfaces/generated-artifacts/
contracts/tokens/generated-artifacts/
contracts/examples/generated-artifacts/
contracts/extensions/generated-artifacts/
packages/sol-cov/test/fixtures/artifacts/
packages/sol-trace-based-tools-common/test/fixtures/artifacts/
packages/metacoin/artifacts/

# generated contract wrappers
Expand Down
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ lib
/packages/sra-spec/public/
package.json
scripts/postpublish_utils.js
packages/sol-cov/test/fixtures/artifacts
packages/sol-coverage/test/fixtures/artifacts
5 changes: 4 additions & 1 deletion CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ packages/metacoin/ @LogvinovLeon
packages/monorepo-scripts/ @fabioberger
packages/order-utils/ @fabioberger @LogvinovLeon
packages/sol-compiler/ @LogvinovLeon
packages/sol-cov/ @LogvinovLeon
packages/sol-coverage/ @LogvinovLeon
packages/sol-profiler/ @LogvinovLeon
packages/sol-trace/ @LogvinovLeon
packages/sol-trace-based-tools-common/ @LogvinovLeon
packages/sol-resolver/ @LogvinovLeon
packages/subproviders/ @fabioberger @dekz
packages/verdaccio/ @albrow
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ Visit our [developer portal](https://0xproject.com/docs/order-utils) for a compr
| -------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`@0x/web3-wrapper`](/packages/web3-wrapper) | [![npm](https://img.shields.io/npm/v/@0x/web3-wrapper.svg)](https://www.npmjs.com/package/@0x/web3-wrapper) | An Ethereum JSON RPC client |
| [`@0x/sol-compiler`](/packages/sol-compiler) | [![npm](https://img.shields.io/npm/v/@0x/sol-compiler.svg)](https://www.npmjs.com/package/@0x/sol-compiler) | A wrapper around solc-js that adds smart re-compilation, ability to compile an entire project, Solidity version specific compilation, standard input description support and much more. |
| [`@0x/sol-cov`](/packages/sol-cov) | [![npm](https://img.shields.io/npm/v/@0x/sol-cov.svg)](https://www.npmjs.com/package/@0x/sol-cov) | A solidity test coverage tool |
| [`@0x/sol-coverage`](/packages/sol-coverage) | [![npm](https://img.shields.io/npm/v/@0x/sol-coverage.svg)](https://www.npmjs.com/package/@0x/sol-coverage) | A solidity test coverage tool |
| [`@0x/sol-profiler`](/packages/sol-profiler) | [![npm](https://img.shields.io/npm/v/@0x/sol-profiler.svg)](https://www.npmjs.com/package/@0x/sol-profiler) | A solidity gas cost profiler |
| [`@0x/sol-trace`](/packages/sol-trace) | [![npm](https://img.shields.io/npm/v/@0x/sol-trace.svg)](https://www.npmjs.com/package/@0x/sol-trace) | A solidity stack trace tool |
| [`@0x/sol-resolver`](/packages/sol-resolver) | [![npm](https://img.shields.io/npm/v/@0x/sol-resolver.svg)](https://www.npmjs.com/package/@0x/sol-resolver) | Import resolver for smart contracts dependencies |
| [`@0x/subproviders`](/packages/subproviders) | [![npm](https://img.shields.io/npm/v/@0x/subproviders.svg)](https://www.npmjs.com/package/@0x/subproviders) | Web3 provider middlewares (e.g. LedgerSubprovider) |
| [`@0x/sol-doc`](/packages/sol-doc) | [![npm](https://img.shields.io/npm/v/@0x/sol-doc.svg)](https://www.npmjs.com/package/@0x/sol-doc) | Solidity documentation generator |
Expand Down
2 changes: 1 addition & 1 deletion contracts/TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ TEST_PROVIDER=geth yarn test

## Code coverage

In order to see the Solidity code coverage output generated by `@0x/sol-cov`, run:
In order to see the Solidity code coverage output generated by `@0x/sol-coverage`, run:

```
yarn test:coverage
Expand Down
1 change: 0 additions & 1 deletion contracts/examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
"@0x/contracts-test-utils": "^1.0.2",
"@0x/dev-utils": "^1.0.21",
"@0x/sol-compiler": "^1.1.16",
"@0x/sol-cov": "^2.1.16",
"@0x/subproviders": "^2.1.8",
"@0x/tslint-config": "^2.0.0",
"@types/bn.js": "^4.11.0",
Expand Down
1 change: 0 additions & 1 deletion contracts/extensions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
"@0x/contracts-test-utils": "^1.0.2",
"@0x/dev-utils": "^1.0.21",
"@0x/sol-compiler": "^1.1.16",
"@0x/sol-cov": "^2.1.16",
"@0x/subproviders": "^2.1.8",
"@0x/tslint-config": "^2.0.0",
"@types/bn.js": "^4.11.0",
Expand Down
1 change: 0 additions & 1 deletion contracts/libs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"@0x/contracts-test-utils": "^1.0.2",
"@0x/dev-utils": "^1.0.21",
"@0x/sol-compiler": "^1.1.16",
"@0x/sol-cov": "^2.1.16",
"@0x/subproviders": "^2.1.8",
"@0x/tslint-config": "^2.0.0",
"@types/bn.js": "^4.11.0",
Expand Down
1 change: 0 additions & 1 deletion contracts/multisig/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"@0x/contracts-test-utils": "^1.0.2",
"@0x/dev-utils": "^1.0.21",
"@0x/sol-compiler": "^1.1.16",
"@0x/sol-cov": "^2.1.16",
"@0x/subproviders": "^2.1.8",
"@0x/tslint-config": "^2.0.0",
"@types/bn.js": "^4.11.0",
Expand Down
1 change: 0 additions & 1 deletion contracts/protocol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
"@0x/abi-gen": "^1.0.19",
"@0x/dev-utils": "^1.0.21",
"@0x/sol-compiler": "^1.1.16",
"@0x/sol-cov": "^2.1.16",
"@0x/subproviders": "^2.1.8",
"@0x/tslint-config": "^2.0.0",
"@types/bn.js": "^4.11.0",
Expand Down
4 changes: 3 additions & 1 deletion contracts/test-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@
"@0x/dev-utils": "^1.0.21",
"@0x/order-utils": "^3.0.7",
"@0x/sol-compiler": "^1.1.16",
"@0x/sol-cov": "^2.1.16",
"@0x/sol-coverage": "^1.0.0",
"@0x/sol-profiler": "^1.0.0",
"@0x/sol-trace": "^1.0.0",
"@0x/subproviders": "^2.1.8",
"@0x/tslint-config": "^2.0.0",
"@0x/types": "^1.4.1",
Expand Down
2 changes: 1 addition & 1 deletion contracts/test-utils/src/coverage.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { devConstants } from '@0x/dev-utils';
import { CoverageSubprovider, SolCompilerArtifactAdapter } from '@0x/sol-cov';
import { CoverageSubprovider, SolCompilerArtifactAdapter } from '@0x/sol-coverage';
import * as _ from 'lodash';

let coverageSubprovider: CoverageSubprovider;
Expand Down
2 changes: 1 addition & 1 deletion contracts/test-utils/src/profiler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { devConstants } from '@0x/dev-utils';
import { ProfilerSubprovider, SolCompilerArtifactAdapter } from '@0x/sol-cov';
import { ProfilerSubprovider, SolCompilerArtifactAdapter } from '@0x/sol-profiler';
import * as _ from 'lodash';

let profilerSubprovider: ProfilerSubprovider;
Expand Down
2 changes: 1 addition & 1 deletion contracts/test-utils/src/revert_trace.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { devConstants } from '@0x/dev-utils';
import { RevertTraceSubprovider, SolCompilerArtifactAdapter } from '@0x/sol-cov';
import { RevertTraceSubprovider, SolCompilerArtifactAdapter } from '@0x/sol-trace';
import * as _ from 'lodash';

let revertTraceSubprovider: RevertTraceSubprovider;
Expand Down
1 change: 0 additions & 1 deletion contracts/tokens/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"@0x/contracts-test-utils": "^1.0.2",
"@0x/dev-utils": "^1.0.21",
"@0x/sol-compiler": "^1.1.16",
"@0x/sol-cov": "^2.1.16",
"@0x/subproviders": "^2.1.8",
"@0x/tslint-config": "^2.0.0",
"@types/bn.js": "^4.11.0",
Expand Down
1 change: 0 additions & 1 deletion contracts/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"@0x/contracts-test-utils": "^1.0.2",
"@0x/dev-utils": "^1.0.21",
"@0x/sol-compiler": "^1.1.16",
"@0x/sol-cov": "^2.1.16",
"@0x/subproviders": "^2.1.8",
"@0x/tslint-config": "^2.0.0",
"@types/bn.js": "^4.11.0",
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
},
"config": {
"mnemonic": "concert load couple harbor equip island argue ramp clarify fence smart topic",
"packagesWithDocPages": "0x.js connect json-schemas subproviders web3-wrapper contract-wrappers order-utils order-watcher sol-compiler sol-cov ethereum-types asset-buyer migrations"
"packagesWithDocPages": "0x.js connect json-schemas subproviders web3-wrapper contract-wrappers order-utils order-watcher sol-compiler sol-coverage sol-profiler sol-trace ethereum-types asset-buyer migrations"
},
"bundlewatch": {
"files": [
Expand All @@ -62,6 +62,9 @@
"repoBranchBase": "development"
}
},
"resolutions": {
"graceful-fs": "4.1.15"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran into that issue on my machine gulpjs/gulp#2246

},
"devDependencies": {
"@0x-lerna-fork/lerna": "3.0.0-beta.26",
"@0xproject/npm-cli-login": "^0.0.11",
Expand Down
3 changes: 2 additions & 1 deletion packages/metacoin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"@0x/abi-gen": "^1.0.19",
"@0x/abi-gen-templates": "^1.0.1",
"@0x/base-contract": "^3.0.10",
"@0x/sol-cov": "^2.1.16",
"@0x/sol-coverage": "^1.0.0",
"@0x/sol-profiler": "^1.0.0",
"@0x/subproviders": "^2.1.8",
"@0x/tslint-config": "^2.0.0",
"@0x/types": "^1.4.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/metacoin/test/utils/coverage.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { devConstants } from '@0x/dev-utils';
import { CoverageSubprovider, SolCompilerArtifactAdapter } from '@0x/sol-cov';
import { CoverageSubprovider, SolCompilerArtifactAdapter } from '@0x/sol-coverage';
import * as _ from 'lodash';

import { config } from './config';
Expand Down
2 changes: 1 addition & 1 deletion packages/metacoin/test/utils/profiler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { devConstants } from '@0x/dev-utils';
import { ProfilerSubprovider, SolCompilerArtifactAdapter } from '@0x/sol-cov';
import { ProfilerSubprovider, SolCompilerArtifactAdapter } from '@0x/sol-profiler';
import * as _ from 'lodash';

import { config } from './config';
Expand Down
73 changes: 39 additions & 34 deletions packages/monorepo-scripts/src/test_installation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,45 +45,50 @@ function logIfDefined(x: any): void {
const IS_LOCAL_PUBLISH = process.env.IS_LOCAL_PUBLISH === 'true';
const registry = IS_LOCAL_PUBLISH ? 'http://localhost:4873/' : 'https://registry.npmjs.org/';
const monorepoRootPath = path.join(__dirname, '../../..');
const packages = utils.getPackages(monorepoRootPath);
// We sort error messages according to package topology so that we can
LogvinovLeon marked this conversation as resolved.
Show resolved Hide resolved
// them in a more intuitive order. E.g. if package A has an error and
// package B imports it, the tests for both package A and package B will
// fail. But package B only fails because of an error in package A.
// Since the error in package A is the root cause, we log it first.
const packages = utils.getTopologicallySortedPackages(monorepoRootPath);
const installablePackages = _.filter(
packages,
pkg => !pkg.packageJson.private && !_.isUndefined(pkg.packageJson.main) && pkg.packageJson.main.endsWith('.js'),
);
utils.log('Testing packages:');
_.map(installablePackages, pkg => utils.log(`* ${pkg.packageJson.name}`));
// Run all package tests asynchronously and push promises into an array so
// we can wait for all of them to resolve.
const promises: Array<Promise<void>> = [];
const errors: PackageErr[] = [];
for (const installablePackage of installablePackages) {
const packagePromise = testInstallPackageAsync(monorepoRootPath, registry, installablePackage).catch(error => {
errors.push({ packageName: installablePackage.packageJson.name, error });
});
promises.push(packagePromise);
}
await Promise.all(promises);
if (errors.length > 0) {
// We sort error messages according to package topology so that we can
// them in a more intuitive order. E.g. if package A has an error and
// package B imports it, the tests for both package A and package B will
// fail. But package B only fails because of an error in package A.
// Since the error in package A is the root cause, we log it first.
const topologicallySortedPackages = utils.getTopologicallySortedPackages(monorepoRootPath);
const topologicallySortedErrors = _.sortBy(errors, packageErr =>
findPackageIndex(topologicallySortedPackages, packageErr.packageName),
);
_.forEach(topologicallySortedErrors, packageError => {
utils.log(`ERROR in package ${packageError.packageName}:`);
logIfDefined(packageError.error.message);
logIfDefined(packageError.error.stderr);
logIfDefined(packageError.error.stdout);
logIfDefined(packageError.error.stack);
});
process.exit(1);
} else {
process.exit(0);
const CHUNK_SIZE = 15;
const chunkedInstallablePackages = _.chunk(installablePackages, CHUNK_SIZE);
utils.log(`Testing all packages in ${chunkedInstallablePackages.length} chunks`);
for (const installablePackagesChunk of chunkedInstallablePackages) {
utils.log('Testing packages:');
_.map(installablePackagesChunk, pkg => utils.log(`* ${pkg.packageJson.name}`));
// Run all package tests within that chunk asynchronously and push promises into an array so
// we can wait for all of them to resolve.
const promises: Array<Promise<void>> = [];
const errors: PackageErr[] = [];
for (const installablePackage of installablePackagesChunk) {
const packagePromise = testInstallPackageAsync(monorepoRootPath, registry, installablePackage).catch(
error => {
errors.push({ packageName: installablePackage.packageJson.name, error });
},
);
promises.push(packagePromise);
}
await Promise.all(promises);
if (errors.length > 0) {
const topologicallySortedErrors = _.sortBy(errors, packageErr =>
findPackageIndex(packages, packageErr.packageName),
);
_.forEach(topologicallySortedErrors, packageError => {
utils.log(`ERROR in package ${packageError.packageName}:`);
logIfDefined(packageError.error.message);
logIfDefined(packageError.error.stderr);
logIfDefined(packageError.error.stdout);
logIfDefined(packageError.error.stack);
});
process.exit(1);
}
}
process.exit(0);
})().catch(err => {
utils.log(`Unexpected error: ${err.message}`);
process.exit(1);
Expand Down
6 changes: 0 additions & 6 deletions packages/sol-cov/tslint.json

This file was deleted.

12 changes: 12 additions & 0 deletions packages/sol-coverage/CHANGELOG.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
{
"version": "1.0.0",
"changes": [
{
"note":
"Initial release as a separate package. For historic entries check @0x/sol-trace-based-tools-common",
LogvinovLeon marked this conversation as resolved.
Show resolved Hide resolved
"pr": 1492
}
]
}
]
14 changes: 7 additions & 7 deletions packages/sol-cov/README.md → packages/sol-coverage/README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
## @0x/sol-cov
## @0x/sol-coverage

A Solidity code coverage tool.

### Read the [Documentation](https://0xproject.com/docs/sol-cov).
### Read the [Documentation](https://0xproject.com/docs/sol-coverage).

## Installation

```bash
yarn add @0x/sol-cov
yarn add @0x/sol-coverage
```

**Import**

```javascript
import { CoverageSubprovider } from '@0x/sol-cov';
import { CoverageSubprovider } from '@0x/sol-coverage';
```

or

```javascript
var CoverageSubprovider = require('@0x/sol-cov').CoverageSubprovider;
var CoverageSubprovider = require('@0x/sol-coverage').CoverageSubprovider;
```

## Contributing
Expand Down Expand Up @@ -47,13 +47,13 @@ yarn install
To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory:

```bash
PKG=@0x/sol-cov yarn build
PKG=@0x/sol-coverage yarn build
```

Or continuously rebuild on change:

```bash
PKG=@0x/sol-cov yarn watch
PKG=@0x/sol-coverage yarn watch
```

### Clean
Expand Down
Loading