Skip to content
This repository was archived by the owner on Mar 7, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Code Coverage with Codecov

on:
push:
branches:
- feature/140-code-coverage-codecov
- main
pull_request:
branches:
- main
jobs:
Coverage:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: recursive

- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 11
- uses: gradle/gradle-build-action@v2
with:
gradle-version: 6.7.1

- name: Javascore BMC coverage
working-directory: ./javascore/bmc
run: |
gradle test
- name: Javascore BMV coverage
working-directory: ./javascore/bmv/bridge
continue-on-error: true
run: |
gradle test
- name: Javascore BMV coverage
working-directory: ./javascore/bmv/btpblock
continue-on-error: true
run: |
gradle test
- name: Javascore BMV coverage
working-directory: ./javascore/bmv/icon
continue-on-error: true
run: |
gradle test
- name: Javascore BSH coverage
working-directory: ./javascore/bsh
run: |
gradle test
- name: Javascore nativecoin coverage
working-directory: ./javascore/nativecoin
run: |
gradle test
- name: Javascore test-lib coverage
working-directory: ./javascore/test-lib
run: |
gradle test
- name: Javascore xcall coverage
working-directory: ./javascore/test-lib
run: |
gradle test
- name: GO test common
working-directory: ./common
run: |
go test ./... -race -covermode=atomic -coverprofile=coverage.out || exit 0
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'npm'
cache-dependency-path: |
solidity/bmv/package-lock.json
solidity/xcall/package-lock.json
- name: Solidity BMC coverage
working-directory: ./solidity/bmc
run: |
yarn install
npm install -g truffle
truffle run coverage || exit 0 # Bug on truffle to compile while running coverage and it fails, so exit 0
- name: Solidity BMV coverage
working-directory: ./solidity/bmv
run: |
cp .env.example .env
npm ci
npm run test:coverage
- name: Solidity xcall
working-directory: ./solidity/xcall
run: |
yarn install
truffle run coverage || exit 0
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# BTP (Block Transmission Protocol) Relay System

