Skip to content

Commit fa79033

Browse files
authored
chore(contracts): github workflow for contracts testing (#10)
1 parent f56e256 commit fa79033

File tree

5 files changed

+81
-122
lines changed

5 files changed

+81
-122
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Contracts Testing
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- master
8+
pull_request:
9+
branches:
10+
- "*"
11+
12+
jobs:
13+
test:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Setup Node.js environment
17+
uses: actions/setup-node@v2.5.1
18+
with:
19+
node-version: 16.x
20+
21+
- uses: actions/checkout@v2.4.0
22+
23+
- name: Cache node modules
24+
uses: actions/cache@v2.1.7
25+
env:
26+
cache-name: cache-node-modules
27+
with:
28+
path: |
29+
~/.npm
30+
**/node_modules
31+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}
32+
restore-keys: |
33+
${{ runner.os }}-build-${{ env.cache-name }}-
34+
${{ runner.os }}-build-
35+
${{ runner.os }}-
36+
37+
#- name: Install parent dependencies
38+
# run: |
39+
# echo "current dir: $PWD"
40+
# yarn install
41+
42+
- name: Install contracts dependencies
43+
run: |
44+
yarn workspace @kleros/kleros-v2-contracts install
45+
46+
- name: Compile
47+
run: |
48+
npx hardhat compile
49+
working-directory: contracts
50+
51+
- name: Test with coverage
52+
run: |
53+
npx hardhat coverage --solcoverjs ./.solcover.js --temp artifacts --testfiles \"./test/**/*.ts\"
54+
working-directory: contracts
55+
56+
- name: Upload a build artifact
57+
uses: actions/upload-artifact@v2.3.1
58+
with:
59+
name: code-coverage-report
60+
path: contracts/coverage

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
</p>
1010

1111
<p align="center">
12+
<a href="https://github.com/kleros/kleros-v2/actions/workflows/contracts-testing.yml"><img src="https://github.com/kleros/kleros-v2/actions/workflows/contracts-testing.yml/badge.svg" alt="Unit testing"></a>
1213
<a href="https://conventionalcommits.org"><img src="https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg" alt="Conventional Commits"></a>
1314
<a href="http://commitizen.github.io/cz-cli/"><img src="https://img.shields.io/badge/commitizen-friendly-brightgreen.svg" alt="Commitizen Friendly"></a>
1415
<a href="https://github.com/prettier/prettier"><img src="https://img.shields.io/badge/styled_with-prettier-ff69b4.svg" alt="Styled with Prettier"></a>

contracts/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Hardhat files
22
cache
33
artifacts
4+
coverage.json
45

56
## Hardhat typechain bindings/types
67
typechain

contracts/.solcover.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/* eslint-disable node/no-extraneous-require */
2+
3+
const shell = require("shelljs");
4+
5+
// The environment variables are loaded in hardhat.config.ts
6+
7+
module.exports = {
8+
istanbulReporter: ["html"],
9+
onCompileComplete: async function (_config) {
10+
await run("typechain");
11+
},
12+
onIstanbulComplete: async function (_config) {
13+
// We need to do this because solcover generates bespoke artifacts.
14+
shell.rm("-rf", "./artifacts");
15+
shell.rm("-rf", "./typechain");
16+
},
17+
providerOptions: {},
18+
skipFiles: ["mocks", "test"],
19+
};

contracts/coverage.json

Lines changed: 0 additions & 122 deletions
This file was deleted.

0 commit comments

Comments
 (0)