From e3b2ab8a0460156df51a23af8d776e1710ddeaa1 Mon Sep 17 00:00:00 2001 From: jaybuidl Date: Wed, 5 Jan 2022 18:24:35 +0000 Subject: [PATCH 01/15] chore: github workflow for contracts testing --- .github/workflows/contracts-testing.yml | 39 +++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/contracts-testing.yml diff --git a/.github/workflows/contracts-testing.yml b/.github/workflows/contracts-testing.yml new file mode 100644 index 000000000..73b9e1b7c --- /dev/null +++ b/.github/workflows/contracts-testing.yml @@ -0,0 +1,39 @@ +name: Unit testing + +on: + workflow_dispatch: + push: + branches: + - master + pull_request: + branches: + - "*" + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Setup Node.js environment + uses: actions/setup-node@v2.5.1 + with: + node-version: 16.x + + - uses: actions/checkout@v2.4.0 + + - name: Cache node modules + uses: actions/cache@v2.1.7 + env: + cache-name: cache-node-modules + with: + path: | + ~/.npm + **/node_modules + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: Install + run: npm install + working-directory: contracts From 8a08485d634488ef0588f73a0e274cc1d1e9f8f0 Mon Sep 17 00:00:00 2001 From: jaybuidl Date: Wed, 5 Jan 2022 18:59:46 +0000 Subject: [PATCH 02/15] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index dd8d06cfa..fe171b4d6 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@

+ Unit testing Conventional Commits Commitizen Friendly Styled with Prettier From fed69e47cbd901fe4213dc598790a52c2cbc5671 Mon Sep 17 00:00:00 2001 From: jaybuidl Date: Wed, 5 Jan 2022 19:00:23 +0000 Subject: [PATCH 03/15] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fe171b4d6..49090207d 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@

