-
-
Notifications
You must be signed in to change notification settings - Fork 652
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor .travis.yml to deduplicate uses of Docker and use Mustache c…
…omments (#7351) ### Problem #7235 introduced an initial deduplication of launching docker images, notably allowing the image name to be parametrized. While working on #7197, it became evident how frequently the same code was being repeated for calling `docker run`. The only thing that changes between these invocations is what goes inside `sh -c "my bash command"`. This duplication makes our Travis code harder to understand, along with the usual arguments for DRY. ### Solution Introduce a new `docker_run_image` mustache template that takes the parameters `$docker_image_name` and `$docker_run_command`. Also changed: * rename `launch_docker_image` -> `docker_build_image` * remove script entry for `&travis_docker_image`, as it gets overridden every time by its caller so is unnecessary and confusing. * introduce Mustache comments to some of our templates. These don't get copied over into `.travis.yml`, which is good for reducing noise, while still allowing us to explain the concept in the template. ### Result CI should perform the same with the benefit of a shorter and better abstracted `travis.yml.mustache`.
- Loading branch information
1 parent
63d430e
commit c835267
Showing
7 changed files
with
76 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
- PATH="/usr/lib/jvm/java-8-openjdk-amd64/jre/bin":$PATH | ||
- JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 | ||
# Increase the max number of user watches to ensure that watchman is able to watch all | ||
# files in the working copy. | ||
{{! Increase the max number of user watches to ensure that watchman is able to watch all | ||
# files in the working copy. }} | ||
- sudo sysctl fs.inotify.max_user_watches=524288 | ||
- ./build-support/bin/install_aws_cli_for_ci.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{{! Note we mount ${HOME} to cache the ${HOME}/.cache/pants/rust-toolchain. }} | ||
docker run | ||
--rm -t | ||
-v "${HOME}:/travis/home" | ||
-v "${TRAVIS_BUILD_DIR}:/travis/workdir" | ||
{{! $docker_image_name is an environment variable with an expected value like `travis_ci`. | ||
It should be set in the env section.}} | ||
${docker_image_name}:latest | ||
{{! $docker_run_command is an environment variable with an expected string value like | ||
`"echo 'hello' && exit 1"`. It should be set in the env section.}} | ||
sh -c "${docker_run_command}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
{{! These flags are necessary to get OpenSSL working. | ||
See https://github.com/pyenv/pyenv/wiki/Common-build-problems#error-the-python-ssl-extension-was-not-compiled-missing-the-openssl-lib. }} | ||
PATH="/usr/local/opt/openssl/bin:$PATH" | ||
LDFLAGS="-L/usr/local/opt/openssl/lib" | ||
CPPFLAGS="-I/usr/local/opt/openssl/include" | ||
{{! OSX shards that use Pyenv do so by directly cloning the repository, as several OSX images | ||
have outdated versions of pyenv that don't include the Python versions we need. | ||
So, we set these environment variables here to get this solution working. }} | ||
PYENV_ROOT="${HOME}/.pyenv" | ||
PATH="${PYENV_ROOT}/shims:${PATH}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters