-
Notifications
You must be signed in to change notification settings - Fork 94
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
Use Travis-CI stages in build, and add a stage before tests for short-lived tasks #2860
Conversation
c880927
to
66a8147
Compare
Oh, and happy to fix conflicts here if the coverage pull request is merged first. Ditto if this one is merged first, no problems with fixing conflicts in the other 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.
Minor comments, but otherwise OK to go in.
Most of that is probably installation! A couple of thoughts: I would have thought that we might as well run the unittests as a parallel job along with the functional tests to avoid making the functional tests wait 1:15 before they start running? Or is the idea to avoid unnecessary runs of the functional tests? We should probably run the unittests using the minimum and maximum supported Python versions (presently 2.6 & 2.7, near future 3.? & 3.7). Luckily TravisCI makes this really easy. |
Most likely! pytest is taking ~0.4 seconds to run the unit tests on master in my computer. That number, however, will increase a bit as we add more tests.
Good point. The idea is indeed to avoid the runs of functional tests, but in theory starting unit tests alongside the functional tests could speed it up even more. Only issue that I have with that, is that if you look at Travis-CI after you push changes, it starts the 4 jobs in our build matrix right now, one for each CHUNK env var. But sometimes one or two jobs take a long time to start. I assume that's Travis-CI's internal scheduler/workload system that is waiting for a container or VM to start up, or to become free, until the job is assigned and started up. I've seen jobs taking more than 7 minutes to start, while other jobs for other CHUNK values were already running. It might increase a bit our build time, but I hope to be able to work on improvements for the functional tests later too 😬
Agreed. I am waiting until the test coverage pull request, and the - currently a WIP - setup.py pull requests to be reviewed / merged, and then the Python 3 branch work starts, so that we can start using tox. With tox and tox-travis, we can easily run it in Travis-CI against different versions of Python. Main advantage of tox is that it handles creating isolated virtualenv per run, and also tests the installation of the module through setup.py. That way it reduces the chances of having surprises when uploading the package to PYPI or Conda 👍 |
66a8147
to
8d03a9c
Compare
Fixed issues pointed by @matthewrmshin (thanks!). Rebased, now Travis-CI is happily building it again 👍 |
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.
+1 for moving the testing script out of the .travis.yml
, I'm trying to do the same for Rose!
Alongside the pycodestyle
test (tests/syntax
) there is also a pep8
test which should be removed as well (pep8
was renamed pycodestyle
so we have different tests to allow running on legacy systems [like ours]).
I think there should still be an easy way to run these code checkers locally, especially to help new contributors who won't be aware that to test their change they must run cylc test-battery
and pytest
and pycodestyle
(where before they just ran cylc test-battery
).
Is it possible to slot syntax checks into the pytest
battery? Or perhaps we could leave all of these tests in the Cylc test battery but make them skip when run on Travis-CI (using a SKIP_UNIT_TESTS
environment variable or something of that sort).
5d6102d
to
4f4d13a
Compare
Triggered build twice after @oliver-sanders comments, first time the unit tests were executed in 1 minute and 6 seconds, second time in 1 minute and 2 seconds. So down 10-20 seconds 🎉 Also update Travis-CI to build against the latest Ubuntu distro in Travis, xenial. We were building against trusty, which I think is the old LTS. The current LTS, bionic, is not available in Travis-CI yet. |
@oliver-sanders just removed the Then later I read a blog post and the author mentioned |
I normally have my monitor turned 90°. Perfect for code development (and for reading web sites that insist on displaying everything in a vertical block). Wide screen is for watching films. |
Agreed but it is also the assumed aspect. The ideal?
|
Well, never tried using my monitor like that. Might give it a try then :-) |
I just tried running the $ cd "${CYLC_HOME}"
$ PYTHONPATH="$(pwd -P)/lib/" pytest lib/cylc/
going into /net/home/h06/osanders/cylc/lib/cherrypy/test
======================== test_auth_basic.py ========================
... and so on for all the cherrypy test modules
going into /net/home/h06/osanders/cylc/lib/cylc/tests
================== test_conditional_simplifier.py ==================
======================= test_graph_parser.py =======================
========================== test_rundb.py =========================== I'm bamboozled. |
Oh, yup. I think the test coverage pull request includes a For now you would have to trigger And if that fails to import cylc, then try Travis I think isn't setting pythonpath. But IIRC Cylc had a script (cylc.init?) That modifies sys.path... I'm planning to look into that after the Sorry the mess! |
So
|
So, finally |
@matthewrmshin spotted that (cd "${CYLC_DIR}/lib/cylc"; pytest -c) # -c suppresses output unless errors occur To allow us to run unittests outside of Travis we could add something like this to the diff --git a/bin/cylc-test-battery b/bin/cylc-test-battery
index c34dde88e..388363588 100755
--- a/bin/cylc-test-battery
+++ b/bin/cylc-test-battery
@@ -149,6 +149,29 @@ if [[ -w "$CYLC_DIR/lib" ]]; then
python -mcompileall -q "$CYLC_DIR/lib"
fi
+LINTERS=(pycodestyle pep8)
+
+# Run python tests.
+if [[ ! -n "${@:-}" ]]; then
+ # Code style.
+ for linter in "${LINTERS[@]}"; do
+ if which "${linter}" >/dev/null 2>&1; then
+ "${linter}" --ignore=E402,W503,W504 \
+ lib/cylc \
+ lib/Jinja2Filters/*.py \
+ lib/parsec/*.py \
+ $(grep -l '#!.*\<python\>' bin/* | grep -v 'cylc-test-battery')
+ break # run the first linter present on the system
+ fi
+ done
+
+ # Unittests (including doctests).
+ (cd "${CYLC_DIR}/lib/cylc"; pytest -c)
+fi
+
+# Run functional tests.
if perl -e 'use Test::Harness 3.00' 2>/dev/null; then
NPROC=$(cylc get-global-config '--item=process pool size')
if [[ -z "${NPROC}" ]]; then Unfortunately the unittests are not Python 2 friendly, on 2.6 I'm getting the following errors:
Suppressing these issues is awkward since:
|
@oliver-sanders once we have the |
On
With the |
(I wouldn't want to use it in an automated hook either. However, the option to change my files in a working tree - so I can inspect the diff before committing (or reset) is a good one.) |
Push back to soon - given the dependency of this PR on #2834 - or we may want to have Either way, we should ensure that our local site tests do not become many commands? |
@matthewrmshin I think it's easier to keep both separated for now, so that feedback on each can be addressed separately (or the work can be postponed/included in a release more easily). If we merge the Otherwise, if this one is merged first, I would be happy to fix the other branch as well :) |
Sure thing @matthewrmshin . As this one is smaller, we will have less risks working on this one for perhaps 7.8.1 or later 👍 Will rebase, and review last comments to see what's missing here. |
39d5fd9
to
8968647
Compare
85c9b7c
to
cce9d34
Compare
Done @matthewrmshin
Ready for review again I believe. Cheers |
@oliver-sanders Has @kinow addressed your concerns? |
Almost, a couple of outstanding issues:
Perhaps we should accept this now and work at unifying the test approaches in a future PR. A further issue not entirely related to this change is that Otherwise this is all working fine and I'm happy to approve this. |
+1
+1 And I believe you are right @oliver-sanders about the new linters. Not too sure where they will be called. I have IDE integration, and also try to remember to run them before committing (though many times I run them after I see Travis-CI failing... 😥 ) If that's OK, I think we can address the pending issues in further pull requests. |
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.
2nd approval, on the basis that @oliver-sanders and @kinow agreed on further tweaks in follow-up PRs, (and I think @oliver-sanders is away for a few days?).
In our build process in Travis-CI, we have 4 chunks, each being executed in parallel and running the
cylc test-battery
command.Within those 4 chunks, any of them can pick up the test that executes
pycodestyle
. This test is triggered viacylc test-battery
.But in case
pycodestyle
failed to validate our syntax, it could take minutes (even more than 10 minutes) after the build started until the build was marked as failure.So what we have in this pull request is a simple change to use stages in Travis-CI. One stage called
Unit-test
, which will runpycodestyle
andpytest
, and another stage that keeps the old behaviour, running the test battery.As in the screen shot, it is possible to see that
pycodestyle
andpytest
currently take together 1 minute and 15 seconds to run. And the other steps won't start until this first stage is done.This means that before you are able to get a cup of coffee, Travis-CI will have failed if you added a bug found in one of the unit tests, or if you forgot the 80 characters limit in your Python source code (which I did a few times and had to edit my commits 😠 hence this pull request).
Cheers
(moved some parts of the build to external scripts, so that they could be re-used between stages)