diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 000000000000..930299b0d1a8 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,103 @@ +var_for_docker_image: &docker_image circleci/python:2.7.14-jessie-browsers + +anchor_for_job_defaults: &job_defaults + working_directory: /home/circleci/oppia + docker: + - image: *docker_image + +anchor_for_installing_dependencies: &install_dependencies + name: Install dependencies + command: | + source scripts/setup.sh || exit 1 + source scripts/setup_gae.sh || exit 1 + +anchor_for_restoring_cache: &restore_cache + keys: + - setup-files-cache-{{ checksum "date" }} + - third-party-cache-{{ checksum "date" }} + +version: 2 +jobs: + setup: + <<: *job_defaults + steps: + - checkout + - run: date +%F > date + - restore_cache: + <<: *restore_cache + - run: + <<: *install_dependencies + - save_cache: + key: setup-files-cache-{{ checksum "date" }} + paths: + - ../node_modules/ + - ../oppia_tools/ + + lint_tests: + <<: *job_defaults + steps: + - checkout + - run: date +%F > date + - restore_cache: + <<: *restore_cache + - run: + name: Run lint tests + command: | + bash scripts/install_third_party.sh + python scripts/third_party_size_check.py + python scripts/pre_commit_linter.py --path=. + - save_cache: + key: third-party-cache-{{ checksum "date" }} + paths: + - third_party/ + + frontend_tests: + <<: *job_defaults + steps: + - checkout + - run: date +%F > date + - restore_cache: + <<: *restore_cache + - run: + name: Run frontend tests + command: | + bash -x scripts/run_frontend_tests.sh --run-minified-tests=true + - run: + name: Generate frontend coverage report + command: | + sudo pip install codecov + codecov --file ../karma_coverage_reports/coverage-final.json + when: on_success + + backend_tests: + <<: *job_defaults + steps: + - checkout + - run: date +%F > date + - restore_cache: + <<: *restore_cache + - run: + name: Run backend tests + command: | + bash scripts/run_backend_tests.sh --generate_coverage_report --exclude_load_tests + - run: + name: Generate backend coverage report + command: | + sudo pip install codecov + codecov + when: on_success + +workflows: + version: 2 + circleci_tests: + jobs: + - setup + - lint_tests: + requires: + - setup + - frontend_tests: + requires: + - setup + - backend_tests: + requires: + - setup diff --git a/.travis.yml b/.travis.yml index a76b45c59852..d786fcf070f8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,9 +19,11 @@ branches: env: matrix: - - RUN_LINT=true - - RUN_FRONTEND_TESTS=true - - RUN_BACKEND_TESTS=true REPORT_BACKEND_COVERAGE=false EXCLUDE_LOAD_TESTS=true + # These lines are commented out because these checks are being run on CircleCI + # here: https://circleci.com/gh/oppia/oppia + # - RUN_LINT=true + # - RUN_FRONTEND_TESTS=true + # - RUN_BACKEND_TESTS=true REPORT_BACKEND_COVERAGE=false EXCLUDE_LOAD_TESTS=true # TODO(sll): Reinstate this when we can get it to run in reasonable time. # - RUN_BACKEND_TESTS=true REPORT_BACKEND_COVERAGE=true # TODO(sll): Reinstate this when the load tests are more reliable. @@ -98,16 +100,19 @@ install: - pushd $TRAVIS_BUILD_DIR - source scripts/setup.sh || exit 1 - source scripts/setup_gae.sh || exit 1 +- bash scripts/install_third_party.sh script: -- if [ "$RUN_LINT" == 'true' ]; then bash scripts/install_third_party.sh; python scripts/third_party_size_check.py; python scripts/pre_commit_linter.py --path=.; fi +# These lines are commented out because these checks are being run on CircleCI +# here: https://circleci.com/gh/oppia/oppia +# - if [ "$RUN_LINT" == 'true' ]; then python scripts/third_party_size_check.py; python scripts/pre_commit_linter.py --path=.; fi # Travis aborts test run if nothing is printed back to STDOUT for some time. # -x is used to avoid that. -- if [ "$RUN_FRONTEND_TESTS" == 'true' ]; then travis_retry bash -x scripts/run_frontend_tests.sh --run-minified-tests=true; fi -- if [ "$RUN_BACKEND_TESTS" == 'true' ] && [ "$REPORT_BACKEND_COVERAGE" == 'true' ] && [ "$EXCLUDE_LOAD_TESTS" == 'true' ]; then bash scripts/run_backend_tests.sh --generate_coverage_report --exclude_load_tests; fi -- if [ "$RUN_BACKEND_TESTS" == 'true' ] && [ "$REPORT_BACKEND_COVERAGE" == 'false' ] && [ "$EXCLUDE_LOAD_TESTS" == 'true' ]; then bash scripts/run_backend_tests.sh --exclude_load_tests; fi -- if [ "$RUN_BACKEND_TESTS" == 'true' ] && [ "$REPORT_BACKEND_COVERAGE" == 'true' ] && [ "$EXCLUDE_LOAD_TESTS" == 'false' ]; then bash scripts/run_backend_tests.sh --generate_coverage_report; fi -- if [ "$RUN_BACKEND_TESTS" == 'true' ] && [ "$REPORT_BACKEND_COVERAGE" == 'false' ] && [ "$EXCLUDE_LOAD_TESTS" == 'false' ]; then bash scripts/run_backend_tests.sh; fi +# - if [ "$RUN_FRONTEND_TESTS" == 'true' ]; then travis_retry bash -x scripts/run_frontend_tests.sh --run-minified-tests=true; fi +# - if [ "$RUN_BACKEND_TESTS" == 'true' ] && [ "$REPORT_BACKEND_COVERAGE" == 'true' ] && [ "$EXCLUDE_LOAD_TESTS" == 'true' ]; then bash scripts/run_backend_tests.sh --generate_coverage_report --exclude_load_tests; fi +# - if [ "$RUN_BACKEND_TESTS" == 'true' ] && [ "$REPORT_BACKEND_COVERAGE" == 'false' ] && [ "$EXCLUDE_LOAD_TESTS" == 'true' ]; then bash scripts/run_backend_tests.sh --exclude_load_tests; fi +# - if [ "$RUN_BACKEND_TESTS" == 'true' ] && [ "$REPORT_BACKEND_COVERAGE" == 'true' ] && [ "$EXCLUDE_LOAD_TESTS" == 'false' ]; then bash scripts/run_backend_tests.sh --generate_coverage_report; fi +# - if [ "$RUN_BACKEND_TESTS" == 'true' ] && [ "$REPORT_BACKEND_COVERAGE" == 'false' ] && [ "$EXCLUDE_LOAD_TESTS" == 'false' ]; then bash scripts/run_backend_tests.sh; fi # Run e2e tests in production mode. - if [ "$RUN_E2E_TESTS_ACCESSIBILITY" == 'true' ]; then travis_retry bash scripts/run_e2e_tests.sh --suite="accessibility" --prod_env; fi - if [ "$RUN_E2E_TESTS_ADDITIONAL_EDITOR_AND_PLAYER_FEATURES" == 'true' ]; then travis_retry bash scripts/run_e2e_tests.sh --suite="additionalEditorAndPlayerFeatures" --prod_env; fi @@ -132,9 +137,11 @@ script: # Run e2e tests for mobile in dev mode since the demo explorations and collections are only available in the dev mode and not in production mode. - if [ "$RUN_E2E_TESTS_MOBILE" == 'true' ]; then travis_retry bash scripts/run_e2e_tests.sh --browserstack; fi -after_success: -- if [ "$RUN_BACKEND_TESTS" == 'true' ] && [ "$REPORT_BACKEND_COVERAGE" == 'true' ]; then codecov; fi -- if [ "$RUN_FRONTEND_TESTS" == 'true' ]; then codecov --file ../karma_coverage_reports/coverage-final.json; fi +# These lines are commented out because these checks are being run on CircleCI +# here: https://circleci.com/gh/oppia/oppia +# after_success: +# - if [ "$RUN_BACKEND_TESTS" == 'true' ] && [ "$REPORT_BACKEND_COVERAGE" == 'true' ]; then codecov; fi +# - if [ "$RUN_FRONTEND_TESTS" == 'true' ]; then codecov --file ../karma_coverage_reports/coverage-final.json; fi cache: # Cache Oppia's dependencies.