-
Notifications
You must be signed in to change notification settings - Fork 587
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
Conversation
f412ad2
to
6e38365
Compare
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 |
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.
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 |
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.
minor: I prefer the verbose forms (e.g. set -o errexit
) for readability.
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.
Oooooooh. I don’t have time to review this right now, hopefully soon!
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. |
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.
sytsem -> system
(you poor soul 😉)
f0053ff
to
d4cfecb
Compare
@@ -1,7 +1,7 @@ | |||
#!/bin/bash | |||
set -e -o xtrace | |||
|
|||
cd "$(dirname "$0")"/../hypothesis-python | |||
cd "$(dirname "$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.
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?)
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.
@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.)
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.
Whoops! I did it in a bunch of places but not the one that @alexwlchan actually commented on. Thanks.
hypothesis-python/tox.ini
Outdated
@@ -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 |
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.
nit: why the leading ./
here and not on line 60?
tooling/scripts/ensure-python.sh
Outdated
# 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 |
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.
nit: "lost" ~> "loss
tooling/scripts/ensure-python.sh
Outdated
# 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 |
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.
nit: "It is unclear"
tooling/scripts/ensure-python.sh
Outdated
# 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. |
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.
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?
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 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: |
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.
👍
much neater
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.
Some comments based on another partial read, but I haven't got to main.py yet.
472a982
to
e1bf16f
Compare
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! |
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', |
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.
Note: our current run requires flake8-docstrings
to be installed too.
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.
That's fine. This runs in a virtualenv that installs everything from tools.txt
Looks like all you need to do is drop the old-python and old-pip tasks from Travis 😄 |
f98202b
to
1a7c223
Compare
Have fixed all of the small nits, but I think this is all good for review now. |
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. |
I'm not quite so busy, but just don't have the depth of experience with bash to do a useful review. |
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. |
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. |
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.
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 |
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.
nit: prefer “set -o xtrace” for readability
(and ease of Googling!)
|
||
SCRIPTS="$ROOT/tooling/scripts" | ||
|
||
# shellcheck source=tooling/scripts/common.sh |
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.
minor: why is this commented out?
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.
It's not a command, it's a shellcheck pragma to tell it where to look for the dynamic source.
tooling/scripts/common.sh
Outdated
ROOT="$(git -C "$HERE" rev-parse --show-toplevel)" | ||
|
||
export ROOT | ||
export BUILD_RUNTIMES=${BUILD_RUNTIMES-$HOME/.cache/hypothesis-build-runtimes} |
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’m familiar with assigning variables of the form:
export VARNAME=${VARIABLE:-default}
but this doesn't have the colon. What am I missing?
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.
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.
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.
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" |
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.
nit: is this extra indentation significant? It doesn't look to me like it is, but it makes the code slightly harder to follow.
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.
Turns out to be mixed tabs and spaces from moving some stuff over from the makefile. Whoops!
94f49f8
to
c09a835
Compare
BTW I propose that at some point we just YOLO merge this rather than doing a detailed review. Reasons:
In addition because I would like this merged sooner rather than later because:
|
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.
YOLO 🚀
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? 😉 |
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. 😉 |
Merge when you think it's ready! |
What Could Possibly Go Wrong. |
Literally Everything. |
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.