diff --git a/.ci/docker-compose.yml b/.ci/docker-compose.yml index f9d9df846..4d3635eed 100644 --- a/.ci/docker-compose.yml +++ b/.ci/docker-compose.yml @@ -7,6 +7,7 @@ services: dockerfile: .ci/Dockerfile args: NODE_JS_VERSION: ${NODE_JS_VERSION:-10} + CODECOV_TOKEN: ${CODECOV_TOKEN} environment: - "TEST_ES_SERVER=http://elasticsearch-oss:9200" volumes: @@ -54,6 +55,8 @@ services: - esnet-platinum depends_on: - elasticsearch-platinum + # there is not need to run again also the unit test + command: ["npm", "run", "test:integration"] elasticsearch-platinum: image: docker.elastic.co/elasticsearch/elasticsearch:${ELASTICSEARCH_VERSION:5.6.15} diff --git a/.ci/jobs/defaults.yml b/.ci/jobs/defaults.yml index 3df606402..a293e7c2a 100644 --- a/.ci/jobs/defaults.yml +++ b/.ci/jobs/defaults.yml @@ -30,6 +30,10 @@ wipe-workspace: 'True' triggers: - github + vault: + url: https://secrets.elastic.co:8200 + # vault read auth/approle/role/clients-ci/role-id + role_id: ddbd0d44-0e51-105b-177a-c8fdfd445126 axes: - axis: type: slave diff --git a/.ci/run-tests b/.ci/run-tests index cccda74c3..0a721624b 100755 --- a/.ci/run-tests +++ b/.ci/run-tests @@ -10,6 +10,12 @@ # - $NODE_JS_VERSION # +set +x +export VAULT_TOKEN=$(vault write -field=token auth/approle/login role_id="$VAULT_ROLE_ID" secret_id="$VAULT_SECRET_ID") +export CODECOV_TOKEN=$(vault read -field=token secret/clients-ci/elasticsearch-js/codecov) +unset VAULT_ROLE_ID VAULT_SECRET_ID VAULT_TOKEN +set -x + ELASTICSEARCH_VERSION=${ELASTICSEARCH_VERSION} NODE_JS_VERSION=${NODE_JS_VERSION} docker-compose -f .ci/docker-compose.yml run client-oss ELASTICSEARCH_VERSION=${ELASTICSEARCH_VERSION} NODE_JS_VERSION=${NODE_JS_VERSION} docker-compose -f .ci/docker-compose.yml run client-platinum diff --git a/.codecov.yml b/.codecov.yml new file mode 100644 index 000000000..eadbe3ef0 --- /dev/null +++ b/.codecov.yml @@ -0,0 +1,14 @@ +comment: off + +coverage: + precision: 2 + round: down + range: "90...100" + + status: + project: yes + patch: yes + changes: no + +ignore: + - "api" diff --git a/package.json b/package.json index 8dd66ec47..b2f142858 100644 --- a/package.json +++ b/package.json @@ -22,11 +22,10 @@ "test:integration": "tap test/integration/index.js -T --harmony --no-esm", "test:types": "tsc --project ./test/types/tsconfig.json", "test:benchmarks": "nanobench test/benchmarks/*.bench.js", + "test:coverage": "tap test/unit/*.test.js -J -t 300 --cov --coverage-report=text-lcov && codecov", "lint": "standard", "lint:fix": "standard --fix", - "generate": "node scripts/run.js", - "elasticsearch": "./scripts/es-docker.sh", - "ci": "npm run license-checker && npm test && npm run test:integration", + "ci": "npm run license-checker && npm test && npm run test:integration && npm run test:coverage", "license-checker": "license-checker --production --onlyAllow='MIT;Apache-2.0;Apache1.1;ISC;BSD-3-Clause;BSD-2-Clause'" }, "author": { @@ -39,6 +38,7 @@ }, "devDependencies": { "@types/node": "^10.12.24", + "codecov": "^3.2.0", "convert-hrtime": "^2.0.0", "dedent": "^0.7.0", "deepmerge": "^3.1.0",