@@ -31,131 +31,50 @@ Generation/publication of the code coverage results consists of the following:
3131 us to minimize who can modify the nodejs.org website as no additional
3232 access is required.
3333
34- # Benchmark Job
34+ # Coverage Job
3535
36- The benchmark job follows the same pattern as our other build jobs in order
36+ The coverage job follows the same pattern as our other build jobs in order
3737to check out the version of node to be build/tested. It requires the following
3838additions:
3939
40-
41- 1 . Checkout of the scripts used to generate the coverage
42-
43- ```
44- if [ ! -d testing ]; then
45- git clone --depth=10 --single-branch https://github.com/nodejs/testing.git
46- else
47- cd testing
48- git pull
49- fi
50- ```
51-
52- 2 . Get a copy of gcov:
40+ 1 . Build/test with the coverage targets. This is currently:
5341
5442 ```
55- # get gcov if required and then apply patches that are required for it
56- # to work with Node.js.
57- if [ ! -d gcovr ]; then
58- git clone --depth=10 --single-branch git://github.com/gcovr/gcovr.git
59- (cd gcovr && patch -p1 < "../testing/coverage/gcovr-patches.diff")
60- fi
43+ ./configure --coverage
44+ make coverage-clean
45+ NODE_TEST_DIR=${HOME}/node-tmp PYTHON=python COVTESTS=test-ci make coverage -j $(getconf _NPROCESSORS_ONLN)
6146 ```
6247
63- 3 . Install the npm modules that we use to instrument Node.js and
64- generate JavaScript coverage, instrument Node.js
65- (both JavaScript and c++) and remove any
66- old coverage files. This requires first building Node.js without
67- coverage so we can install the npm modules and then use those npms to do
68- the instrumentation. A later step will then rebuild as we would in the
69- normal build/test jobs resulting in an instrumented binary. The step
70- that instruments for C++ currently requires patching the Node.js source
71- tree (patches.diff). We will work to build those changes into the Makefile
72- so that there are additional targets that can be used for code coverage
73- runs and that patching the source is no longer required. This will
74- reduce the likelihood/frequency of conflicts causing the code
75- coverage job to fail due to conflicts.
48+ 2 . Generate html summary page and push results to the benchmarking data machine:
7649
7750 ```
7851 #!/bin/bash
79- # patch things up
80- patch -p1 < "./testing/coverage/patches.diff"
81- export PATH="$(pwd):$PATH"
82-
83- # if we don't have our npm dependencies available, build node and fetch them
84- # with npm
85- if [ ! -x "./node_modules/.bin/nyc" ] || \
86- [ ! -x "./node_modules/.bin/istanbul-merge" ]; then
87- echo "Building, without lib/ coverage..." >&2
88- ./configure
89- make -j $(getconf _NPROCESSORS_ONLN) node
90- ./node -v
91-
9252
93- # get nyc + istanbul-merge
94- "./node" "./deps/npm" install istanbul-merge@1.1.0
95- "./node" "./deps/npm" install nyc@8.0.0-candidate
96-
97- test -x "./node_modules/.bin/nyc"
98- test -x "./node_modules/.bin/istanbul-merge"
99- fi
100-
101-
102- echo "Instrumenting code in lib/..."
103- "./node_modules/.bin/nyc" instrument lib/ lib_/
104- sed -e s~"'"lib/~"'"lib_/~g -i~ node.gyp
105-
106- echo "Removing old coverage files"
107- rm -rf coverage
108- rm -rf out/Release/.coverage
109- rm -f out/Release/obj.target/node/src/*.gcda
110- ```
111-
112- 4 . Build/test as per normal build/test job. This is currently:
113-
114- ```
115- NODE_TEST_DIR=${HOME}/node-tmp PYTHON=python FLAKY_TESTS=$FLAKY_TESTS_MODE make run-ci -j $(getconf _NPROCESSORS_ONLN)
116- ```
117-
118- but modified for that test failures don't stop the rest of the process as the
119- instrumentation seems to have introduced a couple of failures.
120-
121- 5 . Gather coverage and push to the benchmarking data machine:
122-
123- ```
124- #!/bin/bash
53+ # copy the coverage results to the directory where we keep them
54+ # generate the summaries and transfer to the benchmarking data
55+ # machine from which the website will pull them
12556
12657 export PATH="$(pwd):$PATH"
127- echo "Gathering coverage..." >&2
128-
129- mkdir -p coverage .cov_tmp
130- "$WORKSPACE/node_modules/.bin/istanbul-merge" --out .cov_tmp/libcov.json \
131- 'out/Release/.coverage/coverage-*.json'
132- (cd lib && "$WORKSPACE/node_modules/.bin/nyc" report \
133- --temp-directory "$(pwd)/../.cov_tmp" -r html --report-dir "../coverage")
134- (cd out && "$WORKSPACE/gcovr/scripts/gcovr" --gcov-exclude='.*deps' --gcov-exclude='.*usr' -v \
135- -r Release/obj.target/node --html --html-detail \
136- -o ../coverage/cxxcoverage.html)
13758
59+ # copy over results
60+ COMMIT_ID=$(git rev-parse --short=16 HEAD)
13861 mkdir -p "$HOME/coverage-out"
13962 OUTDIR="$HOME/coverage-out/out"
140- COMMIT_ID=$(git rev-parse --short=16 HEAD)
141-
14263 mkdir -p "$OUTDIR"
14364 rm -rf "$OUTDIR/coverage-$COMMIT_ID" || true
144- cp -rv coverage "$OUTDIR/coverage-$COMMIT_ID"
65+ cp -r coverage "$OUTDIR/coverage-$COMMIT_ID"
14566
67+ # add entry into the index and generate the html version
14668 JSCOVERAGE=$(grep -B1 Lines coverage/index.html | \
14769 head -n1 | grep -o '[0-9\.]*')
14870 CXXCOVERAGE=$(grep -A3 Lines coverage/cxxcoverage.html | \
149- grep style | grep -o '[0-9]\{1,3\}\.[0-9]\{1,2\}')
150-
151- echo "JS Coverage: $JSCOVERAGE %"
152- echo "C++ Coverage: $CXXCOVERAGE %"
153-
71+ grep style | grep -o '[0-9]\{1,3\}\.[0-9]\{1,2\}')
15472 NOW=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
15573
15674 echo "$JSCOVERAGE,$CXXCOVERAGE,$NOW,$COMMIT_ID" >> "$OUTDIR/index.csv"
75+
15776 cd $OUTDIR/..
158- $HOME/ coverage-out /generate-index-html.py
77+ $WORKSPACE/testing/ coverage/generate-index-html.py
15978
16079 # transfer results to machine where coverage data is staged.
16180 rsync -r out coveragedata:coverage-out
0 commit comments