From 73c762487327592fcdcf6914d5c832fab7c911b0 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Mon, 9 Sep 2019 23:58:12 +0200 Subject: [PATCH 1/5] add code climate coverage reporting --- .travis.yml | 6 ++++++ README.md | 2 ++ 2 files changed, 8 insertions(+) diff --git a/.travis.yml b/.travis.yml index f466db4..38a8ceb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,6 +38,9 @@ before_install: - echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p before_script: + - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter + - chmod +x ./cc-test-reporter + - ./cc-test-reporter before-build - git clone https://github.com/oceanprotocol/barge - cd barge - bash -x start_ocean.sh --no-pleuston 2>&1 > start_ocean.log & @@ -53,6 +56,9 @@ script: - npm run test:e2e || travis_terminate 1 - ./scripts/build.sh +after_script: + - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT + notifications: email: false diff --git a/README.md b/README.md index b4664d7..96ae69c 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,8 @@ [![Build Status](https://travis-ci.com/oceanprotocol/commons.svg?branch=master)](https://travis-ci.com/oceanprotocol/commons) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/6a19987e62344b1c9c1d5bc9f315c733)](https://www.codacy.com/app/ocean-protocol/commons) [![Codacy Badge](https://api.codacy.com/project/badge/Coverage/6a19987e62344b1c9c1d5bc9f315c733)](https://www.codacy.com/app/ocean-protocol/commons) +[![Maintainability](https://api.codeclimate.com/v1/badges/ed6e8212a8d294b6aa88/maintainability)](https://codeclimate.com/github/oceanprotocol/commons/maintainability) +[![Test Coverage](https://api.codeclimate.com/v1/badges/ed6e8212a8d294b6aa88/test_coverage)](https://codeclimate.com/github/oceanprotocol/commons/test_coverage) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-7b1173.svg?style=flat-square)](https://github.com/prettier/prettier) [![js oceanprotocol](https://img.shields.io/badge/js-oceanprotocol-7b1173.svg)](https://github.com/oceanprotocol/eslint-config-oceanprotocol) [![css bigchaindb](https://img.shields.io/badge/css-bigchaindb-39BA91.svg)](https://github.com/bigchaindb/stylelint-config-bigchaindb) From 1f7845aa221b486abb0f51bdc156d2bed5c0e16a Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Tue, 10 Sep 2019 00:15:13 +0200 Subject: [PATCH 2/5] code fixes --- .../src/components/organisms/AssetsUser.tsx | 81 +++++++++---------- client/src/utils/cleanupContentType.ts | 35 ++++---- 2 files changed, 57 insertions(+), 59 deletions(-) diff --git a/client/src/components/organisms/AssetsUser.tsx b/client/src/components/organisms/AssetsUser.tsx index f0d828d..70fa119 100644 --- a/client/src/components/organisms/AssetsUser.tsx +++ b/client/src/components/organisms/AssetsUser.tsx @@ -10,6 +10,8 @@ export default class AssetsUser extends PureComponent< { list?: boolean; recent?: number }, { results: any[]; isLoading: boolean } > { + public static contextType = User + public state = { results: [], isLoading: true } public _isMounted = false @@ -58,51 +60,46 @@ export default class AssetsUser extends PureComponent< public render() { const { account } = this.context + const { recent, list } = this.props + const { isLoading, results } = this.state + + if (!account) return null return ( - account && ( -
- {this.props.recent && ( -

- Your Latest Published Data Sets -

- )} +
+ {this.props.recent && ( +

+ Your Latest Published Data Sets +

+ )} - {this.state.isLoading ? ( - - ) : this.state.results.length ? ( - <> - {this.state.results - .slice( - 0, - this.props.recent - ? this.props.recent - : undefined - ) - .filter(asset => !!asset) - .map((asset: any) => ( - - ))} - {this.props.recent && ( - - All Data Sets - - )} - - ) : ( -
-

No Data Sets Yet.

- + Publish A Data Set -
- )} -
- ) + {isLoading ? ( + + ) : results.length ? ( + <> + {results + .slice(0, recent ? recent : undefined) + .filter(asset => !!asset) + .map((asset: any) => ( + + ))} + {recent && ( + + All Data Sets + + )} + + ) : ( +
+

No Data Sets Yet.

+ + Publish A Data Set +
+ )} +
) } } - -AssetsUser.contextType = User diff --git a/client/src/utils/cleanupContentType.ts b/client/src/utils/cleanupContentType.ts index 0ec5c31..bcc53ab 100644 --- a/client/src/utils/cleanupContentType.ts +++ b/client/src/utils/cleanupContentType.ts @@ -7,23 +7,24 @@ const cleanupContentType = (contentType: string) => { let contentTypeCleaned // TODO: add all the possible archive & compression MIME types - if ( - contentType === 'application/x-lzma' || - contentType === 'application/x-xz' || - contentType === 'application/x-tar' || - contentType === 'application/x-gtar' || - contentType === 'application/x-bzip2' || - contentType === 'application/x-gzip' || - contentType === 'application/x-7z-compressed' || - contentType === 'application/x-rar-compressed' || - contentType === 'application/x-zip-compressed' || - contentType === 'application/x-apple-diskimage' - ) { - contentTypeCleaned = contentTypeSplit - .replace('x-', '') - .replace('-compressed', '') - } else { - contentTypeCleaned = contentTypeSplit + switch (contentType) { + case 'application/x-lzma': + case 'application/x-xz': + case 'application/x-tar': + case 'application/x-gtar': + case 'application/x-bzip2': + case 'application/x-gzip': + case 'application/x-7z-compressed': + case 'application/x-rar-compressed': + case 'application/x-zip-compressed': + case 'application/x-apple-diskimage': + contentTypeCleaned = contentTypeSplit + .replace('x-', '') + .replace('-compressed', '') + break + default: + contentTypeCleaned = contentTypeSplit + break } // Manual replacements From c62b69b17f1ad62b1afe4a5460505c7973ba9495 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Tue, 10 Sep 2019 00:22:23 +0200 Subject: [PATCH 3/5] pipe and merge coverage reports --- .travis.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 38a8ceb..80b3dc4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -56,8 +56,12 @@ script: - npm run test:e2e || travis_terminate 1 - ./scripts/build.sh +# Pipe the coverage data to Code Climate after_script: - - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT + - ./cc-test-reporter format-coverage -t lcov -o client/coverage/codeclimate.client.json client/coverage/lcov.info # Format client coverage + - ./cc-test-reporter format-coverage -t lcov -o coverage/codeclimate.server.json server/coverage/lcov.info # Format server coverage + - ./cc-test-reporter sum-coverage coverage/codeclimate.*.json -p 2 # Sum both coverage parts into coverage/codeclimate.json + - if [[ "$TRAVIS_TEST_RESULT" == 0 ]]; then ./cc-test-reporter upload-coverage; fi # Upload coverage/codeclimate.json notifications: email: false From 60d98340d921be24611f89ca66daeb5ce5c909bb Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Tue, 10 Sep 2019 00:33:23 +0200 Subject: [PATCH 4/5] lint fix --- client/src/components/organisms/AssetsUser.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/components/organisms/AssetsUser.tsx b/client/src/components/organisms/AssetsUser.tsx index 70fa119..bd418bf 100644 --- a/client/src/components/organisms/AssetsUser.tsx +++ b/client/src/components/organisms/AssetsUser.tsx @@ -78,7 +78,7 @@ export default class AssetsUser extends PureComponent< ) : results.length ? ( <> {results - .slice(0, recent ? recent : undefined) + .slice(0, recent || undefined) .filter(asset => !!asset) .map((asset: any) => ( Date: Tue, 10 Sep 2019 00:52:25 +0200 Subject: [PATCH 5/5] code climate script fix --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 80b3dc4..b40206c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -58,7 +58,7 @@ script: # Pipe the coverage data to Code Climate after_script: - - ./cc-test-reporter format-coverage -t lcov -o client/coverage/codeclimate.client.json client/coverage/lcov.info # Format client coverage + - ./cc-test-reporter format-coverage -t lcov -o coverage/codeclimate.client.json client/coverage/lcov.info # Format client coverage - ./cc-test-reporter format-coverage -t lcov -o coverage/codeclimate.server.json server/coverage/lcov.info # Format server coverage - ./cc-test-reporter sum-coverage coverage/codeclimate.*.json -p 2 # Sum both coverage parts into coverage/codeclimate.json - if [[ "$TRAVIS_TEST_RESULT" == 0 ]]; then ./cc-test-reporter upload-coverage; fi # Upload coverage/codeclimate.json