2018-12-28 09:21:03 +01:00
|
|
|
# See https://zulip.readthedocs.io/en/latest/testing/continuous-integration.html for
|
|
|
|
# high-level documentation on our CircleCI setup.
|
2017-08-30 02:09:09 +02:00
|
|
|
# See CircleCI upstream's docs on this config format:
|
|
|
|
# https://circleci.com/docs/2.0/language-python/
|
|
|
|
#
|
|
|
|
version: 2
|
2018-12-05 16:46:25 +01:00
|
|
|
aliases:
|
|
|
|
- &create_cache_directories
|
|
|
|
run:
|
|
|
|
name: create cache directories
|
|
|
|
command: |
|
|
|
|
dirs=(/srv/zulip-{npm,venv}-cache)
|
|
|
|
sudo mkdir -p "${dirs[@]}"
|
|
|
|
sudo chown -R circleci "${dirs[@]}"
|
|
|
|
|
2018-12-05 17:24:51 +01:00
|
|
|
- &restore_cache_package_json
|
|
|
|
restore_cache:
|
|
|
|
keys:
|
2018-12-05 17:24:51 +01:00
|
|
|
- v1-npm-base.{{ .Environment.CIRCLE_JOB }}-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
|
2018-12-05 17:24:51 +01:00
|
|
|
|
|
|
|
- &restore_cache_requirements
|
|
|
|
restore_cache:
|
|
|
|
keys:
|
2018-12-05 17:24:51 +01:00
|
|
|
- v1-venv-base.{{ .Environment.CIRCLE_JOB }}-{{ checksum "requirements/thumbor.txt" }}-{{ checksum "requirements/dev.txt" }}
|
2018-12-05 17:24:51 +01:00
|
|
|
|
2018-12-05 16:53:07 +01:00
|
|
|
- &install_dependencies
|
|
|
|
run:
|
|
|
|
name: install dependencies
|
|
|
|
command: |
|
|
|
|
sudo apt-get update
|
2018-12-05 21:33:41 +01:00
|
|
|
# Install moreutils so we can use `ts` and `mispipe` in the following.
|
2018-12-05 16:53:07 +01:00
|
|
|
sudo apt-get install -y moreutils
|
2018-12-05 21:33:41 +01:00
|
|
|
|
|
|
|
# CircleCI sets the following in Git config at clone time:
|
|
|
|
# url.ssh://git@github.com.insteadOf https://github.com
|
|
|
|
# This breaks the Git clones in the NVM `install.sh` we run
|
|
|
|
# in `install-node`.
|
|
|
|
# TODO: figure out why that breaks, and whether we want it.
|
|
|
|
# (Is it an optimization?)
|
2018-12-05 16:53:07 +01:00
|
|
|
rm -f /home/circleci/.gitconfig
|
2018-12-05 21:33:41 +01:00
|
|
|
|
|
|
|
# This is the main setup job for the test suite
|
2018-12-10 08:05:16 +01:00
|
|
|
mispipe "tools/ci/setup-backend" ts
|
2018-12-05 16:53:07 +01:00
|
|
|
|
2018-12-05 21:33:41 +01:00
|
|
|
# Cleaning caches is mostly unnecessary in Circle, because
|
|
|
|
# most builds don't get to write to the cache.
|
|
|
|
# mispipe "scripts/lib/clean-unused-caches --verbose --threshold 0" ts
|
|
|
|
|
2018-12-05 17:30:08 +01:00
|
|
|
- &save_cache_package_json
|
|
|
|
save_cache:
|
|
|
|
paths:
|
|
|
|
- /srv/zulip-npm-cache
|
2018-12-05 17:24:51 +01:00
|
|
|
key: v1-npm-base.{{ .Environment.CIRCLE_JOB }}-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
|
2018-12-05 17:30:08 +01:00
|
|
|
|
|
|
|
- &save_cache_requirements
|
|
|
|
save_cache:
|
|
|
|
paths:
|
|
|
|
- /srv/zulip-venv-cache
|
2018-12-05 17:24:51 +01:00
|
|
|
key: v1-venv-base.{{ .Environment.CIRCLE_JOB }}-{{ checksum "requirements/thumbor.txt" }}-{{ checksum "requirements/dev.txt" }}
|
2018-12-05 17:30:08 +01:00
|
|
|
# TODO: in Travis we also cache ~/zulip-emoji-cache, ~/node, ~/misc
|
|
|
|
|
2018-12-05 16:55:08 +01:00
|
|
|
- &run_backend_tests
|
|
|
|
run:
|
|
|
|
name: run backend tests
|
|
|
|
command: |
|
|
|
|
. /srv/zulip-py3-venv/bin/activate
|
2018-12-10 08:05:16 +01:00
|
|
|
mispipe ./tools/ci/backend ts
|
2018-12-05 16:55:08 +01:00
|
|
|
|
2018-12-05 16:58:41 +01:00
|
|
|
- &run_frontend_tests
|
|
|
|
run:
|
|
|
|
name: run frontend tests
|
|
|
|
command: |
|
|
|
|
. /srv/zulip-py3-venv/bin/activate
|
2018-12-10 08:05:16 +01:00
|
|
|
mispipe ./tools/ci/frontend ts
|
2018-12-05 16:58:41 +01:00
|
|
|
|
2018-12-05 17:00:55 +01:00
|
|
|
- &upload_coverage_report
|
|
|
|
run:
|
|
|
|
name: upload coverage report
|
|
|
|
command: |
|
|
|
|
. /srv/zulip-py3-venv/bin/activate
|
|
|
|
pip install codecov && codecov \
|
|
|
|
|| echo "Error in uploading coverage reports to codecov.io."
|
|
|
|
|
2017-08-30 02:09:09 +02:00
|
|
|
jobs:
|
2018-01-30 21:20:50 +01:00
|
|
|
"trusty-python-3.4":
|
2017-08-30 02:09:09 +02:00
|
|
|
docker:
|
2018-01-30 21:20:50 +01:00
|
|
|
# This is built from tools/circleci/images/trusty/Dockerfile .
|
2018-06-02 01:24:21 +02:00
|
|
|
- image: gregprice/circleci:trusty-python-5.test
|
2017-08-30 02:09:09 +02:00
|
|
|
|
2018-01-30 21:21:29 +01:00
|
|
|
working_directory: ~/zulip
|
2017-08-30 02:09:09 +02:00
|
|
|
|
|
|
|
steps:
|
|
|
|
- checkout
|
|
|
|
|
2018-12-05 16:46:25 +01:00
|
|
|
- *create_cache_directories
|
2018-12-05 17:24:51 +01:00
|
|
|
- *restore_cache_package_json
|
|
|
|
- *restore_cache_requirements
|
2018-12-05 21:33:41 +01:00
|
|
|
- *install_dependencies
|
2018-12-05 17:30:08 +01:00
|
|
|
- *save_cache_package_json
|
|
|
|
- *save_cache_requirements
|
2018-12-05 16:55:08 +01:00
|
|
|
- *run_backend_tests
|
2018-12-05 16:58:41 +01:00
|
|
|
- *run_frontend_tests
|
2018-12-05 17:00:55 +01:00
|
|
|
- *upload_coverage_report
|
circleci: Upload coverage reports to codecov.io.
The Travis config does this by a `pip install codecov` in setup and
running the resulting `codecov` command at the end. That risks
confusion because it makes the library look like something we might
be using *during* the tests to collect coverage information.
Instead, install and run codecov together at the end.
(The docs also suggest using their bash-based uploader instead;
but following those directions seems to result in coverage.xml
not getting included (maybe not even built), and no coverage data
getting uploaded for Python source files, only JavaScript. Not
sure why that is, but using the pip package is fine.)
Also, because this step is inherently about talking to a
third-party service whose reliability we can't control, and because
it's purely a reporting step that happens after our actual test
suite has succeeded, don't fail if it fails; just print a message.
(I'd prefer a somewhat louder message, like turning that step
yellow or something in the Circle web UI, but Circle doesn't offer
an option like that. If the coverage reports start consistently
failing for some reason, then if we're actually reading them we'll
notice anyway.)
[greg: Edited step name and error message; wrote this commit message.]
2018-01-26 21:08:13 +01:00
|
|
|
|
2017-08-30 02:09:09 +02:00
|
|
|
# - store_artifacts: # TODO
|
|
|
|
# path: var/casper/
|
|
|
|
# # also /tmp/zulip-test-event-log/
|
|
|
|
# destination: test-reports
|
|
|
|
|
2018-01-30 21:20:50 +01:00
|
|
|
"xenial-python-3.5":
|
|
|
|
docker:
|
|
|
|
# This is built from tools/circleci/images/xenial/Dockerfile .
|
2018-06-02 01:24:21 +02:00
|
|
|
- image: gregprice/circleci:xenial-python-4.test
|
2018-01-30 21:20:50 +01:00
|
|
|
|
2018-01-30 21:21:29 +01:00
|
|
|
working_directory: ~/zulip
|
2018-01-30 21:20:50 +01:00
|
|
|
|
|
|
|
steps:
|
|
|
|
- checkout
|
2018-12-05 16:46:25 +01:00
|
|
|
- *create_cache_directories
|
2018-12-05 17:24:51 +01:00
|
|
|
- *restore_cache_package_json
|
|
|
|
- *restore_cache_requirements
|
2018-12-05 16:53:07 +01:00
|
|
|
- *install_dependencies
|
2018-12-05 17:30:08 +01:00
|
|
|
- *save_cache_package_json
|
|
|
|
- *save_cache_requirements
|
2018-12-05 16:55:08 +01:00
|
|
|
- *run_backend_tests
|
2018-12-05 17:00:55 +01:00
|
|
|
- *upload_coverage_report
|
2018-01-31 18:41:05 +01:00
|
|
|
|
2018-05-30 18:46:08 +02:00
|
|
|
"bionic-python-3.6":
|
|
|
|
docker:
|
|
|
|
# This is built from tools/circleci/images/bionic/Dockerfile .
|
|
|
|
- image: gregprice/circleci:bionic-python-1.test
|
|
|
|
|
|
|
|
working_directory: ~/zulip
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- checkout
|
|
|
|
|
2018-12-05 16:46:25 +01:00
|
|
|
- *create_cache_directories
|
|
|
|
|
2018-05-30 18:46:08 +02:00
|
|
|
- run:
|
2018-12-05 16:46:25 +01:00
|
|
|
name: do Bionic hack
|
2018-05-30 18:46:08 +02:00
|
|
|
command: |
|
|
|
|
# Temporary hack till `sudo service redis-server start` gets fixes in Bionic. See
|
|
|
|
# https://chat.zulip.org/#narrow/stream/3-backend/topic/Ubuntu.20bionic.20CircleCI
|
|
|
|
redis-server --daemonize yes
|
|
|
|
|
2018-12-05 17:24:51 +01:00
|
|
|
- *restore_cache_package_json
|
|
|
|
- *restore_cache_requirements
|
2018-12-05 16:53:07 +01:00
|
|
|
- *install_dependencies
|
2018-12-05 17:30:08 +01:00
|
|
|
- *save_cache_package_json
|
|
|
|
- *save_cache_requirements
|
2018-12-05 16:55:08 +01:00
|
|
|
- *run_backend_tests
|
2018-12-05 17:00:55 +01:00
|
|
|
- *upload_coverage_report
|
2018-05-30 18:46:08 +02:00
|
|
|
|
2018-01-30 21:20:50 +01:00
|
|
|
workflows:
|
|
|
|
version: 2
|
|
|
|
build:
|
|
|
|
jobs:
|
|
|
|
- "trusty-python-3.4"
|
|
|
|
- "xenial-python-3.5"
|
2018-05-30 18:46:08 +02:00
|
|
|
- "bionic-python-3.6"
|