Skip to content

Commit

Permalink
Introduce Code-Climate to maintain coverage (oppia#7067)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rishav Chakraborty authored and DubeySandeep committed Jul 8, 2019
1 parent b38e39a commit 699dd31
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 1 deletion.
26 changes: 26 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ var_for_docker_image: &docker_image circleci/python:2.7.14-jessie-browsers

anchor_for_job_defaults: &job_defaults
working_directory: /home/circleci/oppia
# Its okay to hardcode the CC_TEST_REPORTER_ID as the only risk in doing so is
# when someone uses this test coverage ID to post incorrect coverage data.
# This generally does not occur and if it happens, it would be replaced with
# data from subsequent coverage payloads. See this comment for more
# information: https://github.com/oppia/oppia/pull/7067#issuecomment-508822501
environment:
CC_TEST_REPORTER_ID: 561968e2f03d3bb4f1aed69dc94174c2e3b9dc82cf1f8ad31fc799f8c67afc6e
docker:
- image: *docker_image

Expand All @@ -11,6 +18,13 @@ anchor_for_installing_dependencies: &install_dependencies
source scripts/setup.sh || exit 1
source scripts/setup_gae.sh || exit 1
anchor_for_installing_cc_test_reporter: &install_cc
name: Install codeclimate test reporter
command: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
./cc-test-reporter before-build
anchor_for_restoring_cache: &restore_cache
keys:
- setup-files-cache-{{ checksum "date" }}
Expand Down Expand Up @@ -62,11 +76,18 @@ jobs:
name: Run frontend tests
command: |
bash -x scripts/run_frontend_tests.sh --run-minified-tests=true
# TODO(lilithxxx): Uncomment the following lines once #6821 is resolved.
# - run:
# <<: *install_cc
- run:
name: Generate frontend coverage report
command: |
sudo pip install codecov
codecov --file ../karma_coverage_reports/coverage-final.json
# TODO(lilithxxx): Uncomment the following lines and delete the above
# codecov statements once #6821 is resolved.
# ./cc-test-reporter sum-coverage ../karma_coverage_reports/coverage-final.json
# ./cc-test-reporter upload-coverage ../karma_coverage_reports/coverage-final.json
when: on_success

backend_tests:
Expand All @@ -80,11 +101,16 @@ jobs:
name: Run backend tests
command: |
bash scripts/run_backend_tests.sh --generate_coverage_report --exclude_load_tests
- run:
<<: *install_cc
- run:
name: Generate backend coverage report
command: |
sudo pip install codecov
codecov
./cc-test-reporter format-coverage -t coverage.py coverage.xml
./cc-test-reporter sum-coverage coverage/codeclimate.json
./cc-test-reporter upload-coverage
when: on_success

workflows:
Expand Down
6 changes: 6 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# .coveragerc to control coverage.py
[run]
omit =
*/oppia_tools/*
*/third_party/*
*/usr/*
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
/.eslintignore @apb7
/.eslintrc @apb7
/.htmllintrc @apb7
/.coveragerc @apb7
/.gitattributes @apb7
/.gitignore @apb7
/.isort.cfg @apb7
Expand Down
2 changes: 1 addition & 1 deletion .github/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# [Oppia](https://www.oppia.org) [![Build Status](https://api.travis-ci.org/oppia/oppia.svg?branch=develop)](https://travis-ci.org/oppia/oppia) [![Code Coverage](https://codecov.io/github/oppia/oppia/coverage.svg?branch=develop)](https://codecov.io/github/oppia/oppia/?branch=develop) [![Join the chat at https://gitter.im/oppia/oppia-chat](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/oppia/oppia-chat?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
# [Oppia](https://www.oppia.org) [![Build Status](https://api.travis-ci.org/oppia/oppia.svg?branch=develop)](https://travis-ci.org/oppia/oppia) [![Code Coverage](https://api.codeclimate.com/v1/badges/eaa9dfe89c760481079d/test_coverage)](https://codeclimate.com/github/oppia/oppia/test_coverage) [![Join the chat at https://gitter.im/oppia/oppia-chat](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/oppia/oppia-chat?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

Oppia is an online learning tool that enables anyone to easily create and share interactive activities (called 'explorations'). These activities simulate a one-on-one conversation with a tutor, making it possible for students to learn by doing while getting feedback.

Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ core/templates/dev/head/dist/*
core/tests/.browserstack.env
node_modules/*
.coverage*
!.coveragerc
coverage.xml
.viminfo
.vscode/*
libpeerconnection.log
Expand Down
3 changes: 3 additions & 0 deletions scripts/run_backend_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ for arg in "$@"; do
if [ "$arg" == "--generate_coverage_report" ]; then
$PYTHON_CMD $COVERAGE_HOME/coverage combine
$PYTHON_CMD $COVERAGE_HOME/coverage report --omit="$TOOLS_DIR/*","$THIRD_PARTY_DIR/*","/usr/share/*" --show-missing

echo "Generating xml coverage report..."
$PYTHON_CMD $COVERAGE_HOME/coverage xml
fi
done

Expand Down

0 comments on commit 699dd31

Please sign in to comment.