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

Move build system over to custom runner #1227

Merged
merged 46 commits into from
Apr 21, 2018
Merged

Conversation

DRMacIver
Copy link
Member

This is a start of trying to unify our build system a bit more so that it's less spread over Python/make/shell/etc. There's still a bit of shell (both for bootstrapping into Python and some of our test scripts remain).

The main goal in doing this is that it will make it easier to refactor our decisions about what should be running. Right now this is mostly feature parity with a few things that got fixed while I was in the area (e.g. we now check a few more RST files).

I'm not super happy with this code, but it's a decent starting point.

build.sh Outdated
#!/usr/bin/env bash

# This script is here to bootstrap the Hypothesis build process into a working
# version of Python, then hand over to the actual Hypothesi build runner (which
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Hypothesi

build.sh Outdated
# version of Python, then hand over to the actual Hypothesi build runner (which
# is written in Python instead of bash).

set -e -u -x
Copy link
Contributor

Choose a reason for hiding this comment

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

minor: I prefer the verbose forms (e.g. set -o errexit) for readability.

Copy link
Contributor

@alexwlchan alexwlchan left a comment

Choose a reason for hiding this comment

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

Oooooooh. I don’t have time to review this right now, hopefully soon!

@DRMacIver
Copy link
Member Author

It looks like the remaining problems are about how tox looks up interpreters. I'm not going to fix them tonight.

I'd been eyeing up killing tox as part of this and I think that may have tipped me over towards doing that.

Makefile Outdated
@@ -0,0 +1,6 @@
# You don't need to use this Makefile and should use build.sh instead. This is
# just here so that us poor souls who remember the Make based system and keep
# typing "make target" can ease our transition to the new sytsem.
Copy link
Member

Choose a reason for hiding this comment

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

sytsem -> system

(you poor soul 😉)

@@ -1,7 +1,7 @@
#!/bin/bash
set -e -o xtrace

cd "$(dirname "$0")"/../hypothesis-python
cd "$(dirname "$0")"/..
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this meant to be cd'ing to the directory this script lives in?

If so, would https://stackoverflow.com/a/246128/1558022 potentially be more robust? (e.g. if this script is called from something else, is $0 set correctly?)

Copy link
Member

Choose a reason for hiding this comment

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

@DRMacIver the 👍 makes me think you wanted to take this suggestion, but it looks like you didn't?

(I don't have any opinion and definitely haven't read that SO answer. Just checking in to see if there's something you wanted to do and didn't here.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Whoops! I did it in a bunch of places but not the one that @alexwlchan actually commented on. Thanks.

@@ -146,7 +146,7 @@ commands =
python -m coverage debug sys
python -m coverage run --rcfile=.coveragerc -m pytest -n0 --strict tests/cover tests/datetime tests/py3 tests/numpy tests/pandas --maxfail=1 --ff {posargs}
python -m coverage report -m --fail-under=100 --show-missing
python ../scripts/validate_branch_check.py
python ./scripts/validate_branch_check.py
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: why the leading ./ here and not on line 60?

# This is to guard against multiple builds in parallel. The various installers will tend
# to stomp all over each other if you do this and they haven't previously successfully
# succeeded. We use a lock file to block progress so only one install runs at a time.
# This script should be pretty fast once files are cached, so the lost of concurrency
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: "lost" ~> "loss

# is not a major problem.
# This should be using the lockfile command, but that's not available on the
# containerized travis and we can't install it without sudo.
# Is is unclear if this is actually useful. I was seeing behaviour that suggested
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: "It is unclear"

# containerized travis and we can't install it without sudo.
# Is is unclear if this is actually useful. I was seeing behaviour that suggested
# concurrent runs of the installer, but I can't seem to find any evidence of this lock
# ever not being acquired.
Copy link
Contributor

Choose a reason for hiding this comment

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

Surely a single Travis run only installs a single version of Python, in which case parallelism is never a problem. Is this only an issue for local builds?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think so. When I wrote it it sure looked like it helped on Travis, but I think that was an illusion. I no longer remember the details.

"""Given a task name, should we run this task?"""
if not is_pull_request:
if not IS_PULL_REQUEST:
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

much neater

Copy link
Contributor

@alexwlchan alexwlchan left a comment

Choose a reason for hiding this comment

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

Some comments based on another partial read, but I haven't got to main.py yet.

@DRMacIver
Copy link
Member Author

BTW the current status of this is that I'm struggling to reproduce the problem that is occurring reliably on CI where the install phase isn't actually working, and it's a rather slow loop to reproduce so I keep getting distracted by other work. Still ongoing work in progress though!

@DRMacIver
Copy link
Member Author

BTW the current status of this is that I'm struggling to reproduce the problem that is occurring reliably on CI

(╯°□°)╯︵ ┻━┻

Eventually I figured out by staring at CI logs for long enough.

The problem is that when running a script that exists solely to read stuff out of the environment, maybe I shouldn't be carefully starting it in a blank environment. Ugh.

tools.ROOT, '.flake8'
))
pip_tool(
'flake8',
Copy link
Member

Choose a reason for hiding this comment

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

Note: our current run requires flake8-docstrings to be installed too.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's fine. This runs in a virtualenv that installs everything from tools.txt

@Zac-HD
Copy link
Member

Zac-HD commented Apr 16, 2018

Looks like all you need to do is drop the old-python and old-pip tasks from Travis 😄

@DRMacIver
Copy link
Member Author

Have fixed all of the small nits, but I think this is all good for review now.

@alexwlchan
Copy link
Contributor

I have seen this, but I don’t have a lot of free time for OSS work right now, and I’m on holiday for a week from Sunday. I’d be surprised if I manage to review this properly within the next fortnight.

I won’t be upset if you want to merge this before I’ve reviewed it, and we patch it up after the fact.

@Zac-HD
Copy link
Member

Zac-HD commented Apr 19, 2018

I'm not quite so busy, but just don't have the depth of experience with bash to do a useful review.

@DRMacIver
Copy link
Member Author

I won’t be upset if you want to merge this before I’ve reviewed it, and we patch it up after the fact.

No worries. I'll definitely want to merge this in the next fortnight, but this is very much a stage one so it will probably see a lot of evolution from here, so you'll have plenty of later opportunity to comment. :-)

