Browse Source

add coverage test

Signed-off-by: Jakub Sokołowski <jakub@status.im>
pull/8526/head
tbenr 1 month ago
parent
commit
b78bb456a4
No account linked to committer's email address
11 changed files with 1298 additions and 25 deletions
  1. 4
    0
      .gitignore
  2. 17
    0
      .nycrc
  3. 3
    0
      Makefile
  4. 2
    0
      README.md
  5. 8
    0
      ci/Jenkinsfile.android
  6. 11
    0
      ci/android.groovy
  7. 3
    1
      desktop_files/package.json.orig
  8. 655
    10
      desktop_files/yarn.lock
  9. 4
    0
      mobile_files/package.json.orig
  10. 540
    14
      mobile_files/yarn.lock
  11. 51
    0
      scripts/run-coverage.sh

+ 4
- 0
.gitignore View File

@@ -166,3 +166,7 @@ conan.cmake
status-modules/translations
status-modules/cljs
status-modules/resources

## coverage
/.nyc_output
/coverage-report

+ 17
- 0
.nycrc View File

@@ -0,0 +1,17 @@
{
"include": [
"target/test/status_im/**"
],
"exclude": [
"target/test/status_im/test/**",
"target/test/status_im/ui/**"
],
"report-dir": "./coverage-report",
"all": true,
"source-map": true,
"produce-source-map": true,
"instrument": true,
"exclude-after-remap": false,
"extension": [".js"],
"reporter": ["lcovonly"]
}

+ 3
- 0
Makefile View File

@@ -191,6 +191,9 @@ test: ##@test Run tests once in NodeJS
test-auto: ##@test Run tests in interactive (auto) mode in NodeJS
lein with-profile test doo node test

coverage: ##@test Run tests once in NodeJS generating coverage
@scripts/run-coverage.sh

#--------------
# Other
#--------------

+ 2
- 0
README.md View File

@@ -66,3 +66,5 @@ Licensed under the [Mozilla Public License v2.0](https://github.com/status-im/st
## Testing Supported by

[![BrowserStack Status](https://www.browserstack.com/automate/badge.svg?badge_key=SFBWQ3k5R2tnT2t6UGsxU1h1U0g3VFlCNnoxVTRHYWNoTDhsb1laaTJZWT0tLUZMUm5sSVFBSU9qSWM1RUJvK1I3Z3c9PQ==--ad15ae7992b432b33743749d40318952415bd98f)](https://www.browserstack.com/automate/public-build/SFBWQ3k5R2tnT2t6UGsxU1h1U0g3VFlCNnoxVTRHYWNoTDhsb1laaTJZWT0tLUZMUm5sSVFBSU9qSWM1RUJvK1I3Z3c9PQ==--ad15ae7992b432b33743749d40318952415bd98f)

[![Coverage Status](https://coveralls.io/repos/github/status-im/status-react/badge.svg?)](https://coveralls.io/github/status-im/status-react)

+ 8
- 0
ci/Jenkinsfile.android View File

@@ -35,6 +35,9 @@ pipeline {
LEIN_HOME = "/var/tmp/lein-${EXECUTOR_NUMBER}"
YARN_CACHE_FOLDER = "/var/tmp/yarn-${EXECUTOR_NUMBER}"
GRADLE_USER_HOME = "/var/tmp/gradle-${EXECUTOR_NUMBER}"
/* coverage report identification */
COVERALLS_SERVICE_NAME = "jenkins"
COVERALLS_SERVICE_JOB_ID = "${JOB_NAME}#${BUILD_NUMBER}"
}

stages {
@@ -65,6 +68,11 @@ pipeline {
script { cmn.nix.shell('lein test-cljs') }
}
}
stage('Coverage') {
steps {
script { android.coverage() }
}
}
} }
stage('Build') { stages {
stage('Clojure') {

+ 11
- 0
ci/android.groovy View File

@@ -101,4 +101,15 @@ def uploadToDiawi() {
return diawiUrl
}

def coverage() {
withCredentials([
string(credentialsId: 'coveralls-status-react-token', variable: 'COVERALLS_REPO_TOKEN'),
]) {
nix.shell(
'make coverage',
keep: ['COVERALLS_REPO_TOKEN', 'COVERALLS_SERVICE_NAME', 'COVERALLS_SERVICE_JOB_ID']
)
}
}

return this

+ 3
- 1
desktop_files/package.json.orig View File

@@ -110,7 +110,9 @@
"@babel/plugin-transform-block-scoping": "7.0.0",
"@babel/preset-env": "7.1.0",
"@babel/register": "7.0.0",
"patch-package": "^5.1.1"
"patch-package": "^5.1.1",
"coveralls": "^3.0.4",
"nyc": "^14.1.1"
},
"optionalDependencies": {
"appdmg": "^0.5.2"

+ 655
- 10
desktop_files/yarn.lock
File diff suppressed because it is too large
View File


+ 4
- 0
mobile_files/package.json.orig View File

@@ -75,5 +75,9 @@
"url": "0.10.3",
"web3": "git+https://github.com/status-im/web3.js.git#0.20.3-status.alpha.3",
"web3-utils": "1.0.0-beta.36"
},
"devDependencies": {
"coveralls": "^3.0.4",
"nyc": "^14.1.1"
}
}

+ 540
- 14
mobile_files/yarn.lock
File diff suppressed because it is too large
View File


+ 51
- 0
scripts/run-coverage.sh View File

@@ -0,0 +1,51 @@
#!/usr/bin/env bash

# Fail on first error
set -e

TEST_JS=target/test/test.js
COVERAGE_REPORT=coverage-report/lcov.info

rm -rf "${COVERAGE_REPORT}"

RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'

if [ ! -f "$TEST_JS" ]; then
echo -e "${YELLOW}test suite not found, compiling and running...${NC}"
make test
else
echo -e "${YELLOW}test suite found.${NC}"
fi

echo -e "${YELLOW}running test suite with coverage...${NC}"

nyc node target/test/test.js

echo -e "${GREEN}DONE.${NC}"

if [ ! -f "$COVERAGE_REPORT" ]; then
echo -e "${RED}coverage report not generated! check nyc configuration file .nycrc${NC}"
exit 1
fi

## COVERALLS ENV ##

# COVERALLS_REPO_TOKEN (the secret repo token from coveralls.io)

# optionals ENV
# COVERALLS_SERVICE_NAME (the name of your build system, "jenkins"
# COVERALLS_SERVICE_JOB_ID

if [ -z "$COVERALLS_REPO_TOKEN" ]; then
echo -e "${RED}COVERALLS_REPO_TOKEN not set!${NC}"
exit 1
fi

echo -e "${YELLOW}uploading coverage to coveralls...${NC}"

cat coverage-report/lcov.info | coveralls

echo -e "${GREEN}DONE.${NC}"

Loading…
Cancel
Save