From 84e857d51512997262cc0815feb2fcaa3ff00764 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Tue, 15 Jun 2021 15:00:32 +0200 Subject: [PATCH 01/32] GitHub CI actions --- .github/workflows/ci.yml | 120 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..bf277aad1 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,120 @@ +name: 'CI' + +on: + push: + branches: + - main + tags: + - '**' + pull_request: + branches: + - '**' + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: '15' + - name: Cache node_modules + uses: actions/cache@v2 + env: + cache-name: cache-node-modules + with: + path: ~/.npm + key: ${{ runner.os }}-lint-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: ${{ runner.os }}-lint-${{ env.cache-name }}- + - run: npm ci + - run: npm run lint + + unit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: '15' + - name: Cache node_modules + uses: actions/cache@v2 + env: + cache-name: cache-node-modules + with: + path: ~/.npm + key: ${{ runner.os }}-unit-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: ${{ runner.os }}-unit-${{ env.cache-name }}- + - run: npm ci + - run: npm run build:metadata + - run: npm run test:unit:cover + + integration: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: '15' + - name: Cache node_modules + uses: actions/cache@v2 + env: + cache-name: cache-node-modules + with: + path: ~/.npm + key: ${{ runner.os }}-integration-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: ${{ runner.os }}-integration-${{ env.cache-name }}- + - run: npm ci + - name: Checkout Barge + uses: actions/checkout@v2 + with: + repository: 'oceanprotocol/barge' + path: 'barge' + - name: Run Barge + working-directory: ${{ github.workspace }}/barge + env: + ADDRESS_FILE: '${HOME}/.ocean/ocean-contracts/artifacts/address.json' + AQUARIUS_URI: 'http://172.15.0.5:5000' + DEPLOY_CONTRACTS: 'true' + run: | + if [[ -n "$DOCKERHUB_PASSWORD" && -n "$DOCKERHUB_USERNAME" ]]; then echo "login to docker";echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin; fi & + bash -x start_ocean.sh --no-dashboard 2>&1 > start_ocean.log & + cd .. & + ./scripts/waitforcontracts.sh + - run: npm run test:integration:cover + + build: + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + node: ['15', '16'] + + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node }} + - name: Cache node_modules + uses: actions/cache@v2 + env: + cache-name: cache-node-modules + with: + path: ~/.npm + key: ${{ runner.os }}-${{ matrix.node }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: ${{ runner.os }}-${{ matrix.node }}-build-${{ env.cache-name }}- + - run: npm ci + - run: npm run build + + # coverage: + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v2 + # - uses: actions/setup-node@v2 + # - run: npm ci + # - uses: paambaati/codeclimate-action@v2.7.5 + # env: + # CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} + # with: + # coverageCommand: npm test From 3504a9a66e2cea30e4fe5720ada2ed393d3c526b Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Tue, 15 Jun 2021 15:24:29 +0200 Subject: [PATCH 02/32] add coverage job --- .github/workflows/ci.yml | 54 +++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 31 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bf277aad1..0b6a1b83a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,26 +29,7 @@ jobs: - run: npm ci - run: npm run lint - unit: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - node-version: '15' - - name: Cache node_modules - uses: actions/cache@v2 - env: - cache-name: cache-node-modules - with: - path: ~/.npm - key: ${{ runner.os }}-unit-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} - restore-keys: ${{ runner.os }}-unit-${{ env.cache-name }}- - - run: npm ci - - run: npm run build:metadata - - run: npm run test:unit:cover - - integration: + test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -80,7 +61,13 @@ jobs: bash -x start_ocean.sh --no-dashboard 2>&1 > start_ocean.log & cd .. & ./scripts/waitforcontracts.sh + - run: npm run build:metadata + - run: npm run test:unit:cover - run: npm run test:integration:cover + - uses: actions/upload-artifact@v1 + with: + name: coverage + path: coverage build: runs-on: ${{ matrix.os }} @@ -107,14 +94,19 @@ jobs: - run: npm ci - run: npm run build - # coverage: - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v2 - # - uses: actions/setup-node@v2 - # - run: npm ci - # - uses: paambaati/codeclimate-action@v2.7.5 - # env: - # CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} - # with: - # coverageCommand: npm test + coverage: + runs-on: ubuntu-latest + needs: test + if: success() + steps: + - uses: actions/checkout@v2 + - uses: actions/download-artifact@v1 + with: + name: coverage + - uses: paambaati/codeclimate-action@v2.7.5 + env: + CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} + with: + coverageLocations: | + ${{github.workspace}}/coverage/unit/lcov.info:lcov + ${{github.workspace}}/coverage/integration/lcov.info:lcov From a136bafb62de4670e3ed56ced23dfe54c0878a5d Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Tue, 15 Jun 2021 15:36:53 +0200 Subject: [PATCH 03/32] test run tweaks --- .github/workflows/ci.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0b6a1b83a..751fa6158 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,9 +42,11 @@ jobs: cache-name: cache-node-modules with: path: ~/.npm - key: ${{ runner.os }}-integration-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} - restore-keys: ${{ runner.os }}-integration-${{ env.cache-name }}- + key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: ${{ runner.os }}-test-${{ env.cache-name }}- - run: npm ci + - run: npm run build:metadata + - name: Checkout Barge uses: actions/checkout@v2 with: @@ -59,12 +61,11 @@ jobs: run: | if [[ -n "$DOCKERHUB_PASSWORD" && -n "$DOCKERHUB_USERNAME" ]]; then echo "login to docker";echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin; fi & bash -x start_ocean.sh --no-dashboard 2>&1 > start_ocean.log & - cd .. & - ./scripts/waitforcontracts.sh - - run: npm run build:metadata + cd .. && ./scripts/waitforcontracts.sh + - run: npm run test:unit:cover - run: npm run test:integration:cover - - uses: actions/upload-artifact@v1 + - uses: actions/upload-artifact@v2 with: name: coverage path: coverage @@ -100,7 +101,7 @@ jobs: if: success() steps: - uses: actions/checkout@v2 - - uses: actions/download-artifact@v1 + - uses: actions/download-artifact@v2 with: name: coverage - uses: paambaati/codeclimate-action@v2.7.5 From ad05a447ceee6cd5b5a67594147e7aa851d48e0f Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Tue, 15 Jun 2021 15:59:06 +0200 Subject: [PATCH 04/32] windows build fix --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 034352010..1fa60bdd4 100644 --- a/package.json +++ b/package.json @@ -13,13 +13,13 @@ "start": "npm run clean && npm run build:metadata && tsc -w", "build": "npm run clean && npm run build:metadata && microbundle build --format umd,cjs,es --compress --target node --tsconfig tsconfig.json", "build:tsc": "tsc --sourceMap", - "build:metadata": "./scripts/get-metadata.js > src/metadata.json", - "clean": "rm -rf ./dist/ ./doc/ ./.nyc_output", + "build:metadata": "scripts/get-metadata.js > src/metadata.json", + "clean": "rm -rf dist/ doc/ .nyc_output", "lint": "eslint --ignore-path .gitignore --ext .ts,.tsx . && npm run type-check", "lint:fix": "eslint --ignore-path .gitignore --ext .ts,.tsx . --fix", "format": "prettier --parser typescript --ignore-path .gitignore --write '**/*.{js,jsx,ts,tsx}'", "type-check": "npm run build:metadata && tsc --noEmit", - "doc:json": "./scripts/typedoc.js", + "doc:json": "scripts/typedoc.js", "run": "ts-node", "release": "release-it --non-interactive", "changelog": "auto-changelog -p", From 80241ea88ae33cb3d9dc777ffdad4cb7c26f95ce Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Tue, 15 Jun 2021 16:07:39 +0200 Subject: [PATCH 05/32] barge tweaks --- .github/workflows/ci.yml | 6 +++--- package.json | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 751fa6158..9089dacd3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,8 +55,8 @@ jobs: - name: Run Barge working-directory: ${{ github.workspace }}/barge env: - ADDRESS_FILE: '${HOME}/.ocean/ocean-contracts/artifacts/address.json' - AQUARIUS_URI: 'http://172.15.0.5:5000' + # ADDRESS_FILE: '${HOME}/.ocean/ocean-contracts/artifacts/address.json' + # AQUARIUS_URI: 'http://172.15.0.5:5000' DEPLOY_CONTRACTS: 'true' run: | if [[ -n "$DOCKERHUB_PASSWORD" && -n "$DOCKERHUB_USERNAME" ]]; then echo "login to docker";echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin; fi & @@ -76,7 +76,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-latest, windows-latest] + os: [ubuntu-latest, macos-latest] node: ['15', '16'] steps: diff --git a/package.json b/package.json index 1fa60bdd4..034352010 100644 --- a/package.json +++ b/package.json @@ -13,13 +13,13 @@ "start": "npm run clean && npm run build:metadata && tsc -w", "build": "npm run clean && npm run build:metadata && microbundle build --format umd,cjs,es --compress --target node --tsconfig tsconfig.json", "build:tsc": "tsc --sourceMap", - "build:metadata": "scripts/get-metadata.js > src/metadata.json", - "clean": "rm -rf dist/ doc/ .nyc_output", + "build:metadata": "./scripts/get-metadata.js > src/metadata.json", + "clean": "rm -rf ./dist/ ./doc/ ./.nyc_output", "lint": "eslint --ignore-path .gitignore --ext .ts,.tsx . && npm run type-check", "lint:fix": "eslint --ignore-path .gitignore --ext .ts,.tsx . --fix", "format": "prettier --parser typescript --ignore-path .gitignore --write '**/*.{js,jsx,ts,tsx}'", "type-check": "npm run build:metadata && tsc --noEmit", - "doc:json": "scripts/typedoc.js", + "doc:json": "./scripts/typedoc.js", "run": "ts-node", "release": "release-it --non-interactive", "changelog": "auto-changelog -p", From 59b9257fb9ce9cb610074a8824bc393a10942f16 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Tue, 15 Jun 2021 16:44:00 +0200 Subject: [PATCH 06/32] deal with env vars --- .github/workflows/ci.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9089dacd3..039637a9e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,6 +31,9 @@ jobs: test: runs-on: ubuntu-latest + env: + ADDRESS_FILE: '${HOME}/.ocean/ocean-contracts/artifacts/address.json' + AQUARIUS_URI: 'http://172.15.0.5:5000' steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 @@ -55,11 +58,9 @@ jobs: - name: Run Barge working-directory: ${{ github.workspace }}/barge env: - # ADDRESS_FILE: '${HOME}/.ocean/ocean-contracts/artifacts/address.json' - # AQUARIUS_URI: 'http://172.15.0.5:5000' DEPLOY_CONTRACTS: 'true' run: | - if [[ -n "$DOCKERHUB_PASSWORD" && -n "$DOCKERHUB_USERNAME" ]]; then echo "login to docker";echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin; fi & + if [[ -n "$DOCKERHUB_PASSWORD" && -n "$DOCKERHUB_USERNAME" ]]; then echo "login to docker";echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin; fi && bash -x start_ocean.sh --no-dashboard 2>&1 > start_ocean.log & cd .. && ./scripts/waitforcontracts.sh From fbfaa2ee5a87cbca777991172b1b481394ca0fbe Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Tue, 15 Jun 2021 17:00:20 +0200 Subject: [PATCH 07/32] add npm publish job --- .github/workflows/ci.yml | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 039637a9e..7fcee7c86 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 with: - node-version: '15' + node-version: '16' - name: Cache node_modules uses: actions/cache@v2 env: @@ -38,7 +38,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 with: - node-version: '15' + node-version: '16' - name: Cache node_modules uses: actions/cache@v2 env: @@ -61,7 +61,7 @@ jobs: DEPLOY_CONTRACTS: 'true' run: | if [[ -n "$DOCKERHUB_PASSWORD" && -n "$DOCKERHUB_USERNAME" ]]; then echo "login to docker";echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin; fi && - bash -x start_ocean.sh --no-dashboard 2>&1 > start_ocean.log & + bash -x start_ocean.sh --with-provider2 --no-dashboard 2>&1 > start_ocean.log & cd .. && ./scripts/waitforcontracts.sh - run: npm run test:unit:cover @@ -112,3 +112,19 @@ jobs: coverageLocations: | ${{github.workspace}}/coverage/unit/lcov.info:lcov ${{github.workspace}}/coverage/integration/lcov.info:lcov + + publish: + runs-on: ubuntu-latest + needs: test + if: success() && startsWith( github.ref, 'refs/tags/') + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: 16 + registry-url: https://registry.npmjs.org/ + - run: npm ci + - run: npm run build + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.npm_token }} From ca9e6adcfbbb2c7fe31d9006aed47643099ab7c5 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Wed, 16 Jun 2021 10:28:43 +0200 Subject: [PATCH 08/32] trial & error --- .github/workflows/ci.yml | 9 ++++----- README.md | 8 ++++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7fcee7c86..79e419e45 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: test: runs-on: ubuntu-latest env: - ADDRESS_FILE: '${HOME}/.ocean/ocean-contracts/artifacts/address.json' + ADDRESS_FILE: '$HOME/.ocean/ocean-contracts/artifacts/address.json' AQUARIUS_URI: 'http://172.15.0.5:5000' steps: - uses: actions/checkout@v2 @@ -115,16 +115,15 @@ jobs: publish: runs-on: ubuntu-latest - needs: test - if: success() && startsWith( github.ref, 'refs/tags/') + if: startsWith( github.ref, 'refs/tags/') steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 with: - node-version: 16 + node-version: '16' registry-url: https://registry.npmjs.org/ - run: npm ci - run: npm run build - run: npm publish env: - NODE_AUTH_TOKEN: ${{ secrets.npm_token }} + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/README.md b/README.md index 7795bc4d2..2978a603a 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ > JavaScript library to privately & securely publish, exchange, and consume data. [![npm](https://img.shields.io/npm/v/@oceanprotocol/lib.svg)](https://www.npmjs.com/package/@oceanprotocol/lib) -[![Build Status](https://travis-ci.com/oceanprotocol/ocean.js.svg?token=soMi2nNfCZq19zS1Rx4i&branch=main)](https://travis-ci.com/oceanprotocol/ocean.js) +[![Build Status](https://github.com/oceanprotocol/ocean.js/workflows/CI/badge.svg)](https://github.com/oceanprotocol/ocean.js/actions) [![Maintainability](https://api.codeclimate.com/v1/badges/6381c81b8ac568a53537/maintainability)](https://codeclimate.com/github/oceanprotocol/ocean.js/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/6381c81b8ac568a53537/test_coverage)](https://codeclimate.com/github/oceanprotocol/ocean.js/test_coverage) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-7b1173.svg?style=flat-square)](https://github.com/prettier/prettier) @@ -120,7 +120,7 @@ This batteries-included flow includes metadata, multiple services for one datato If you have any difficulties with the quickstarts, or if you have further questions about how to use ocean.js please reach out to us on [Discord](https://discord.gg/TnXjkR5). -If you notice any bugs or issues with Ocean.js please [open an issue on github](https://github.com/oceanprotocol/ocean.js/issues/new?assignees=&labels=bug&template=bug_report.md&title=). +If you notice any bugs or issues with ocean.js please [open an issue on github](https://github.com/oceanprotocol/ocean.js/issues/new?assignees=&labels=bug&template=bug_report.md&title=). ## 🦑 Development @@ -160,7 +160,7 @@ cd barge You can then proceed to run in another terminal. -Let ocean.js know where to pickup the smartcontract addresses: +Let ocean.js know where to pickup the smart contract addresses: ``` export ADDRESS_FILE="${HOME}/.ocean/ocean-contracts/artifacts/address.json" @@ -169,7 +169,7 @@ export ADDRESS_FILE="${HOME}/.ocean/ocean-contracts/artifacts/address.json" Build metadata: ``` -npm run build +npm run build:metadata ``` Executing linting, type checking, unit, and integration tests with coverage reporting all in one go: From 3c78fc975c2f9deb43e5df3f5af6e4364aa40b71 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Wed, 16 Jun 2021 12:10:30 +0200 Subject: [PATCH 09/32] remove Travis --- .travis.yml | 55 ----------------------------------------------------- 1 file changed, 55 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b65bc7531..000000000 --- a/.travis.yml +++ /dev/null @@ -1,55 +0,0 @@ -dist: xenial -sudo: required -language: node_js -node_js: - - 15 - -services: - - docker - -cache: npm - -matrix: - fast_finish: true - -before_script: - # CodeClimate test reporter setup - - 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 - # Barge setup - - git clone https://github.com/oceanprotocol/barge - - cd barge - - export ADDRESS_FILE="${HOME}/.ocean/ocean-contracts/artifacts/address.json" - - mkdir "${HOME}/.ocean/" - - mkdir "${HOME}/.ocean/ocean-contracts/" - - mkdir "${HOME}/.ocean/ocean-contracts/artifacts" - - touch $ADDRESS_FILE - - echo "{}" >> $ADDRESS_FILE - - export AQUARIUS_URI="http://172.15.0.5:5000" - - export DEPLOY_CONTRACTS="true" - - if [[ -n "$DOCKERHUB_PASSWORD" && -n "$DOCKERHUB_USERNAME" ]]; then echo "logining in to docker";echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin;fi - - bash -x start_ocean.sh --with-provider2 --no-dashboard 2>&1 > start_ocean.log & - - cd .. - - ./scripts/waitforcontracts.sh - -script: - - npm test - - npm run build - -after_script: - - ./cc-test-reporter format-coverage -t lcov -o coverage/codeclimate.unit.json coverage/unit/lcov.info # Format unit test coverage - - ./cc-test-reporter format-coverage -t lcov -o coverage/codeclimate.integration.json coverage/integration/lcov.info # Format integration test coverage - - ./cc-test-reporter sum-coverage coverage/codeclimate.*.json -p 2 # Sum both coverage parts into coverage/codeclimate.json - - if [[ -n "CC_TEST_REPORTER_ID" && "$TRAVIS_TEST_RESULT" == 0 ]]; then ./cc-test-reporter upload-coverage; fi # Upload coverage/codeclimate.json - -notifications: - email: false - -deploy: - - provider: npm - email: 'devops@oceanprotocol.com' - api_key: ${NPM_TOKEN} - skip_cleanup: true - on: - tags: true From fc684915b7df896a0d2d753ef83c79ae766dc058 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Wed, 16 Jun 2021 12:10:54 +0200 Subject: [PATCH 10/32] publish as single workflow --- .github/workflows/ci.yml | 19 +++---------------- .github/workflows/publish.yml | 21 +++++++++++++++++++++ scripts/waitforcontracts.sh | 9 ++++----- 3 files changed, 28 insertions(+), 21 deletions(-) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 79e419e45..2fca14faa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: test: runs-on: ubuntu-latest env: - ADDRESS_FILE: '$HOME/.ocean/ocean-contracts/artifacts/address.json' + ADDRESS_FILE: '${HOME}/.ocean/ocean-contracts/artifacts/address.json' AQUARIUS_URI: 'http://172.15.0.5:5000' steps: - uses: actions/checkout@v2 @@ -64,6 +64,8 @@ jobs: bash -x start_ocean.sh --with-provider2 --no-dashboard 2>&1 > start_ocean.log & cd .. && ./scripts/waitforcontracts.sh + - name: Check running containers + run: docker ps -a - run: npm run test:unit:cover - run: npm run test:integration:cover - uses: actions/upload-artifact@v2 @@ -112,18 +114,3 @@ jobs: coverageLocations: | ${{github.workspace}}/coverage/unit/lcov.info:lcov ${{github.workspace}}/coverage/integration/lcov.info:lcov - - publish: - runs-on: ubuntu-latest - if: startsWith( github.ref, 'refs/tags/') - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - node-version: '16' - registry-url: https://registry.npmjs.org/ - - run: npm ci - - run: npm run build - - run: npm publish - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 000000000..5bede3da4 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,21 @@ +name: 'Publish' + +on: + push: + tags: + - '**' + +jobs: + npm: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: '16' + registry-url: https://registry.npmjs.org/ + - run: npm ci + - run: npm run build + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/scripts/waitforcontracts.sh b/scripts/waitforcontracts.sh index 77a89ea71..2a01fd6aa 100755 --- a/scripts/waitforcontracts.sh +++ b/scripts/waitforcontracts.sh @@ -1,8 +1,7 @@ -if [ "${DEPLOY_CONTRACTS}" = "true" ]; then - while [ ! -f "${HOME}/.ocean/ocean-contracts/artifacts/ready" ]; do - sleep 2 - done -fi +while [ ! -f "${HOME}/.ocean/ocean-contracts/artifacts/ready" ]; do + sleep 2 +done + cat "barge/start_ocean.log" ls -lh "${HOME}/.ocean/ocean-contracts/" ls -lh "${HOME}/.ocean/ocean-contracts/artifacts/" From 8b0df425eab59108f985dd62e9f99615f8f8a7ac Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Wed, 16 Jun 2021 12:28:46 +0200 Subject: [PATCH 11/32] handle Docker Hub login --- .github/workflows/ci.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2fca14faa..4f8dec982 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,12 +55,19 @@ jobs: with: repository: 'oceanprotocol/barge' path: 'barge' + + - name: Login to Docker Hub + run: | + if [[ -n "$DOCKERHUB_PASSWORD" && -n "$DOCKERHUB_USERNAME" ]]; then echo "Login to Docker Hub";echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin; fi + env: + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} + - name: Run Barge working-directory: ${{ github.workspace }}/barge env: DEPLOY_CONTRACTS: 'true' run: | - if [[ -n "$DOCKERHUB_PASSWORD" && -n "$DOCKERHUB_USERNAME" ]]; then echo "login to docker";echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin; fi && bash -x start_ocean.sh --with-provider2 --no-dashboard 2>&1 > start_ocean.log & cd .. && ./scripts/waitforcontracts.sh From 83b49ae262687113d3b6cdbd3ba11679762c035a Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Wed, 16 Jun 2021 13:08:58 +0200 Subject: [PATCH 12/32] maybe preparing ~/.ocean is needed --- .github/workflows/ci.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4f8dec982..d72c59349 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: test: runs-on: ubuntu-latest env: - ADDRESS_FILE: '${HOME}/.ocean/ocean-contracts/artifacts/address.json' + ADDRESS_FILE: ${{ github.workspace }}/.ocean/ocean-contracts/artifacts/address.json AQUARIUS_URI: 'http://172.15.0.5:5000' steps: - uses: actions/checkout@v2 @@ -57,12 +57,21 @@ jobs: path: 'barge' - name: Login to Docker Hub + if: ${{ env.DOCKERHUB_PASSWORD && env.DOCKERHUB_USERNAME }} run: | - if [[ -n "$DOCKERHUB_PASSWORD" && -n "$DOCKERHUB_USERNAME" ]]; then echo "Login to Docker Hub";echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin; fi + echo "Login to Docker Hub";echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin env: DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} + # - name: Prepare ~/.ocean + # run: | + # mkdir "${HOME}/.ocean/" && + # mkdir "${HOME}/.ocean/ocean-contracts/" && + # mkdir "${HOME}/.ocean/ocean-contracts/artifacts" && + # touch "${HOME}/.ocean/ocean-contracts/artifacts/address.json" && + # echo "{}" >> "${HOME}/.ocean/ocean-contracts/artifacts/address.json" + - name: Run Barge working-directory: ${{ github.workspace }}/barge env: From 08d8346e1c0723fc13048bc225e40ffadf02283e Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Wed, 16 Jun 2021 15:14:51 +0200 Subject: [PATCH 13/32] downgrade barge contracts, run with barge defaults --- .github/workflows/ci.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d72c59349..70ef69168 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,9 +31,10 @@ jobs: test: runs-on: ubuntu-latest - env: - ADDRESS_FILE: ${{ github.workspace }}/.ocean/ocean-contracts/artifacts/address.json - AQUARIUS_URI: 'http://172.15.0.5:5000' + # env: + # ADDRESS_FILE: ${{ github.workspace }}/.ocean/ocean-contracts/artifacts/address.json + # AQUARIUS_URI: 'http://172.15.0.5:5000' + steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 @@ -75,7 +76,8 @@ jobs: - name: Run Barge working-directory: ${{ github.workspace }}/barge env: - DEPLOY_CONTRACTS: 'true' + # DEPLOY_CONTRACTS: 'true' + CONTRACTS_VERSION: v0.6.2 run: | bash -x start_ocean.sh --with-provider2 --no-dashboard 2>&1 > start_ocean.log & cd .. && ./scripts/waitforcontracts.sh From 1a14b3ab914f84331363499e2b54e6d9c7196d4b Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Thu, 17 Jun 2021 10:23:06 +0200 Subject: [PATCH 14/32] put back ADDRESS_FILE env var --- .github/workflows/ci.yml | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 70ef69168..7526e3c9d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,8 +31,8 @@ jobs: test: runs-on: ubuntu-latest - # env: - # ADDRESS_FILE: ${{ github.workspace }}/.ocean/ocean-contracts/artifacts/address.json + env: + ADDRESS_FILE: ${{ github.workspace }}/.ocean/ocean-contracts/artifacts/address.json # AQUARIUS_URI: 'http://172.15.0.5:5000' steps: @@ -65,19 +65,11 @@ jobs: DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} - # - name: Prepare ~/.ocean - # run: | - # mkdir "${HOME}/.ocean/" && - # mkdir "${HOME}/.ocean/ocean-contracts/" && - # mkdir "${HOME}/.ocean/ocean-contracts/artifacts" && - # touch "${HOME}/.ocean/ocean-contracts/artifacts/address.json" && - # echo "{}" >> "${HOME}/.ocean/ocean-contracts/artifacts/address.json" - - name: Run Barge working-directory: ${{ github.workspace }}/barge - env: - # DEPLOY_CONTRACTS: 'true' - CONTRACTS_VERSION: v0.6.2 + # env: + # DEPLOY_CONTRACTS: 'true' + # CONTRACTS_VERSION: v0.6.2 run: | bash -x start_ocean.sh --with-provider2 --no-dashboard 2>&1 > start_ocean.log & cd .. && ./scripts/waitforcontracts.sh From db58463709defd14776ba21af53262e4e9791dce Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Thu, 17 Jun 2021 10:50:03 +0200 Subject: [PATCH 15/32] AQUARIUS_URI test --- .github/workflows/ci.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7526e3c9d..3ed884d15 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,7 +33,8 @@ jobs: runs-on: ubuntu-latest env: ADDRESS_FILE: ${{ github.workspace }}/.ocean/ocean-contracts/artifacts/address.json - # AQUARIUS_URI: 'http://172.15.0.5:5000' + # AQUARIUS_URI: 'http://172.15.0.5:5000' + AQUARIUS_URI: http://127.0.0.1:5000 steps: - uses: actions/checkout@v2 @@ -67,9 +68,6 @@ jobs: - name: Run Barge working-directory: ${{ github.workspace }}/barge - # env: - # DEPLOY_CONTRACTS: 'true' - # CONTRACTS_VERSION: v0.6.2 run: | bash -x start_ocean.sh --with-provider2 --no-dashboard 2>&1 > start_ocean.log & cd .. && ./scripts/waitforcontracts.sh From 5d2f09420acb245fef636abd5fd9e0ae664e8f05 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Thu, 17 Jun 2021 11:26:59 +0200 Subject: [PATCH 16/32] ddo creation test logging --- test/unit/config.ts | 2 -- test/unit/ocean/Assets.test.ts | 15 ++++++--------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/test/unit/config.ts b/test/unit/config.ts index 4808ef5a4..549a6bf1d 100644 --- a/test/unit/config.ts +++ b/test/unit/config.ts @@ -7,7 +7,5 @@ export default { metadataCacheUri: 'http://localhost:5000', providerUri: 'http://localhost:8030', nodeUri: `http://localhost:${process.env.ETH_PORT || 8545}`, - parityUri: 'http://localhost:9545', - secretStoreUri: 'http://localhost:12001', verbose: LogLevel.Error } as Config diff --git a/test/unit/ocean/Assets.test.ts b/test/unit/ocean/Assets.test.ts index 8fc0a53d7..31899b17b 100644 --- a/test/unit/ocean/Assets.test.ts +++ b/test/unit/ocean/Assets.test.ts @@ -4,7 +4,7 @@ import spies from 'chai-spies' import { SearchQuery, MetadataCache } from '../../../src/metadatacache/MetadataCache' import { Ocean } from '../../../src/ocean/Ocean' import Web3 from 'web3' -import { Account, DDO, CredentialType, ConfigHelper } from '../../../src/lib' +import { Account, DDO, CredentialType, ConfigHelper, Metadata } from '../../../src/lib' import { responsify, getSearchResults } from '../helpers' const web3 = new Web3('http://127.0.0.1:8545') use(spies) @@ -12,8 +12,6 @@ use(spies) describe('Assets', () => { let ocean: Ocean let metadataCache: MetadataCache - let asset: any - let owner: Account let alice: Account let bob: Account let charlie: Account @@ -30,7 +28,6 @@ describe('Assets', () => { config.web3Provider = web3 ocean = await Ocean.getInstance(config) metadataCache = ocean.metadataCache // eslint-disable-line prefer-destructuring - owner = (await ocean.accounts.list())[0] alice = (await ocean.accounts.list())[1] walletA = alice.getId() bob = (await ocean.accounts.list())[2] @@ -78,8 +75,9 @@ describe('Assets', () => { assert.isDefined(assets.results[0].findServiceById) }) }) - it('Generates metadata', async () => { - asset = { + + it('Alice creates a DDO', async () => { + const metadata: Metadata = { main: { type: 'dataset', name: 'test-dataset', @@ -98,9 +96,7 @@ describe('Assets', () => { ] } } - }) - it('Alice creates a DDO', async () => { const price = '10' // in datatoken const publishedDate = new Date(Date.now()).toISOString().split('.')[0] + 'Z' const timeout = 0 @@ -110,7 +106,8 @@ describe('Assets', () => { publishedDate, timeout ) - ddo = await ocean.assets.create(asset, alice, [service1], null) + ddo = await ocean.assets.create(metadata, alice, [service1]) + console.log(ddo) }) it('should add allow credential', async () => { From 62bbf0a8d952931e5db0bc49ee2de40351aff6f1 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Thu, 17 Jun 2021 11:36:13 +0200 Subject: [PATCH 17/32] make failing DDO creation test actually fail --- .github/workflows/ci.yml | 4 ++-- test/unit/ocean/Assets.test.ts | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3ed884d15..3ab8e169c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,8 +33,8 @@ jobs: runs-on: ubuntu-latest env: ADDRESS_FILE: ${{ github.workspace }}/.ocean/ocean-contracts/artifacts/address.json - # AQUARIUS_URI: 'http://172.15.0.5:5000' - AQUARIUS_URI: http://127.0.0.1:5000 + # AQUARIUS_URI: http://172.15.0.5:5000 + # AQUARIUS_URI: http://127.0.0.1:5000 steps: - uses: actions/checkout@v2 diff --git a/test/unit/ocean/Assets.test.ts b/test/unit/ocean/Assets.test.ts index 31899b17b..3b16afa07 100644 --- a/test/unit/ocean/Assets.test.ts +++ b/test/unit/ocean/Assets.test.ts @@ -23,6 +23,7 @@ describe('Assets', () => { let walletB: string let walletC: string const threeBoxValue = 'did:3:bafyre' + beforeEach(async () => { const config = new ConfigHelper().getConfig('development') config.web3Provider = web3 @@ -107,6 +108,9 @@ describe('Assets', () => { timeout ) ddo = await ocean.assets.create(metadata, alice, [service1]) + assert.isDefined(ddo) + assert.isDefined(ddo.id) + assert(ddo !== null) console.log(ddo) }) From 1b9c4a60ab8e801ae66e8d45dd5bdd0c0a9da552 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Thu, 17 Jun 2021 11:53:57 +0200 Subject: [PATCH 18/32] separate unit/integration Asset tests --- test/integration/Assets.test.ts | 158 ++++++++++++++++++++++++++++++++ test/unit/ocean/Assets.test.ts | 147 +---------------------------- 2 files changed, 160 insertions(+), 145 deletions(-) create mode 100644 test/integration/Assets.test.ts diff --git a/test/integration/Assets.test.ts b/test/integration/Assets.test.ts new file mode 100644 index 000000000..4089fce23 --- /dev/null +++ b/test/integration/Assets.test.ts @@ -0,0 +1,158 @@ +import { assert } from 'chai' + +import { Ocean } from '../../src/ocean/Ocean' +import Web3 from 'web3' +import { Account, DDO, CredentialType, ConfigHelper, Metadata } from '../../src/lib' + +const web3 = new Web3('http://127.0.0.1:8545') + +describe('Assets', () => { + let ocean: Ocean + let alice: Account + let bob: Account + let charlie: Account + let ddo: DDO + let ddoWithAddressAnd3Box: DDO + const addressType = CredentialType.address + const threeBoxType = CredentialType.credential3Box + let walletA: string + let walletB: string + let walletC: string + const threeBoxValue = 'did:3:bafyre' + + beforeEach(async () => { + const config = new ConfigHelper().getConfig('development') + config.web3Provider = web3 + ocean = await Ocean.getInstance(config) + alice = (await ocean.accounts.list())[1] + walletA = alice.getId() + bob = (await ocean.accounts.list())[2] + walletB = bob.getId() + charlie = (await ocean.accounts.list())[3] + walletC = charlie.getId() + }) + + it('Alice creates a DDO', async () => { + const metadata: Metadata = { + main: { + type: 'dataset', + name: 'test-dataset', + dateCreated: new Date(Date.now()).toISOString().split('.')[0] + 'Z', // remove milliseconds + author: 'oceanprotocol-team', + license: 'MIT', + files: [ + { + url: 'https://s3.amazonaws.com/testfiles.oceanprotocol.com/info.0.json', + checksum: 'efb2c764274b745f5fc37f97c6b0e761', + contentLength: '4535431', + contentType: 'text/csv', + encoding: 'UTF-8', + compression: 'zip' + } + ] + } + } + + const price = '10' // in datatoken + const publishedDate = new Date(Date.now()).toISOString().split('.')[0] + 'Z' + const timeout = 0 + const service1 = await ocean.assets.createAccessServiceAttributes( + alice, + price, + publishedDate, + timeout + ) + ddo = await ocean.assets.create(metadata, alice, [service1]) + assert.isDefined(ddo) + assert.isDefined(ddo.id) + assert(ddo !== null) + console.log(ddo) + }) + + it('should add allow credential', async () => { + assert(ocean.assets.checkCredential(ddo, addressType, walletA).status === 0) + assert(ocean.assets.checkCredential(ddo, addressType, walletC).status === 0) + const allowWalletAddressList = [walletA, walletB] + console.error(JSON.stringify(ddo.credentials)) + const newDdo = await ocean.assets.updateCredentials( + ddo, + addressType, + allowWalletAddressList, + [] + ) + assert(newDdo.credentials.allow.length === 1) + assert(ocean.assets.checkCredential(ddo, addressType, walletA).status === 0) + assert(ocean.assets.checkCredential(ddo, addressType, walletC).status === 2) + }) + + it('should append allow credential', async () => { + const allowWalletAddressList = [walletA, walletB] + const allow3BoxList = [threeBoxValue] + ddoWithAddressAnd3Box = await ocean.assets.updateCredentials( + ddo, + addressType, + allowWalletAddressList, + [] + ) + ddoWithAddressAnd3Box = await ocean.assets.updateCredentials( + ddo, + threeBoxType, + allow3BoxList, + [] + ) + assert(ddoWithAddressAnd3Box.credentials.allow.length === 2) + }) + + it('should add deny credential', async () => { + const denyWalletAddressList = [walletC] + const newDdo = await ocean.assets.updateCredentials( + ddo, + addressType, + [], + denyWalletAddressList + ) + assert(newDdo.credentials.deny.length === 1) + assert(ocean.assets.checkCredential(ddo, addressType, walletA).status === 0) + assert(ocean.assets.checkCredential(ddo, addressType, walletC).status === 3) + }) + + it('should append deny credential', async () => { + const denyWalletAddressList = [walletC] + const deny3BoxList = [threeBoxValue] + let newDdo = await ocean.assets.updateCredentials( + ddo, + addressType, + [], + denyWalletAddressList + ) + newDdo = await ocean.assets.updateCredentials(ddo, threeBoxType, [], deny3BoxList) + assert(newDdo.credentials.deny.length === 2) + }) + + it('should only remove allow credential by credential type', async () => { + const allowWalletAddressList = [walletA, walletB] + const allow3BoxList = [threeBoxValue] + let newDdo = await ocean.assets.updateCredentials( + ddo, + addressType, + allowWalletAddressList, + [] + ) + newDdo = await ocean.assets.updateCredentials( + ddoWithAddressAnd3Box, + threeBoxType, + allow3BoxList, + [] + ) + assert(newDdo.credentials.allow.length === 2) + newDdo = await ocean.assets.updateCredentials( + ddoWithAddressAnd3Box, + threeBoxType, + [], + [] + ) + assert(newDdo.credentials.allow.length === 1) + assert(ocean.assets.checkCredential(ddo, addressType, walletA).status === 0) + assert(ocean.assets.checkCredential(ddo, addressType, walletC).status === 2) + }) +}) diff --git a/test/unit/ocean/Assets.test.ts b/test/unit/ocean/Assets.test.ts index 3b16afa07..c5276ca97 100644 --- a/test/unit/ocean/Assets.test.ts +++ b/test/unit/ocean/Assets.test.ts @@ -3,38 +3,19 @@ import spies from 'chai-spies' import { SearchQuery, MetadataCache } from '../../../src/metadatacache/MetadataCache' import { Ocean } from '../../../src/ocean/Ocean' -import Web3 from 'web3' -import { Account, DDO, CredentialType, ConfigHelper, Metadata } from '../../../src/lib' +import { DDO, ConfigHelper } from '../../../src/lib' import { responsify, getSearchResults } from '../helpers' -const web3 = new Web3('http://127.0.0.1:8545') + use(spies) describe('Assets', () => { let ocean: Ocean let metadataCache: MetadataCache - let alice: Account - let bob: Account - let charlie: Account - let ddo: DDO - let ddoWithAddressAnd3Box: DDO - const addressType = CredentialType.address - const threeBoxType = CredentialType.credential3Box - let walletA: string - let walletB: string - let walletC: string - const threeBoxValue = 'did:3:bafyre' beforeEach(async () => { const config = new ConfigHelper().getConfig('development') - config.web3Provider = web3 ocean = await Ocean.getInstance(config) metadataCache = ocean.metadataCache // eslint-disable-line prefer-destructuring - alice = (await ocean.accounts.list())[1] - walletA = alice.getId() - bob = (await ocean.accounts.list())[2] - walletB = bob.getId() - charlie = (await ocean.accounts.list())[3] - walletC = charlie.getId() }) afterEach(() => { @@ -76,128 +57,4 @@ describe('Assets', () => { assert.isDefined(assets.results[0].findServiceById) }) }) - - it('Alice creates a DDO', async () => { - const metadata: Metadata = { - main: { - type: 'dataset', - name: 'test-dataset', - dateCreated: new Date(Date.now()).toISOString().split('.')[0] + 'Z', // remove milliseconds - author: 'oceanprotocol-team', - license: 'MIT', - files: [ - { - url: 'https://s3.amazonaws.com/testfiles.oceanprotocol.com/info.0.json', - checksum: 'efb2c764274b745f5fc37f97c6b0e761', - contentLength: '4535431', - contentType: 'text/csv', - encoding: 'UTF-8', - compression: 'zip' - } - ] - } - } - - const price = '10' // in datatoken - const publishedDate = new Date(Date.now()).toISOString().split('.')[0] + 'Z' - const timeout = 0 - const service1 = await ocean.assets.createAccessServiceAttributes( - alice, - price, - publishedDate, - timeout - ) - ddo = await ocean.assets.create(metadata, alice, [service1]) - assert.isDefined(ddo) - assert.isDefined(ddo.id) - assert(ddo !== null) - console.log(ddo) - }) - - it('should add allow credential', async () => { - assert(ocean.assets.checkCredential(ddo, addressType, walletA).status === 0) - assert(ocean.assets.checkCredential(ddo, addressType, walletC).status === 0) - const allowWalletAddressList = [walletA, walletB] - console.error(JSON.stringify(ddo.credentials)) - const newDdo = await ocean.assets.updateCredentials( - ddo, - addressType, - allowWalletAddressList, - [] - ) - assert(newDdo.credentials.allow.length === 1) - assert(ocean.assets.checkCredential(ddo, addressType, walletA).status === 0) - assert(ocean.assets.checkCredential(ddo, addressType, walletC).status === 2) - }) - - it('should append allow credential', async () => { - const allowWalletAddressList = [walletA, walletB] - const allow3BoxList = [threeBoxValue] - ddoWithAddressAnd3Box = await ocean.assets.updateCredentials( - ddo, - addressType, - allowWalletAddressList, - [] - ) - ddoWithAddressAnd3Box = await ocean.assets.updateCredentials( - ddo, - threeBoxType, - allow3BoxList, - [] - ) - assert(ddoWithAddressAnd3Box.credentials.allow.length === 2) - }) - - it('should add deny credential', async () => { - const denyWalletAddressList = [walletC] - const newDdo = await ocean.assets.updateCredentials( - ddo, - addressType, - [], - denyWalletAddressList - ) - assert(newDdo.credentials.deny.length === 1) - assert(ocean.assets.checkCredential(ddo, addressType, walletA).status === 0) - assert(ocean.assets.checkCredential(ddo, addressType, walletC).status === 3) - }) - - it('should append deny credential', async () => { - const denyWalletAddressList = [walletC] - const deny3BoxList = [threeBoxValue] - let newDdo = await ocean.assets.updateCredentials( - ddo, - addressType, - [], - denyWalletAddressList - ) - newDdo = await ocean.assets.updateCredentials(ddo, threeBoxType, [], deny3BoxList) - assert(newDdo.credentials.deny.length === 2) - }) - - it('should only remove allow credential by credential type', async () => { - const allowWalletAddressList = [walletA, walletB] - const allow3BoxList = [threeBoxValue] - let newDdo = await ocean.assets.updateCredentials( - ddo, - addressType, - allowWalletAddressList, - [] - ) - newDdo = await ocean.assets.updateCredentials( - ddoWithAddressAnd3Box, - threeBoxType, - allow3BoxList, - [] - ) - assert(newDdo.credentials.allow.length === 2) - newDdo = await ocean.assets.updateCredentials( - ddoWithAddressAnd3Box, - threeBoxType, - [], - [] - ) - assert(newDdo.credentials.allow.length === 1) - assert(ocean.assets.checkCredential(ddo, addressType, walletA).status === 0) - assert(ocean.assets.checkCredential(ddo, addressType, walletC).status === 2) - }) }) From 9db0d304092f19ba921d7536464e86a243c5729a Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Thu, 17 Jun 2021 12:31:52 +0200 Subject: [PATCH 19/32] set AQUARIUS_URI again --- .github/workflows/ci.yml | 2 +- test/integration/Assets.test.ts | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3ab8e169c..721a9474c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,7 +33,7 @@ jobs: runs-on: ubuntu-latest env: ADDRESS_FILE: ${{ github.workspace }}/.ocean/ocean-contracts/artifacts/address.json - # AQUARIUS_URI: http://172.15.0.5:5000 + AQUARIUS_URI: http://172.15.0.5:5000 # AQUARIUS_URI: http://127.0.0.1:5000 steps: diff --git a/test/integration/Assets.test.ts b/test/integration/Assets.test.ts index 4089fce23..ce87d2d4f 100644 --- a/test/integration/Assets.test.ts +++ b/test/integration/Assets.test.ts @@ -62,11 +62,14 @@ describe('Assets', () => { publishedDate, timeout ) + ddo = await ocean.assets.create(metadata, alice, [service1]) assert.isDefined(ddo) assert.isDefined(ddo.id) - assert(ddo !== null) - console.log(ddo) + + // const storeTx = await ocean.onChainMetadata.publish(ddo.id, ddo, alice.getId()) + // assert(storeTx) + // await waitForAqua(ocean, ddo.id) }) it('should add allow credential', async () => { From 572b49ad637dbc5777046f3464d7c02b1a263c30 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Thu, 17 Jun 2021 18:43:10 +0200 Subject: [PATCH 20/32] readme updates --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2978a603a..8c974bd24 100644 --- a/README.md +++ b/README.md @@ -147,7 +147,7 @@ npm run format ## 👩‍🔬 Testing -Test suite for unit & integration tests is setup with [Mocha](https://mochajs.org) as test runner, and [nyc](https://github.com/istanbuljs/nyc) for coverage reporting. A combined coverage report is sent to CodeClimate via Travis. +Test suite for unit & integration tests is setup with [Mocha](https://mochajs.org) as test runner, and [nyc](https://github.com/istanbuljs/nyc) for coverage reporting. A combined coverage report is sent to CodeClimate via the `coverage` GitHub Actions job. Running all tests requires running Ocean Protocol components beforehand with [Barge](https://github.com/oceanprotocol/barge), which also runs a `ganache-cli` instance: @@ -160,7 +160,7 @@ cd barge You can then proceed to run in another terminal. -Let ocean.js know where to pickup the smart contract addresses: +Let ocean.js know where to pickup the smart contract addresses, which has been written out by Barge in this location: ``` export ADDRESS_FILE="${HOME}/.ocean/ocean-contracts/artifacts/address.json" @@ -225,7 +225,7 @@ The task does the following: - creates a Git tag - commits and pushes everything - creates a GitHub release with commit messages as description -- Git tag push will trigger Travis to do a npm release +- Git tag push will trigger a GitHub Action workflow to do a npm release For the GitHub releases steps a GitHub personal access token, exported as `GITHUB_TOKEN` is required. [Setup](https://github.com/release-it/release-it#github-releases) From c583ba0b736be782ec02aa68780d00dfc7fa38e2 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Thu, 17 Jun 2021 18:50:01 +0200 Subject: [PATCH 21/32] prepare ~/.ocean folder --- .github/workflows/ci.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 721a9474c..2ce43a464 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,6 +66,14 @@ jobs: DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} + - name: Prepare ~/.ocean + run: | + mkdir ${{ github.workspace }}/.ocean/ && + mkdir ${{ github.workspace }}/.ocean/ocean-contracts/ && + mkdir ${{ github.workspace }}/.ocean/ocean-contracts/artifacts && + touch ${{ github.workspace }}/.ocean/ocean-contracts/artifacts/address.json && + echo "{}" >> ${{ github.workspace }}/.ocean/ocean-contracts/artifacts/address.json + - name: Run Barge working-directory: ${{ github.workspace }}/barge run: | From 147e6e8d74d8a3618182bda6ca98f0b5c8106e1a Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Thu, 17 Jun 2021 19:09:56 +0200 Subject: [PATCH 22/32] separate tests into multiple jobs --- .github/workflows/ci.yml | 42 ++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2ce43a464..087690647 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,38 @@ jobs: - run: npm ci - run: npm run lint - test: + test_unit: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: '16' + - name: Cache node_modules + uses: actions/cache@v2 + env: + cache-name: cache-node-modules + with: + path: ~/.npm + key: ${{ runner.os }}-test-unit-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: ${{ runner.os }}-test-unit-${{ env.cache-name }}- + - run: npm ci + - run: npm run build:metadata + + - name: Run Ganache + run: | + docker pull trufflesuite/ganache-cli:latest + docker run -d -p 8545:8545 trufflesuite/ganache-cli:latest --mnemonic "taxi music thumb unique chat sand crew more leg another off lamp" + sleep 5 + + - run: npm run test:unit:cover + - uses: actions/upload-artifact@v2 + with: + name: coverage + path: coverage/unit + + test_integration: runs-on: ubuntu-latest env: ADDRESS_FILE: ${{ github.workspace }}/.ocean/ocean-contracts/artifacts/address.json @@ -47,8 +78,8 @@ jobs: cache-name: cache-node-modules with: path: ~/.npm - key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} - restore-keys: ${{ runner.os }}-test-${{ env.cache-name }}- + key: ${{ runner.os }}-test-integration-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: ${{ runner.os }}-test-integration-${{ env.cache-name }}- - run: npm ci - run: npm run build:metadata @@ -82,12 +113,11 @@ jobs: - name: Check running containers run: docker ps -a - - run: npm run test:unit:cover - run: npm run test:integration:cover - uses: actions/upload-artifact@v2 with: name: coverage - path: coverage + path: coverage/integration build: runs-on: ${{ matrix.os }} @@ -116,7 +146,7 @@ jobs: coverage: runs-on: ubuntu-latest - needs: test + needs: [test_unit, test_integration] if: success() steps: - uses: actions/checkout@v2 From 81bc475ca804772bebed045bd50f29c134779078 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Fri, 18 Jun 2021 11:44:36 +0200 Subject: [PATCH 23/32] address.json debugging --- .github/workflows/ci.yml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 087690647..529cad759 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -99,20 +99,26 @@ jobs: - name: Prepare ~/.ocean run: | - mkdir ${{ github.workspace }}/.ocean/ && - mkdir ${{ github.workspace }}/.ocean/ocean-contracts/ && - mkdir ${{ github.workspace }}/.ocean/ocean-contracts/artifacts && - touch ${{ github.workspace }}/.ocean/ocean-contracts/artifacts/address.json && + mkdir ${{ github.workspace }}/.ocean/ + mkdir ${{ github.workspace }}/.ocean/ocean-contracts/ + mkdir ${{ github.workspace }}/.ocean/ocean-contracts/artifacts + touch ${{ github.workspace }}/.ocean/ocean-contracts/artifacts/address.json echo "{}" >> ${{ github.workspace }}/.ocean/ocean-contracts/artifacts/address.json - name: Run Barge working-directory: ${{ github.workspace }}/barge run: | - bash -x start_ocean.sh --with-provider2 --no-dashboard 2>&1 > start_ocean.log & + bash -x start_ocean.sh --with-provider2 --no-dashboard 2>&1 > start_ocean.log cd .. && ./scripts/waitforcontracts.sh - name: Check running containers run: docker ps -a + - name: Check address.json + run: | + echo "via ADDRESS_FILE: " && cat ${{ env.ADDRESS_FILE }} + echo "via github.workspace: " && cat ${{ github.workspace }}/.ocean/ocean-contracts/artifacts/address.json + echo "via HOME: " && cat "${HOME}/.ocean/ocean-contracts/artifacts/address.json" + - run: npm run test:integration:cover - uses: actions/upload-artifact@v2 with: From 0f2ad6e752892f1b65051ca343ce1e6deee3792a Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Fri, 18 Jun 2021 11:54:21 +0200 Subject: [PATCH 24/32] windows build fixes --- .github/workflows/ci.yml | 4 ++-- package.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 529cad759..e2701248c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -108,7 +108,7 @@ jobs: - name: Run Barge working-directory: ${{ github.workspace }}/barge run: | - bash -x start_ocean.sh --with-provider2 --no-dashboard 2>&1 > start_ocean.log + bash -x start_ocean.sh --with-provider2 --no-dashboard 2>&1 > start_ocean.log & cd .. && ./scripts/waitforcontracts.sh - name: Check running containers @@ -131,7 +131,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest, macos-latest, windows-latest] node: ['15', '16'] steps: diff --git a/package.json b/package.json index 034352010..a14d56958 100644 --- a/package.json +++ b/package.json @@ -13,13 +13,13 @@ "start": "npm run clean && npm run build:metadata && tsc -w", "build": "npm run clean && npm run build:metadata && microbundle build --format umd,cjs,es --compress --target node --tsconfig tsconfig.json", "build:tsc": "tsc --sourceMap", - "build:metadata": "./scripts/get-metadata.js > src/metadata.json", + "build:metadata": "node ./scripts/get-metadata.js > src/metadata.json", "clean": "rm -rf ./dist/ ./doc/ ./.nyc_output", "lint": "eslint --ignore-path .gitignore --ext .ts,.tsx . && npm run type-check", "lint:fix": "eslint --ignore-path .gitignore --ext .ts,.tsx . --fix", "format": "prettier --parser typescript --ignore-path .gitignore --write '**/*.{js,jsx,ts,tsx}'", "type-check": "npm run build:metadata && tsc --noEmit", - "doc:json": "./scripts/typedoc.js", + "doc:json": "node ./scripts/typedoc.js", "run": "ts-node", "release": "release-it --non-interactive", "changelog": "auto-changelog -p", From 83f6f6c06164525a6300679b019524c970492adc Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Fri, 18 Jun 2021 12:25:03 +0200 Subject: [PATCH 25/32] address.json trials --- .github/workflows/ci.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e2701248c..d901558b9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,7 +63,7 @@ jobs: test_integration: runs-on: ubuntu-latest env: - ADDRESS_FILE: ${{ github.workspace }}/.ocean/ocean-contracts/artifacts/address.json + ADDRESS_FILE: ${{ env.HOME }}/.ocean/ocean-contracts/artifacts/address.json AQUARIUS_URI: http://172.15.0.5:5000 # AQUARIUS_URI: http://127.0.0.1:5000 @@ -97,13 +97,13 @@ jobs: DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} - - name: Prepare ~/.ocean - run: | - mkdir ${{ github.workspace }}/.ocean/ - mkdir ${{ github.workspace }}/.ocean/ocean-contracts/ - mkdir ${{ github.workspace }}/.ocean/ocean-contracts/artifacts - touch ${{ github.workspace }}/.ocean/ocean-contracts/artifacts/address.json - echo "{}" >> ${{ github.workspace }}/.ocean/ocean-contracts/artifacts/address.json + # - name: Prepare ~/.ocean + # run: | + # mkdir ${{ env.HOME }}/.ocean/ + # mkdir ${{ env.HOME }}/.ocean/ocean-contracts/ + # mkdir ${{ env.HOME }}/.ocean/ocean-contracts/artifacts + # touch ${{ env.HOME }}/.ocean/ocean-contracts/artifacts/address.json + # echo "{}" >> ${{ env.HOME }}/.ocean/ocean-contracts/artifacts/address.json - name: Run Barge working-directory: ${{ github.workspace }}/barge From d23bed188a75f9dd0f7a523f51630f636f92a6ac Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Fri, 18 Jun 2021 12:37:05 +0200 Subject: [PATCH 26/32] env var expansion workaround --- .github/workflows/ci.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d901558b9..24c04eb97 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,7 +63,6 @@ jobs: test_integration: runs-on: ubuntu-latest env: - ADDRESS_FILE: ${{ env.HOME }}/.ocean/ocean-contracts/artifacts/address.json AQUARIUS_URI: http://172.15.0.5:5000 # AQUARIUS_URI: http://127.0.0.1:5000 @@ -83,6 +82,11 @@ jobs: - run: npm ci - run: npm run build:metadata + # Env var expansion workaround + # https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable + - name: Set ADDRESS_FILE + run: echo "ADDRESS_FILE=${HOME}/.ocean/ocean-contracts/artifacts/address.json" >> $GITHUB_ENV + - name: Checkout Barge uses: actions/checkout@v2 with: @@ -116,7 +120,6 @@ jobs: - name: Check address.json run: | echo "via ADDRESS_FILE: " && cat ${{ env.ADDRESS_FILE }} - echo "via github.workspace: " && cat ${{ github.workspace }}/.ocean/ocean-contracts/artifacts/address.json echo "via HOME: " && cat "${HOME}/.ocean/ocean-contracts/artifacts/address.json" - run: npm run test:integration:cover From 1d7cebc3fb55601a8a6f563eb22fe5c88ada35e5 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Fri, 18 Jun 2021 13:14:43 +0200 Subject: [PATCH 27/32] cleanup --- .github/workflows/ci.yml | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 24c04eb97..2640f6ff7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,9 +62,6 @@ jobs: test_integration: runs-on: ubuntu-latest - env: - AQUARIUS_URI: http://172.15.0.5:5000 - # AQUARIUS_URI: http://127.0.0.1:5000 steps: - uses: actions/checkout@v2 @@ -101,27 +98,12 @@ jobs: DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} - # - name: Prepare ~/.ocean - # run: | - # mkdir ${{ env.HOME }}/.ocean/ - # mkdir ${{ env.HOME }}/.ocean/ocean-contracts/ - # mkdir ${{ env.HOME }}/.ocean/ocean-contracts/artifacts - # touch ${{ env.HOME }}/.ocean/ocean-contracts/artifacts/address.json - # echo "{}" >> ${{ env.HOME }}/.ocean/ocean-contracts/artifacts/address.json - - name: Run Barge working-directory: ${{ github.workspace }}/barge run: | bash -x start_ocean.sh --with-provider2 --no-dashboard 2>&1 > start_ocean.log & cd .. && ./scripts/waitforcontracts.sh - - name: Check running containers - run: docker ps -a - - name: Check address.json - run: | - echo "via ADDRESS_FILE: " && cat ${{ env.ADDRESS_FILE }} - echo "via HOME: " && cat "${HOME}/.ocean/ocean-contracts/artifacts/address.json" - - run: npm run test:integration:cover - uses: actions/upload-artifact@v2 with: @@ -162,7 +144,7 @@ jobs: - uses: actions/download-artifact@v2 with: name: coverage - - uses: paambaati/codeclimate-action@v2.7.5 + - uses: paambaati/codeclimate-action@v2.7.1 env: CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} with: From fb46b0c67d2558ee72e0570ea56aa14379adaa4f Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Fri, 18 Jun 2021 18:42:15 +0200 Subject: [PATCH 28/32] debug coverage output --- .github/workflows/ci.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2640f6ff7..64dbf7f33 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,7 +58,7 @@ jobs: - uses: actions/upload-artifact@v2 with: name: coverage - path: coverage/unit + path: coverage/ test_integration: runs-on: ubuntu-latest @@ -108,7 +108,7 @@ jobs: - uses: actions/upload-artifact@v2 with: name: coverage - path: coverage/integration + path: coverage/ build: runs-on: ${{ matrix.os }} @@ -144,10 +144,18 @@ jobs: - uses: actions/download-artifact@v2 with: name: coverage + - uses: paambaati/codeclimate-action@v2.7.1 env: CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} with: coverageLocations: | - ${{github.workspace}}/coverage/unit/lcov.info:lcov - ${{github.workspace}}/coverage/integration/lcov.info:lcov + ${{ github.workspace }}/coverage/unit/lcov.info:lcov + ${{ github.workspace }}/coverage/integration/lcov.info:lcov + + - name: Debug coverage output + run: | + ls -lh ${{ github.workspace }} + ls -lh coverage/ + ls -lh coverage/unit/ + ls -lh coverage/integration/ From 833c1fbafa49e9ac2e04b5497bcc9712fc721106 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Sat, 19 Jun 2021 13:52:56 +0200 Subject: [PATCH 29/32] fix coverage --- .github/workflows/ci.yml | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 64dbf7f33..74ce934bc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -149,13 +149,7 @@ jobs: env: CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} with: + coverageCommand: echo "Fake Command" coverageLocations: | - ${{ github.workspace }}/coverage/unit/lcov.info:lcov - ${{ github.workspace }}/coverage/integration/lcov.info:lcov - - - name: Debug coverage output - run: | - ls -lh ${{ github.workspace }} - ls -lh coverage/ - ls -lh coverage/unit/ - ls -lh coverage/integration/ + ${{ github.workspace }}/unit/lcov.info:lcov + ${{ github.workspace }}/integration/lcov.info:lcov From 7e26d8c91bbc16d329921f106723b56199007dbc Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Mon, 21 Jun 2021 12:37:34 +0200 Subject: [PATCH 30/32] bump codeclimate-action --- .github/workflows/ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 74ce934bc..f3bf19e78 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -145,11 +145,10 @@ jobs: with: name: coverage - - uses: paambaati/codeclimate-action@v2.7.1 + - uses: paambaati/codeclimate-action@v2.7.5 env: CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} with: - coverageCommand: echo "Fake Command" coverageLocations: | ${{ github.workspace }}/unit/lcov.info:lcov ${{ github.workspace }}/integration/lcov.info:lcov From 152ba1fe7236d2fd0cd33bf50a64fb0a04961bd5 Mon Sep 17 00:00:00 2001 From: Alex Coseru Date: Tue, 22 Jun 2021 12:49:14 +0300 Subject: [PATCH 31/32] use barge instead of ganache (#855) * use barge instead of ganache * small unit test job cleanup Co-authored-by: Matthias Kretschmann --- .github/workflows/ci.yml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f3bf19e78..b4ac4978c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,15 +45,19 @@ jobs: path: ~/.npm key: ${{ runner.os }}-test-unit-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} restore-keys: ${{ runner.os }}-test-unit-${{ env.cache-name }}- - - run: npm ci - - run: npm run build:metadata - - name: Run Ganache - run: | - docker pull trufflesuite/ganache-cli:latest - docker run -d -p 8545:8545 trufflesuite/ganache-cli:latest --mnemonic "taxi music thumb unique chat sand crew more leg another off lamp" - sleep 5 + - name: Checkout Barge + uses: actions/checkout@v2 + with: + repository: 'oceanprotocol/barge' + path: 'barge' + + - name: Run Ganache with Barge + working-directory: ${{ github.workspace }}/barge + run: bash -x start_ocean.sh --no-aquarius --no-elasticsearch --no-provider --no-dashboard --skip-deploy 2>&1 > start_ocean.log + - run: npm ci + - run: npm run build:metadata - run: npm run test:unit:cover - uses: actions/upload-artifact@v2 with: From 588d1c83d5b783f980582435120ad0bd3fb34487 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Tue, 22 Jun 2021 12:05:30 +0200 Subject: [PATCH 32/32] barge detach workaround --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b4ac4978c..52d18da35 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,7 +54,9 @@ jobs: - name: Run Ganache with Barge working-directory: ${{ github.workspace }}/barge - run: bash -x start_ocean.sh --no-aquarius --no-elasticsearch --no-provider --no-dashboard --skip-deploy 2>&1 > start_ocean.log + run: | + bash -x start_ocean.sh --no-aquarius --no-elasticsearch --no-provider --no-dashboard --skip-deploy 2>&1 > start_ocean.log & + cd .. - run: npm ci - run: npm run build:metadata