@froztbyte any chance you could take a look at this? It's rather in your area of expertise.

@DRMacIver
Copy link
Member Author

just don't have the depth of experience with bash to do a useful review.

FWIW very little of the bash is actually new. It's all just extracted from existing bash scripts that have been more or less working for about four years now. That doesn't mean it's correct, but it's probably not broken in new ways, and it doesn't need a super extensive review.

Copy link
Contributor

@alexwlchan alexwlchan left a comment

Choose a reason for hiding this comment

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

A few more small comments on the bash.

Given the inconsistent approaches to bash headers (#!/bin/bash and #!/usr/bin/env bash), and the varying uses of set -o or set -o errexit, maybe something that checks for common headers, similar to what we have for Python?

Just a thought.

build.sh Outdated
# version of Python, then hand over to the actual Hypothesis build runner (which
# is written in Python instead of bash).

set -x
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: prefer “set -o xtrace” for readability

(and ease of Googling!)


SCRIPTS="$ROOT/tooling/scripts"

# shellcheck source=tooling/scripts/common.sh
Copy link
Contributor

Choose a reason for hiding this comment

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

minor: why is this commented out?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's not a command, it's a shellcheck pragma to tell it where to look for the dynamic source.

ROOT="$(git -C "$HERE" rev-parse --show-toplevel)"

export ROOT
export BUILD_RUNTIMES=${BUILD_RUNTIMES-$HOME/.cache/hypothesis-build-runtimes}
Copy link
Contributor

Choose a reason for hiding this comment

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

I’m familiar with assigning variables of the form:

export VARNAME=${VARIABLE:-default}

but this doesn't have the colon. What am I missing?

Copy link
Member Author

Choose a reason for hiding this comment

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

Both are valid syntax! Though it turns out with very slightly different semantics - :- will use the new value if VARIABLE is set but null, while - will use null in that case. I'll switch it over.

Copy link
Contributor

Choose a reason for hiding this comment

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

Both “Why bash? 😭” and “Why? bash 😭” are valid responses I had! Though it turns out with very slightly different semantics.

😉

build.sh Outdated
if [ ! -e "$TOOL_PYTHON" ] ; then
rm -rf "$TOOL_VIRTUALENV"
"$PYTHON" -m pip install --upgrade virtualenv
"$PYTHON" -m virtualenv "$TOOL_VIRTUALENV"
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: is this extra indentation significant? It doesn't look to me like it is, but it makes the code slightly harder to follow.

Copy link
Member Author

Choose a reason for hiding this comment

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

Turns out to be mixed tabs and spaces from moving some stuff over from the makefile. Whoops!

@DRMacIver
Copy link
Member Author

DRMacIver commented Apr 21, 2018

BTW I propose that at some point we just YOLO merge this rather than doing a detailed review.

Reasons:

  • It's large and annoying. I know, sorry.
  • A detailed review will conclude that it's not very good, but we know that already
  • Most of the details will change in smaller chunks as we monorepo more stuff, and that can be subject to more detailed review
  • It doesn't actually affect users because it doesn't touch any shippable code, so any problems with it will fall on us to fix later rather than inflicting them on other people.

In addition because I would like this merged sooner rather than later because:

  • We keep making changes to the Makefile. e.g. Rename private modules with leading underscore #1248.
  • I'm now working on hypothesis for Ruby again (and finding things that are arbitrarily wrong in its build environment!) and I'd like to bring it into the fold sooner rather than later so I can start getting some of the core under test in Python land.

Copy link
Member

@Zac-HD Zac-HD left a comment

Choose a reason for hiding this comment

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

YOLO 🚀

I expect a follow-up issue to track the inevitable glitches, but let's get it in and iterate on a shared base.

@DRMacIver
Copy link
Member Author

I expect a follow-up issue to track the inevitable glitches, but let's get it in and iterate on a shared base.

Oh for sure. But I mean hey things are still broken from the last big change, so how much worse can it be? 😉

@Zac-HD
Copy link
Member

Zac-HD commented Apr 21, 2018

Things including certain build tasks are still broken, so... 😉

@DRMacIver
Copy link
Member Author

Things including certain build tasks are still broken, so... 😉

Specifically there are several task that are broken in master but work correctly in this branch and so are picking up failures that are also present in master. 😉

@Zac-HD
Copy link
Member

Zac-HD commented Apr 21, 2018

Merge when you think it's ready!

@alexwlchan
Copy link
Contributor

BTW I propose that at some point we just YOLO merge this rather than doing a detailed review.

What Could Possibly Go Wrong.

@DRMacIver
Copy link
Member Author

What Could Possibly Go Wrong.

Literally Everything.

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.

4 participants