From e81516ca8020e2ab96aee2859f0200d92108cc3e Mon Sep 17 00:00:00 2001 From: Austin Schaffer Date: Fri, 31 Jan 2020 14:12:52 -0500 Subject: [PATCH] [DEV-6721] Add optional code coverage --- .gitlab-ci.yml | 8 ++++++-- Makefile.am | 5 +++-- configure.ac | 10 ++++++++++ package.json.in | 4 +++- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4461efe..9ec1167 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,12 +3,13 @@ image: $BUILD_IMAGE stages: - build - deploy + - publish build: stage: build script: - autoreconf -fvi - - ./configure --with-srcuri="$SRCURI" + - ./configure --with-srcuri="$SRCURI" --enable-code-coverage - npm install - make all - make info pdf html @@ -16,6 +17,7 @@ build: artifacts: paths: - doc/ + - coverage/ expire_in: 30 min pages: @@ -23,9 +25,11 @@ pages: script: - mkdir -p public/doc - mv doc/liza.html/* doc/liza.pdf doc/liza.info public/ + - mkdir -p public/coverage + - mv coverage/* public/coverage artifacts: paths: - public/ expire_in: 30 min only: - - tags + - tags \ No newline at end of file diff --git a/Makefile.am b/Makefile.am index 9e0d6f8..2e7a45f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -67,10 +67,11 @@ check-ts-out: test: check check: $(tsout) check-ts-out - PATH="$(PATH):$(CURDIR)/node_modules/mocha/bin" \ - mocha @NODE_DESTRUCTURE@ \ + PATH="$(PATH):$(CURDIR)/node_modules/.bin" \ + @CODE_COV@ mocha @NODE_DESTRUCTURE@ \ --require $(path_test)/pre.js \ --recursive \ + @COV_ARGS@ \ $(TESTARGS) FORCE: diff --git a/configure.ac b/configure.ac index 3a0fbc5..c5fc84d 100644 --- a/configure.ac +++ b/configure.ac @@ -79,6 +79,16 @@ AC_ARG_WITH( AC_SUBST([SET_SRCURI], [$set_srcuri]) +AC_ARG_ENABLE( + [code_coverage], + [AS_HELP_STRING([--enable-code-coverage], + [Generate a code coverage report when tests are run + (disabled by default)])], + AC_SUBST([CODE_COV], ["nyc --reporter=html --reporter=text --all --include=src \ + --exclude=**/index.js --exclude=src/version.js"]) + AC_SUBST([COV_ARGS], ["--require ts-node/register/transpile-only \ + --require source-map-support/register"])) + AC_SUBST([AUTOGENERATED], ["THIS FILE IS AUTOGENERATED! DO NOT MODIFY! See *.in."]) diff --git a/package.json.in b/package.json.in index 35abffe..4a99f08 100644 --- a/package.json.in +++ b/package.json.in @@ -43,7 +43,9 @@ "@types/mocha": "5.2.0", "sinon": ">=1.17.4", "es6-promise": "~3", - "@types/amqplib": "0.5.13" + "@types/amqplib": "0.5.13", + "nyc": "15.0.0", + "ts-node": "^8.6.2" }, "licenses": [