The change in the measurement of CVAT-UI code coverage. (#2295)

* The change in the measurement of CVAT-UI code coverage.

* Firefox to cron without coverage.

PR, push coverage via Chrome.

* Refactoring .travis.yml.

Added a wait of 10 seconds in the first test to prevent a login error in CVAT after rebuilding containers after code instrumentation.

Co-authored-by: Kruchinin <dmitryx.kruchinin@intel.com>
main
Dmitry Kruchinin 5 years ago committed by GitHub
parent c50e3efca5
commit 70e89d6f83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,8 +1,6 @@
{
"all": true,
"recursive": true,
"compact": false,
"useInlineSourceMaps": false,
"extension": [
".js",
".jsx",

@ -10,6 +10,7 @@ cache:
addons:
firefox: "latest"
chrome: stable
apt:
packages:
- libgconf-2-4
@ -34,27 +35,21 @@ before_script:
script:
- docker-compose -f docker-compose.yml -f docker-compose.ci.yml run cvat_ci /bin/bash -c 'coverage run -a manage.py test cvat/apps utils/cli && mv .coverage ${CONTAINER_COVERAGE_DATA_DIR}'
- docker-compose -f docker-compose.yml -f docker-compose.ci.yml run cvat_ci /bin/bash -c 'cd cvat-data && npm install && cd ../cvat-core && npm install && npm run test && coveralls-lcov -v -n ./reports/coverage/lcov.info > ${CONTAINER_COVERAGE_DATA_DIR}/coverage.json'
- docker-compose -f docker-compose.yml -f docker-compose.ci.yml run cvat_ci /bin/bash -c 'cd cvat-data && npm install && cd ../cvat-core && npm install && npm run test && mv ./reports/coverage/lcov.info ${CONTAINER_COVERAGE_DATA_DIR} && chmod a+rwx ${CONTAINER_COVERAGE_DATA_DIR}/lcov.info'
- docker-compose up -d
# Create superuser
- docker exec -it cvat bash -ic "echo \"from django.contrib.auth.models import User; User.objects.create_superuser('${DJANGO_SU_NAME}', '${DJANGO_SU_EMAIL}', '${DJANGO_SU_PASSWORD}')\" | python3 ~/manage.py shell"
# End-to-end testing
- cd ./tests && npm install && cd ..
- if [[ $TRAVIS_EVENT_TYPE == "cron" && $TRAVIS_BRANCH == "develop" ]];
then
cd ./tests && npm install &&
npm run cypress:run:firefox && cd .. &&
npm install &&
npm run coverage &&
docker-compose up -d --build &&
cd ./tests &&
npm run cypress:run:chrome && cd .. &&
npm run report:coverage:text &&
npm run report:coverage:lcov;
else
cd ./tests && npm install &&
npm run cypress:run:chrome && cd ..;
cd ./tests && npm run cypress:run:firefox && exit $?;
fi;
- npm install && npm run coverage
- docker-compose up -d --build
- cd ./tests && npx cypress run --headless --browser chrome
- mv ./.nyc_output ../ && cd ..
- npx nyc report --reporter=text-lcov >> ${HOST_COVERAGE_DATA_DIR}/lcov.info
- docker-compose -f docker-compose.yml -f docker-compose.ci.yml run cvat_ci /bin/bash -c 'cd ${CONTAINER_COVERAGE_DATA_DIR} && coveralls-lcov -v -n lcov.info > ${CONTAINER_COVERAGE_DATA_DIR}/coverage.json'
after_success:
# https://coveralls-python.readthedocs.io/en/latest/usage/multilang.html

@ -44,9 +44,7 @@
"coverage": "npm run instrument && npm run cp && npm run rm",
"instrument": "nyc instrument cvat-ui cvat-ui_cov && nyc instrument cvat-canvas cvat-canvas_cov && nyc instrument cvat-data cvat-data_cov && nyc instrument cvat-core cvat-core_cov",
"cp": "cp -r cvat-ui_cov/* cvat-ui && cp -r cvat-canvas_cov/* cvat-canvas && cp -r cvat-data_cov/* cvat-data && cp -r cvat-core_cov/* cvat-core",
"rm": "rm -rf cvat-ui_cov && rm -rf cvat-canvas_cov && rm -rf cvat-data_cov && rm -r cvat-core_cov",
"report:coverage:text": "nyc report --reporter=text",
"report:coverage:lcov": "nyc report --reporter=text-lcov | coveralls"
"rm": "rm -rf cvat-ui_cov cvat-canvas_cov cvat-data_cov cvat-core_cov"
},
"repository": {
"type": "git",

@ -29,5 +29,6 @@ describe('Check server availability', () => {
it('Click to "Sign in" button', () => {
cy.get('[type="submit"]').click()
cy.wait(10000)
})
})

@ -8,21 +8,8 @@
const {imageGenerator} = require('../plugins/imageGenerator/addPlugin')
const {createZipArchive} = require('../plugins/createZipArchive/addPlugin')
const istanbul = require('istanbul-lib-coverage')
const { join } = require('path')
const { existsSync, mkdirSync, writeFileSync } = require('fs')
const execa = require('execa')
module.exports = (on) => {
let coverageMap = istanbul.createCoverageMap({})
const outputFolder = '../.nyc_output'
const nycFilename = join(outputFolder, 'out.json')
if (!existsSync(outputFolder)) {
mkdirSync(outputFolder)
console.log('created folder %s for output coverage', outputFolder)
}
module.exports = (on, config) => {
require('@cypress/code-coverage/task')(on, config)
on('task', {imageGenerator})
on('task', {createZipArchive})
on('task', {
@ -31,22 +18,5 @@ module.exports = (on) => {
return null
}
})
on('task', {
/**
* Combines coverage information from single test
* with previously collected coverage.
*/
combineCoverage (coverage) {
coverageMap.merge(coverage)
return null
},
/**
* Saves coverage information as a JSON file and calls
*/
coverageReportPrepare () {
writeFileSync(nycFilename, JSON.stringify(coverageMap, null, 2))
return null
}
})
return config
}

@ -5,6 +5,7 @@
*/
import './commands'
import '@cypress/code-coverage/support'
before(() => {
if (Cypress.browser.name === 'firefox') {
@ -18,19 +19,3 @@ before(() => {
})
}
})
afterEach(() => {
if (Cypress.browser.name === 'chrome') {
cy.window().then(win => {
if (win.__coverage__) {
cy.task('combineCoverage', win.__coverage__)
}
})
}
})
after(() => {
if (Cypress.browser.name === 'chrome') {
cy.task('coverageReportPrepare')
}
})

5617
tests/package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -1,12 +1,12 @@
{
"scripts": {
"cypress:run:chrome": "cypress run --headless --browser chrome",
"cypress:run:firefox": "cypress run --headless --browser firefox"
"cypress:run:chrome": "cypress run --env coverage=false --headless --browser chrome",
"cypress:run:firefox": "cypress run --env coverage=false --headless --browser firefox"
},
"devDependencies": {
"@cypress/code-coverage": "^3.8.1",
"cypress": "^5.0.0",
"cypress-file-upload": "^4.1.1",
"istanbul-lib-coverage": "^3.0.0"
"cypress-file-upload": "^4.1.1"
},
"dependencies": {
"archiver": "^5.0.0",

Loading…
Cancel
Save