Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ci.py helper script to allow parametrizing the pants_version #33

Merged
merged 23 commits into from
Mar 13, 2019

Conversation

Eric-Arellano
Copy link
Contributor

@Eric-Arellano Eric-Arellano commented Mar 12, 2019

Problem

The ./pants script claims to support running with both a pinned pants_version in the pants.ini and with the pants_version unspecified.

We currently do not test this unspecified branch, which we should be doing to guarantee that functionality always works.

Further, this is pre-work for #32, which will add --python-version as another parameter for ci.py to allow an unspecified Python version vs. pants.ini specifying 2.7 or 3.6 (FYI resulting .travis.yml).

Solution

Introduce a new ci.py helper script that uses argparse to have the parameter --pants-version {unspecified,config}.

Requires adding Python 3 to CI shards

Because this script uses modern Python 3—i.e. enums, f-strings, type hints, keyword-only args, and subprocess.run()—it requires Python 3.5+ to run.

Even though we can't yet run ./pants with Python 3 until #32 lands, this PR does some of the pre-work in adding Python 3 to each of the shards so that we can run this script. This is valid to do because every single shard is going to run the tests with both Py27 and Py36—unlike Pants where we have dedicated shards for each interpreter—so there is only benefit in ensuring each shard has Py27 and Py36.

Also updates test's pinned pants_version

--pants-version unspecified would fail because of a bad config, that the contrib module would refer to pants_version even though that line was deleted.
Also modernize .travis.yml to use all the cool goodies we've learned in Pants's CI like anchors and the brew addon package!
Turns out Precise comes installed with 3.6 when requested! So we only need Pyenv for OSX, not Linux.
See if moving back to osx_setup and linux_setup works.
Path wrangling didn't work.
Think this is the style used in most Python projects and ours.
@Eric-Arellano Eric-Arellano changed the title WIP: Add ci.py helper script to allow parametrizing the pants_version Add ci.py helper script to allow parametrizing the pants_version Mar 12, 2019
Copy link
Sponsor Member

@stuhood stuhood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks!

ci.py Outdated Show resolved Hide resolved
Will lead to less of a diff on Friday when we go to 1.15.0.dev4. Plus now the pants daemon tests work on macOS for me!
It's unified in Pants repo, so no good reason to split here.
@Eric-Arellano Eric-Arellano merged commit 7688a33 into pantsbuild:gh-pages Mar 13, 2019
@Eric-Arellano Eric-Arellano deleted the ci-py branch March 13, 2019 00:34
Eric-Arellano added a commit that referenced this pull request Mar 14, 2019
…se Py36 in Linux (#34)

#33 does not propagate return codes for subprocesses, meaning if the `./pants foo` commands fail, the error will print out to the screen but Travis will show everything as working. Fix this by adding `.check_returncode()`.

Also we found Linux Trusty and Xenial were using Python 3.5 to execute `ci.py`, as they err when introducing `f-strings`, which are 3.6+. So, use `pyenv global` to consistently use the correct interpreters.
Eric-Arellano added a commit that referenced this pull request Mar 14, 2019
### Problem
While it's good #33 stepped up our CI game by introducing a new script and allowing us to now test an unspecified `pants_version`, we were reinventing the wheel with parsing and modifying `pants.ini`, which led to confusing code.

### Solution
Use Python's `ConfigParser` to greatly simplify and make more extendable `ci.py`.
@Eric-Arellano Eric-Arellano mentioned this pull request Mar 16, 2019
Eric-Arellano added a commit that referenced this pull request Apr 1, 2019
### Problem
#33  resulted in us installing Python 3.6 on every shard but Trusty and Xenial, and #37 in us installing Python 3.7 on every OSX shard.

This slows down our CI unnecessarily and wastes time.

### Solution
Cache the pyenv folder for every shard, even if it does not use our custom Pyenv. This is safe to do because if the folder does not exist, Travis will simply upload an empty folder to the cache.

This requires adding a unique `CACHE_NAME` to every shard.

Further, we must refactor `.travis.yml` to globally define the env vars needed for our custom Pyenv install and to globally define `pyenv_install_py3{6,7}` for better readability.

## Result
Overall CI time reduced by 20.4 minutes and overall wall time by 6.1 minutes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants