Closed yael-lorenzo closed 6 years ago
Hi @yael-lorenzo-olx seems like you followed the right steps.
The problem seems to be that your lcov.info
seems to be an HTML file and not a real lcov.
Can you share the output.
Hi @rtfpessoa, thanks for the quick reply, the content of th lcov.info is
dev@asset482:~/jenkins/workspace/PWA$ cat coverage/lcov.info TN: SF:/home/dev/jenkins/workspace/PWA/Staging/panamera-web/src/app/App.jsx FN:26,_interopRequireDefault FN:33,(anonymous_1) FN:36,(anonymous_2) FN:36,fetchData FN:110,(anonymous_4)
however, I deleted the ./node_modules/.bin/codacy-coverage and I could not re create it.
what am I missing ?
Ok, so I executed this
rm -rf ./node_modules/
then this
npm install codacy-coverage --save
and then
`dev@asset482:~/jenkins/workspace/PWA$ cat ./node_modules/.bin/codacy-coverage
(function (program, logger, util, lib) { 'use strict'; process.stdin.resume(); process.stdin.setEncoding('utf8');
var input = '';
var loggerImpl;
process.stdin.on('data', function (chunk) {
input += chunk;
if (loggerImpl) {
loggerImpl.trace('Got chunk');
}
});
program
.version(require('../package').version)
.usage('[options]')
.option('-f, --format [value]', 'Coverage input format')
.option('-t, --token [value]', 'Codacy Project API Token')
.option('-c, --commit [value]', 'Commit SHA hash')
.option('-l, --language [value', 'Project Language')
.option('-e, --endpoint [value]', 'Codacy API Endpoint')
.option('-p, --prefix [value]', 'Project path prefix')
.option('-v, --verbose', 'Display verbose output')
.option('-d, --debug', 'Display debug output')
.parse(process.argv);
loggerImpl = logger({
verbose: program.verbose,
debug: program.debug
});
loggerImpl.info(util.format('Started with: token [%j], commitId [%j], language [%j], endpoint [%j], format [%j], path prefix [%j], verbose [%j], debug [%j]',
program.token, program.commit, program.language, program.endpoint, program.format, program.prefix, program.verbose, program.debug));
process.stdin.on('end', function () {
loggerImpl.trace('Received file through stdin');
if (program.help === true) {
return;
}
return lib.handleInput(input, program).then(function () {
loggerImpl.debug('Successfully sent coverage');
}, function (err) {
loggerImpl.error('Error sending coverage');
loggerImpl.error(err);
});
});
}(require('commander'), require('../lib/logger'), require('util'), require('../index')));
then
CODACY_PROJECT_TOKEN='6483049ca61043d691731a3c4d6ce84a' | cat ./coverage/lcov.info | ./node_modules/.bin/codacy-coverage
[error] "2018-02-15T17:57:48.943Z" 'Error sending coverage'
[error] "2018-02-15T17:57:48.945Z" Error: Token is required`
and finally exporting the token to env and running it again apparently worked from CMD
The result is in CODACY.
You should also not invoke the modules inside node_modules directly.
Try something like this https://github.com/rtfpessoa/diff2html/blob/master/package.json#L48 and then run npm run codacy
to have the right setup.
I wil try 👍
I don't understand why the readme is so hard to understand. I am not a user of node js, nor npm. Perhpas that is it. However something "theoritically" so simple and I don't get it how the "publisher" of a report to codacy can be so complicated.
I did
1) Install node-codacy-coverage with npm. 2) Generate coverage using jtest. I got the result in lcov.info file in coverage folder 3) execute CODACY_PROJECT_TOKEN='xxxxxxxxxxxxx'|cat ./coverage/lcov.info | ./node_modules/.bin/codacy-coverage .
the error is
./node_modules/.bin/codacy-coverage: line 1: syntax error near unexpected token
newline' ./node_modules/.bin/codacy-coverage: line 1:<!doctype html>'