bug 1352232: Remove Ansible from py27 build #4239
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4239 +/- ##
==========================================
+ Coverage 86.57% 86.58% +0.01%
==========================================
Files 148 150 +2
Lines 9048 9065 +17
Branches 1199 1198 -1
==========================================
+ Hits 7833 7849 +16
- Misses 988 989 +1
Partials 227 227
Continue to review full report at Codecov.
|
31e8376
to
ae5f594
Compare
Switch to TravisCI-provided MySQL without custom collation. This requires running tests with --no-migrations. The Docker build continues to use MySQL with the custom collation utf8_distinct_ci and migraations. Switch to the TravicCI-recommended method for installing and running ElasticSearch. Update caching so that node installed and downloaded (ElasticSearch and docker-compose) are fast when the version doesn't change. Move configuration environment variables to global, and use additional variables to control what gets installed (rather than TOXENV): * CREATE_DB=dbname - Runs MySQL database creation for Django tests * INSTALL_DOCKER_COMPOSE - Replaces docker_compose with the specific version. * INSTALL_ELASTICSEARCH=1 - Downloads and runs ElasticSearch, and ensures it is ready before starting tests * INSTALL_PIPELINE=1 - Installs node packages used by django-pipeline, so that "make build-static" will run successfully
Drop PYTHONPATH, CFLAGS, and DEBIAN_FRONTED from the environment overrides.
ae5f594
to
e6d8b66
Compare
Add a build (allowed to fail) that tests Kuma with a random PYTHONHASHSEED.
sudo ln -s /usr/lib/`uname -i`-linux-gnu/libfreetype.so /usr/lib | ||
sudo ln -s /usr/lib/`uname -i`-linux-gnu/libz.so /usr/lib | ||
mkdir -p downloads | ||
wget -q -O downloads/elasticsearch-$ES_VERSION.tar.gz $ES_DOWNLOAD_URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you build the url here?
Rather than passing the url in environment parameters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, you can't. ElasticSearch keeps changing their downloads domain. Here's a sample:
.travis.yml
Outdated
# Wait for ElasticSearch to be ready | ||
- if [ ${INSTALL_ELASTICSEARCH:-0} -ne 0 ]; then wget -q --waitretry=1 --retry-connrefused -T 10 -O - http://127.0.0.1:9200; fi; | ||
script: | ||
if [[ "${PYTHONHASHSEED:-}" == "0" ]]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
${PYTHONHASHSEED:-}
seems redundant, I think the simpler ${PYTHONHASHSEED}
would be equivalent.
https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` | ||
fi | ||
chmod +x $DOCKER_COMPOSE_FILE | ||
sudo cp $DOCKER_COMPOSE_FILE /usr/local/bin/docker-compose |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we cache this path and check if the version matches with the provided one?
INSTALLED_DOCER_COMPOSE_VERSION=$(docker-compose -v | grep -o '[0-9]\?[0-9].[0-9]\?[0-9].\?[0-9]')
if ! [ INSTALLED_DOCER_COMPOSE_VERSION == DOCKER_COMPOSE_VERSION];
then
# Download and install
fi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, that will never ever happen. The VM is reset each time, so the version will be 1.8.1 until TravisCI updates their VM image. When they do that, the new default may be later than 1.9.0, and we can stop installing our own docker-compose. Until then, the download
folder is cached, so we don't download the file unless we change DOCKER_COMPOSE_VERSION
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jwhitlock We can add /usr/local/bin/docker-compose
to cache
config to keep the docker-compose
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can cache directories but not files. I think it would be a mistake to cache /usr/local/bin
, so I think we're OK caching the file in downloads
and copying it each time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the docker-compose file is already in the downloads dir, which is in the cache due to https://github.com/mozilla/kuma/pull/4239/files#diff-354f30a63fb0907d4ad57269548329e3R9
Use simple bash tests in .travis.yml Use set -u in scripts/travis-install, instead of checking that the right environment variables are set.
install: | ||
- pip install -r requirements/travis.txt | ||
- if [[ $TOXENV == 'py27' ]]; then ansible-playbook -vvv --tags=mysql,pipeline --connection=local --inventory-file=provisioning/inventory provisioning/travis.yml; fi | ||
- nvm install 6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we include all the installs in scripts/travis-install
?
We dont need to install pip and other thing in docker testing environment. So it will faster the build
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be a good follow-on PR. requirements/travis.txt
includes coveralls
, which is called at the end of each test, so you'd need to ensure coveralls
is not called for the targets that generate coverage data. Which maybe should include the docker target, but currently doesn't. But it could be skipped for the linter tasks.
That's also a lot of work to save at most 10s per build.
PYTHONHASHSEED = 0 | ||
passenv=DJANGO_SETTINGS_MODULE DEBIAN_FRONTEND CFLAGS | ||
make compilejsi18n collectstatic clean | ||
py.test --no-migrations --cov=kuma kuma |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If new migration is added, will it fail?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not here, since we aren't running them due to --no-migrations
.
- TOXENV=docker DOCKER_COMPOSE_VERSION=1.9.0 UID=0 | ||
- TOXENV=locales | ||
INSTALL_DOCKER_COMPOSE=1 | ||
- TOXENV=docker |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keeping it in single line seems more readable to me TOXENV=docker INSTALL_DOCKER_COMPOSE=1 UID=0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer the new multi-line approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work @jwhitlock
Thanks for your thorough review and questions @safwanrahman. I think they've all been addressed and this is good to merge. |
Don't use Ansible to install MySQL and ElasticSearch. Instead:
utf8_distinct_ci
and migrations.make build-static
will work for tests.scripts/travis_install
to use env variables likeINSTALL_ELASTICSEARCH=1
, instead of targeting onTOXENV
, to make it easier to combine and customize.All of these changes makes the
py27
target faster to build (8 minutes vs 11 min 30 seconds, 30% faster), and easier to customize. I've added the first customization for bug 1352232, where tests fail if PYTHONHASHSEED is random, which affects our readiness for Python 3.@jgmize this might be an easy 馃憤, requesting your review if you can get to it by next Monday.