diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 000000000..65a50888c --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,24 @@ +name: Coverage Reports + +on: + workflow_call: + +jobs: + coverage: + name: Coverage Reports + runs-on: ubuntu-latest + strategy: + matrix: + package: [caliper-core, caliper-fabric, generator-caliper] + steps: + - uses: actions/checkout@v3 + - name: Download coverage reports artifact + uses: actions/download-artifact@v1 + with: + name: coverage-reports + path: packages + - name: Upload coverage reports + uses: codecov/codecov-action@v3.1.0 + with: + files: packages/${{ matrix.package }}/coverage/clover.xml + flags: ${{ matrix.package }} diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 9f3d12d1e..35b77add1 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -10,6 +10,9 @@ jobs: unit-tests: uses: ./.github/workflows/unit-tests.yml needs: dci-lint + coverage: + uses: ./.github/workflows/coverage.yml + needs: unit-tests integration-tests: uses: ./.github/workflows/integration-tests.yml needs: unit-tests diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 574960f36..81cd0dfdf 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -40,3 +40,9 @@ jobs: run: ./packages/caliper-publish/publish.js version check - name: Run unit tests run: npm test --workspaces + - name: Upload coverage reports artifact + if: matrix.node-version == '16.x' + uses: actions/upload-artifact@v3 + with: + name: coverage-reports + path: packages/*/coverage/clover.xml diff --git a/README.md b/README.md index c3a963340..c416d3818 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # ![Hyperledger Caliper](https://wiki.hyperledger.org/download/attachments/2392434/Hyperledger_Caliper_Logo_Color.svg?version=1&modificationDate=1548883186000&api=v2) [![CI](https://github.com/hyperledger/caliper/actions/workflows/main.yml/badge.svg)](https://github.com/hyperledger/caliper/actions/workflows/main.yml) +[![codecov](https://codecov.io/gh/hyperledger/caliper/branch/main/graph/badge.svg?token=rVFhTNrZBJ)](https://codecov.io/gh/hyperledger/caliper) [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/2381/badge)](https://bestpractices.coreinfrastructure.org/projects/2381) [![license](https://img.shields.io/badge/license-Apache%202.0-blue)](https://github.com/hyperledger/caliper/blob/main/LICENSE) [![node (scoped)](https://img.shields.io/node/v/@hyperledger/caliper-cli)](https://www.npmjs.com/package/@hyperledger/caliper-cli) diff --git a/packages/caliper-cli/package.json b/packages/caliper-cli/package.json index 858251405..06f946da7 100644 --- a/packages/caliper-cli/package.json +++ b/packages/caliper-cli/package.json @@ -19,7 +19,7 @@ "licchk": "license-check-and-add", "test": "npm run lint", "lint": "npx eslint .", - "nyc": "nyc mocha --recursive -t 10000" + "nyc": "nyc --reporter=text --reporter=clover mocha --recursive -t 10000" }, "engines": { "node": ">=14.19.0", @@ -89,4 +89,4 @@ "lines": 5 }, "license": "Apache-2.0" -} \ No newline at end of file +} diff --git a/packages/caliper-core/package.json b/packages/caliper-core/package.json index 94d208d97..dc5914a15 100644 --- a/packages/caliper-core/package.json +++ b/packages/caliper-core/package.json @@ -15,7 +15,7 @@ "licchk": "license-check-and-add", "test": "npm run lint && npm run nyc", "lint": "npx eslint .", - "nyc": "nyc mocha --recursive -t 10000" + "nyc": "nyc --reporter=text --reporter=clover mocha --recursive -t 10000" }, "engines": { "node": ">=14.19.0", diff --git a/packages/caliper-ethereum/package.json b/packages/caliper-ethereum/package.json index 2d0dbcb3a..b40e467c5 100644 --- a/packages/caliper-ethereum/package.json +++ b/packages/caliper-ethereum/package.json @@ -15,7 +15,7 @@ "licchk": "license-check-and-add", "test": "npm run lint", "lint": "npx eslint .", - "nyc": "nyc mocha --recursive -t 10000" + "nyc": "nyc --reporter=text --reporter=clover mocha --recursive -t 10000" }, "engines": { "node": ">=14.19.0", @@ -83,4 +83,4 @@ "lines": 5 }, "license": "Apache-2.0" -} \ No newline at end of file +} diff --git a/packages/caliper-fabric/package.json b/packages/caliper-fabric/package.json index e120d7a16..caa0ecd03 100644 --- a/packages/caliper-fabric/package.json +++ b/packages/caliper-fabric/package.json @@ -15,7 +15,7 @@ "licchk": "license-check-and-add", "test": "npm run lint && npm run nyc", "lint": "npx eslint .", - "nyc": "nyc mocha --recursive -t 10000" + "nyc": "nyc --reporter=text --reporter=clover mocha --recursive -t 10000" }, "engines": { "node": ">=14.19.0", diff --git a/packages/caliper-fisco-bcos/package.json b/packages/caliper-fisco-bcos/package.json index ff0e7df94..fc0be9d82 100644 --- a/packages/caliper-fisco-bcos/package.json +++ b/packages/caliper-fisco-bcos/package.json @@ -15,7 +15,7 @@ "licchk": "license-check-and-add", "test": "npm run lint", "lint": "npx eslint .", - "nyc": "nyc mocha --recursive -t 10000" + "nyc": "nyc --reporter=text --reporter=clover mocha --recursive -t 10000" }, "engines": { "node": ">=14.19.0", @@ -86,4 +86,4 @@ "lines": 5 }, "license": "Apache-2.0" -} \ No newline at end of file +} diff --git a/packages/caliper-gui-dashboard/package.json b/packages/caliper-gui-dashboard/package.json index 12b1d4b8e..4cc4d1bf9 100755 --- a/packages/caliper-gui-dashboard/package.json +++ b/packages/caliper-gui-dashboard/package.json @@ -13,7 +13,7 @@ "licchk": "license-check-and-add", "test": "npm run lint", "lint": "npx eslint .", - "nyc": "nyc mocha --recursive -t 10000", + "nyc": "nyc --reporter=text --reporter=clover mocha --recursive -t 10000", "start": "SKIP_PREFLIGHT_CHECK=true react-scripts start", "build": "react-scripts build", "eject": "react-scripts eject", diff --git a/packages/caliper-gui-server/package.json b/packages/caliper-gui-server/package.json index d1285e315..dcf873d1a 100644 --- a/packages/caliper-gui-server/package.json +++ b/packages/caliper-gui-server/package.json @@ -14,7 +14,7 @@ "licchk": "license-check-and-add", "test": "npm run lint", "lint": "npx eslint .", - "nyc": "nyc mocha --recursive -t 10000", + "nyc": "nyc --reporter=text --reporter=clover mocha --recursive -t 10000", "start": "node app.js" }, "engines": { @@ -98,4 +98,4 @@ "lines": 1 }, "license": "Apache-2.0" -} \ No newline at end of file +} diff --git a/packages/caliper-publish/package.json b/packages/caliper-publish/package.json index b7be09fdf..8acec228c 100644 --- a/packages/caliper-publish/package.json +++ b/packages/caliper-publish/package.json @@ -14,7 +14,7 @@ "licchk": "license-check-and-add", "test": "npm run lint", "lint": "npx eslint .", - "nyc": "nyc mocha --recursive -t 10000" + "nyc": "nyc --reporter=text --reporter=clover mocha --recursive -t 10000" }, "engines": { "node": ">=14.19.0", @@ -82,4 +82,4 @@ "lines": 5 }, "license": "Apache-2.0" -} \ No newline at end of file +} diff --git a/packages/generator-caliper/package.json b/packages/generator-caliper/package.json index 8ecd16d89..8dc640182 100644 --- a/packages/generator-caliper/package.json +++ b/packages/generator-caliper/package.json @@ -19,7 +19,7 @@ "licchk": "license-check-and-add", "test": "npm run lint && npm run nyc", "lint": "npx eslint .", - "nyc": "nyc mocha --recursive -t 10000" + "nyc": "nyc --reporter=text --reporter=clover mocha --recursive -t 10000" }, "engines": { "node": ">=14.19.0", @@ -92,4 +92,4 @@ "functions": 1, "lines": 1 } -} \ No newline at end of file +}