[![codecov](https://codecov.io/gh/icon-project/btp/branch/iconloop-v2/graph/badge.svg?token=6HB95U5TXG)](https://codecov.io/gh/icon-project/btp)
## Introduction

We need to build a usable [BTP](doc/btp.md) Relay System which can deliver digital tokens between multiple chains.
Expand Down
28 changes: 28 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
codecov:
require_ci_to_pass: false
comment:
behavior: default
layout: "reach, diff, flags, files"

ignore:
- "**/test_*"
- "**/*_test.*"
- "**/mocks/*"
- "**/mock/*"

coverage:
precision: 2
range:
- 80.0
- 100.0
round: down
status:
project: no
patch: # patch status only measures lines adjusted in the pull request or single commit
default:
target: 80% # target of an exact coverage number such as 75% or 100%
threshold: 2% # Allow the coverage to drop by X%, and posting a success status.
base: auto
changes: no # Codecov will detect changes in coverage that are NOT included in the commit/pull diff
github_checks:
annotations: true
16 changes: 16 additions & 0 deletions javascore/bmc/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
version = '0.1.0'
apply plugin: "jacoco"

dependencies {
compileOnly("foundation.icon:javaee-api:$javaeeVersion")
Expand Down Expand Up @@ -113,4 +114,19 @@ test {
systemProperty 'validator.keyStore', scoreTest.default.keyStore
systemProperty 'validator.keyPassword', scoreTest.default.resolvedKeyPassword
}
finalizedBy jacocoTestReport
}

jacocoTestReport {
dependsOn test
reports {
xml.enabled true
xml.destination file("${buildDir}/reports/jacoco/report.xml")
html.enabled true
csv.enabled true
}
subprojects.each {
sourceSets it.sourceSets.main
}
executionData fileTree(project.rootDir.absolutePath).include("**/build/jacoco/*.exec")
}
17 changes: 17 additions & 0 deletions javascore/bmv/bridge/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
version = '0.1.0'
apply plugin: "jacoco"

dependencies {
compileOnly("foundation.icon:javaee-api:$javaeeVersion")
Expand Down Expand Up @@ -85,4 +86,20 @@ test {
systemProperty 'bmc-mock.scoreFilePath', tasks.getByPath(":test-lib:optimizedJarMockBMC").outputJarName
systemProperty 'bmc-mock.params._net', scoreTest.nid+'.icon'
}
finalizedBy jacocoTestReport
}

jacocoTestReport {
dependsOn test
reports {
xml.enabled true
xml.destination file("${buildDir}/reports/jacoco/report.xml")
html.enabled true
csv.enabled true
}
subprojects.each {
sourceSets it.sourceSets.main
}
executionData fileTree(project.rootDir.absolutePath).include("**/build/jacoco/*.exec")
}

17 changes: 17 additions & 0 deletions javascore/bsh/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
id 'java'
}
apply plugin: "jacoco"

repositories {
mavenCentral()
Expand Down Expand Up @@ -74,4 +75,20 @@ deployJar {

test {
useJUnitPlatform()
finalizedBy jacocoTestReport
}

jacocoTestReport {
dependsOn test
reports {
xml.enabled true
xml.destination file("${buildDir}/reports/jacoco/report.xml")
html.enabled true
csv.enabled true
}
subprojects.each {
sourceSets it.sourceSets.main
}
executionData fileTree(project.rootDir.absolutePath).include("**/build/jacoco/*.exec")
}

16 changes: 16 additions & 0 deletions javascore/nativecoin/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
version = '0.1.0'
apply plugin: "jacoco"

dependencies {
compileOnly("foundation.icon:javaee-api:$javaeeVersion")
Expand Down Expand Up @@ -110,4 +111,19 @@ test {
systemProperty 'bmc-mock.scoreFilePath', tasks.getByPath(":test-lib:optimizedJarMockBMC").outputJarName
systemProperty 'bmc-mock.params._net', scoreTest.nid+'.icon'
}
finalizedBy jacocoTestReport
}

jacocoTestReport {
dependsOn test
reports {
xml.enabled true
xml.destination file("${buildDir}/reports/jacoco/report.xml")
html.enabled true
csv.enabled true
}
subprojects.each {
sourceSets it.sourceSets.main
}
executionData fileTree(project.rootDir.absolutePath).include("**/build/jacoco/*.exec")
}
16 changes: 16 additions & 0 deletions javascore/test-lib/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
version = '0.1.0'

apply plugin: 'java-library'
apply plugin: "jacoco"

dependencies {
//for mock package
Expand Down Expand Up @@ -155,4 +156,19 @@ test {
systemProperty 'validator.keyStore', scoreTest.default.keyStore
systemProperty 'validator.keyPassword', scoreTest.default.resolvedKeyPassword
}
finalizedBy jacocoTestReport
}

jacocoTestReport {
dependsOn test
reports {
xml.enabled true
xml.destination file("${buildDir}/reports/jacoco/report.xml")
html.enabled true
csv.enabled true
}
subprojects.each {
sourceSets it.sourceSets.main
}
executionData fileTree(project.rootDir.absolutePath).include("**/build/jacoco/*.exec")
}
16 changes: 16 additions & 0 deletions javascore/xcall/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
version = '0.1.0'
apply plugin: "jacoco"

dependencies {
compileOnly("foundation.icon:javaee-api:$javaeeVersion")
Expand Down Expand Up @@ -101,4 +102,19 @@ test {
systemProperty 'bmc-mock.scoreFilePath', tasks.getByPath(":test-lib:optimizedJarMockBMC").outputJarName
systemProperty 'bmc-mock.params._net', scoreTest.nid + '.icon'
}
finalizedBy jacocoTestReport
}

jacocoTestReport {
dependsOn test
reports {
xml.enabled true
xml.destination file("${buildDir}/reports/jacoco/report.xml")
html.enabled true
csv.enabled true
}
subprojects.each {
sourceSets it.sourceSets.main
}
executionData fileTree(project.rootDir.absolutePath).include("**/build/jacoco/*.exec")
}
3 changes: 2 additions & 1 deletion solidity/bmc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"truffle": "^5.5.23",
"@truffle/hdwallet-provider": "^1.4.0",
"dotenv": "^16.0.1",
"@openzeppelin/truffle-upgrades": "^1.7.0"
"@openzeppelin/truffle-upgrades": "^1.7.0",
"solidity-coverage": "v0.8.0-beta.0"
},
"scripts": {
"linter": "./node_modules/.bin/solhint -f table ./contracts/**/*.sol -f table ./contracts/*.sol",
Expand Down
2 changes: 1 addition & 1 deletion solidity/bmc/truffle-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ module.exports = {
}
}
},
plugins: ["truffle-plugin-verify", "@chainsafe/truffle-plugin-abigen", "truffle-contract-size"],
plugins: ["truffle-plugin-verify", "@chainsafe/truffle-plugin-abigen", "truffle-contract-size", "solidity-coverage"],
db: {
enabled: false
}
Expand Down
5 changes: 5 additions & 0 deletions solidity/bmv/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
BMC_ADDR=""
SRC_NETWORK_ID="'btp://0x2.icon'"
NETWORK_TYPE_ID=2
FIRST_BLOCK_UPDATE="0xf8a40a00a08d647190ed786d4f8a522f32351ff2269732f6e3771b908271ca29aa73c2c03cc00201f80001a041791102999c339c844880b23950704cc43aa840f3739e365323cda4dfa89e7ab858f856f85494e3aee81071e40c44dde872e568d8d09429c5970e94b3d988f28443446c9d7ac62f673085e2736ca4e094f7646979981a5d7dcc05ea261ae26ecd2c2c81889477fec3da1ba8b192f4b278057395a5124392c88b"
SEQUENCE_OFFSET=0
Loading