- Unit testing + Unit testing Conventional Commits Commitizen Friendly Styled with Prettier From 40b066ffc33624b93db8dd45aa03cd184b1550c9 Mon Sep 17 00:00:00 2001 From: jaybuidl Date: Wed, 5 Jan 2022 19:03:20 +0000 Subject: [PATCH 04/15] Update contracts-testing.yml --- .github/workflows/contracts-testing.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/contracts-testing.yml b/.github/workflows/contracts-testing.yml index 73b9e1b7c..0e948e4e9 100644 --- a/.github/workflows/contracts-testing.yml +++ b/.github/workflows/contracts-testing.yml @@ -37,3 +37,15 @@ jobs: - name: Install run: npm install working-directory: contracts + + - name: Compile + run: | + yarn clean + yarn compile + working-directory: contracts + + - name: Test + run: | + yarn test + working-directory: contracts + From 4601d22e829ec2273cf8228f6206a5bfea1a4857 Mon Sep 17 00:00:00 2001 From: jaybuidl Date: Wed, 5 Jan 2022 22:43:16 +0000 Subject: [PATCH 05/15] Update contracts-testing.yml --- .github/workflows/contracts-testing.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/contracts-testing.yml b/.github/workflows/contracts-testing.yml index 0e948e4e9..473654792 100644 --- a/.github/workflows/contracts-testing.yml +++ b/.github/workflows/contracts-testing.yml @@ -35,17 +35,14 @@ jobs: ${{ runner.os }}- - name: Install - run: npm install - working-directory: contracts + run: yarn workspace @kleros/kleros-v2-contracts install - name: Compile run: | - yarn clean - yarn compile - working-directory: contracts + yarn workspace @kleros/kleros-v2-contracts clean + yarn workspace @kleros/kleros-v2-contracts compile - name: Test run: | - yarn test - working-directory: contracts + yarn workspace @kleros/kleros-v2-contracts test From 2ced6fed7310cb8c831d3b88c82eff96cfec656a Mon Sep 17 00:00:00 2001 From: jaybuidl Date: Wed, 5 Jan 2022 22:58:12 +0000 Subject: [PATCH 06/15] Update contracts-testing.yml --- .github/workflows/contracts-testing.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/contracts-testing.yml b/.github/workflows/contracts-testing.yml index 473654792..91afea1f7 100644 --- a/.github/workflows/contracts-testing.yml +++ b/.github/workflows/contracts-testing.yml @@ -28,14 +28,16 @@ jobs: path: | ~/.npm **/node_modules - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }} restore-keys: | ${{ runner.os }}-build-${{ env.cache-name }}- ${{ runner.os }}-build- ${{ runner.os }}- - name: Install - run: yarn workspace @kleros/kleros-v2-contracts install + run: | + yarn install + yarn workspace @kleros/kleros-v2-contracts install - name: Compile run: | From 45d11321713b6fb75ccd64f44a1bd4735d515dff Mon Sep 17 00:00:00 2001 From: jaybuidl Date: Wed, 5 Jan 2022 23:12:46 +0000 Subject: [PATCH 07/15] Update contracts-testing.yml --- .github/workflows/contracts-testing.yml | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/.github/workflows/contracts-testing.yml b/.github/workflows/contracts-testing.yml index 91afea1f7..2130d42ed 100644 --- a/.github/workflows/contracts-testing.yml +++ b/.github/workflows/contracts-testing.yml @@ -34,17 +34,22 @@ jobs: ${{ runner.os }}-build- ${{ runner.os }}- - - name: Install + - name: Install parent dependencies run: | yarn install - yarn workspace @kleros/kleros-v2-contracts install + + - name: Install contracts dependencies + run: | + yarn install + working-directory: contracts - name: Compile - run: | - yarn workspace @kleros/kleros-v2-contracts clean - yarn workspace @kleros/kleros-v2-contracts compile + run: | + yarn compile + working-directory: contracts - name: Test run: | - yarn workspace @kleros/kleros-v2-contracts test + yarn test + working-directory: contracts From 8a9b5d75858a21e0bc4241e7f59a5f459461fc67 Mon Sep 17 00:00:00 2001 From: jaybuidl Date: Wed, 5 Jan 2022 23:15:36 +0000 Subject: [PATCH 08/15] Update contracts-testing.yml --- .github/workflows/contracts-testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/contracts-testing.yml b/.github/workflows/contracts-testing.yml index 2130d42ed..08c3b0975 100644 --- a/.github/workflows/contracts-testing.yml +++ b/.github/workflows/contracts-testing.yml @@ -45,7 +45,7 @@ jobs: - name: Compile run: | - yarn compile + yarn build working-directory: contracts - name: Test From 7b8db740cd4877389d3917e45b9a895175027d6d Mon Sep 17 00:00:00 2001 From: jaybuidl Date: Wed, 5 Jan 2022 23:37:30 +0000 Subject: [PATCH 09/15] Update contracts-testing.yml --- .github/workflows/contracts-testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/contracts-testing.yml b/.github/workflows/contracts-testing.yml index 08c3b0975..5ae7ff7fd 100644 --- a/.github/workflows/contracts-testing.yml +++ b/.github/workflows/contracts-testing.yml @@ -40,7 +40,7 @@ jobs: - name: Install contracts dependencies run: | - yarn install + npm install working-directory: contracts - name: Compile From ef375dcc3fd72613aabc7c77ff7cc78c502a7925 Mon Sep 17 00:00:00 2001 From: jaybuidl Date: Wed, 5 Jan 2022 23:42:28 +0000 Subject: [PATCH 10/15] Update contracts-testing.yml --- .github/workflows/contracts-testing.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/contracts-testing.yml b/.github/workflows/contracts-testing.yml index 5ae7ff7fd..a2c8f79ce 100644 --- a/.github/workflows/contracts-testing.yml +++ b/.github/workflows/contracts-testing.yml @@ -36,15 +36,18 @@ jobs: - name: Install parent dependencies run: | + echo "current dir: $PWD" yarn install - name: Install contracts dependencies run: | + echo "current dir: $PWD" npm install working-directory: contracts - name: Compile run: | + echo "current dir: $PWD" yarn build working-directory: contracts From d2f34808426b9a55933e3f1ca254c3d4ca129da9 Mon Sep 17 00:00:00 2001 From: jaybuidl Date: Wed, 5 Jan 2022 23:50:39 +0000 Subject: [PATCH 11/15] Update contracts-testing.yml --- .github/workflows/contracts-testing.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/contracts-testing.yml b/.github/workflows/contracts-testing.yml index a2c8f79ce..2fa38a056 100644 --- a/.github/workflows/contracts-testing.yml +++ b/.github/workflows/contracts-testing.yml @@ -48,11 +48,10 @@ jobs: - name: Compile run: | echo "current dir: $PWD" - yarn build - working-directory: contracts + ls -d node_modules/hardhat + yarn workspace @kleros/kleros-v2-contracts build - name: Test run: | - yarn test - working-directory: contracts + yarn workspace @kleros/kleros-v2-contracts test From 81593a6097fd220dd82e02615975de166b344a82 Mon Sep 17 00:00:00 2001 From: jaybuidl Date: Wed, 5 Jan 2022 23:57:45 +0000 Subject: [PATCH 12/15] Update contracts-testing.yml --- .github/workflows/contracts-testing.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/contracts-testing.yml b/.github/workflows/contracts-testing.yml index 2fa38a056..b112f4043 100644 --- a/.github/workflows/contracts-testing.yml +++ b/.github/workflows/contracts-testing.yml @@ -49,9 +49,11 @@ jobs: run: | echo "current dir: $PWD" ls -d node_modules/hardhat - yarn workspace @kleros/kleros-v2-contracts build + npx hardhat compile + working-directory: contracts - name: Test run: | - yarn workspace @kleros/kleros-v2-contracts test + npx hardhat test + working-directory: contracts From 4cd6b8a071cb81e5907b47eff2e641ff6083b987 Mon Sep 17 00:00:00 2001 From: jaybuidl Date: Thu, 6 Jan 2022 00:48:03 +0000 Subject: [PATCH 13/15] chore: added solidity code coverage configuration --- contracts/.gitignore | 1 + contracts/.solcover.js | 19 +++++++ contracts/coverage.json | 122 ---------------------------------------- 3 files changed, 20 insertions(+), 122 deletions(-) create mode 100644 contracts/.solcover.js delete mode 100644 contracts/coverage.json diff --git a/contracts/.gitignore b/contracts/.gitignore index 1d29ae4ea..18aa4922d 100644 --- a/contracts/.gitignore +++ b/contracts/.gitignore @@ -1,6 +1,7 @@ # Hardhat files cache artifacts +coverage.json ## Hardhat typechain bindings/types typechain diff --git a/contracts/.solcover.js b/contracts/.solcover.js new file mode 100644 index 000000000..43bd929a3 --- /dev/null +++ b/contracts/.solcover.js @@ -0,0 +1,19 @@ +/* eslint-disable node/no-extraneous-require */ + +const shell = require("shelljs"); + +// The environment variables are loaded in hardhat.config.ts + +module.exports = { + istanbulReporter: ["html"], + onCompileComplete: async function (_config) { + await run("typechain"); + }, + onIstanbulComplete: async function (_config) { + // We need to do this because solcover generates bespoke artifacts. + shell.rm("-rf", "./artifacts"); + shell.rm("-rf", "./typechain"); + }, + providerOptions: {}, + skipFiles: ["mocks", "test"], +}; diff --git a/contracts/coverage.json b/contracts/coverage.json deleted file mode 100644 index 75bd461c7..000000000 --- a/contracts/coverage.json +++ /dev/null @@ -1,122 +0,0 @@ -{ - "src/Greeter.sol": { - "l": { - "10": 3, - "11": 3, - "15": 2, - "19": 1, - "20": 1 - }, - "path": "/Users/jaybee/project/kleros/kleros-v2/contracts/src/Greeter.sol", - "s": { - "1": 3, - "2": 3, - "3": 2, - "4": 1, - "5": 1 - }, - "b": {}, - "f": { - "1": 3, - "2": 2, - "3": 1 - }, - "fnMap": { - "1": { - "name": "constructor", - "line": 9, - "loc": { - "start": { - "line": 9, - "column": 4 - }, - "end": { - "line": 12, - "column": 4 - } - } - }, - "2": { - "name": "greet", - "line": 14, - "loc": { - "start": { - "line": 14, - "column": 4 - }, - "end": { - "line": 16, - "column": 4 - } - } - }, - "3": { - "name": "setGreeting", - "line": 18, - "loc": { - "start": { - "line": 18, - "column": 4 - }, - "end": { - "line": 21, - "column": 4 - } - } - } - }, - "statementMap": { - "1": { - "start": { - "line": 10, - "column": 8 - }, - "end": { - "line": 10, - "column": 67 - } - }, - "2": { - "start": { - "line": 11, - "column": 8 - }, - "end": { - "line": 11, - "column": 27 - } - }, - "3": { - "start": { - "line": 15, - "column": 8 - }, - "end": { - "line": 15, - "column": 23 - } - }, - "4": { - "start": { - "line": 19, - "column": 8 - }, - "end": { - "line": 19, - "column": 78 - } - }, - "5": { - "start": { - "line": 20, - "column": 8 - }, - "end": { - "line": 20, - "column": 27 - } - } - }, - "branchMap": {} - } -} From 8b3de8aec15c3e129f476582bda0b80ed89cd374 Mon Sep 17 00:00:00 2001 From: jaybuidl Date: Thu, 6 Jan 2022 00:51:09 +0000 Subject: [PATCH 14/15] Update contracts-testing.yml --- .github/workflows/contracts-testing.yml | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/.github/workflows/contracts-testing.yml b/.github/workflows/contracts-testing.yml index b112f4043..9c627746f 100644 --- a/.github/workflows/contracts-testing.yml +++ b/.github/workflows/contracts-testing.yml @@ -34,26 +34,27 @@ jobs: ${{ runner.os }}-build- ${{ runner.os }}- - - name: Install parent dependencies - run: | - echo "current dir: $PWD" - yarn install + #- name: Install parent dependencies + # run: | + # echo "current dir: $PWD" + # yarn install - name: Install contracts dependencies run: | - echo "current dir: $PWD" - npm install - working-directory: contracts + yarn workspace @kleros/kleros-v2-contracts install - name: Compile run: | - echo "current dir: $PWD" - ls -d node_modules/hardhat npx hardhat compile working-directory: contracts - - name: Test + - name: Test with coverage run: | - npx hardhat test + npx hardhat coverage --solcoverjs ./.solcover.js --temp artifacts --testfiles \"./test/**/*.ts\" working-directory: contracts + - name: Upload a build artifact + uses: actions/upload-artifact@v2.3.1 + with: + name: code-coverage-report + path: contracts/coverage From ad334a4e73b6ed39f030ae816622acaacbbd0da3 Mon Sep 17 00:00:00 2001 From: jaybuidl Date: Thu, 6 Jan 2022 00:56:10 +0000 Subject: [PATCH 15/15] Update contracts-testing.yml --- .github/workflows/contracts-testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/contracts-testing.yml b/.github/workflows/contracts-testing.yml index 9c627746f..3736f753d 100644 --- a/.github/workflows/contracts-testing.yml +++ b/.github/workflows/contracts-testing.yml @@ -1,4 +1,4 @@ -name: Unit testing +name: Contracts Testing on: workflow_dispatch: