cms-gem-daq-project / gem-plotting-tools

Repository for GEM commissioning plotting tools
GNU General Public License v3.0
1 stars 26 forks source link

[RFC] Integrate gem-plotting-tools with Travis CI #27

Closed lmoureaux closed 7 years ago

lmoureaux commented 7 years ago

Travis CI is an online platform for continuous integration, free-to-use for open source projects. It is deeply integrated with Github and can block merge just like landscape can. This PR adds support for Travis CI for gem-plotting-tools.

Description

Travis is very generic and can be told to run arbitrary commands. The "build" fails if any of the commands fails, which is the ideal behavior for unit tests. Travis uses Ubuntu 14.04 as their default environment, and I don't change this.

This PR adds a .travis.yml file to enable Travis. This file and the scripts in .travis setup the following testing environment:

In addition, this PR adds a test of ana_scans.py --runType=scurve. The test will catch syntax errors and fatal exceptions in ana_scans.py and anaUltraScurve.py, as well as any file they import. The test will not catch other problems. Some changes to ana_scans.py were required in order to make it fail when the subcommands fail.

If this PR gets merged, an administrator can subscribe to Travis and enable it within minutes.

Types of changes

Motivation and Context

See #26 for context. Having Travis run every tool for every commit would catch code typos early.

How Has This Been Tested?

The changes were continuously tested on Travis itself (and only there). See here for an example of the test running without error, here for the output of Travis catching bug #24.

Screenshots

This is the current Travis result for my branch travis... Build Status

Checklist:

lmoureaux commented 7 years ago

This PR isn't ready yet, but I'd like to get comments on the architecture before more tests get added to it.

bdorney commented 7 years ago

Ubuntu's ROOT packages

Can you confirm this is:

ROOT 5.34/36 (heads/v5-34-00-patches@v5-34-34-76-g57bae4c, Apr 08 2016, 12:05:00 on linuxx8664gcc)

Python 2.6 and python 2.7 (tests will be run in both environments):

Can you confirm these are:

Python 2.6.6
Python 2.7.5

As these are the defaults on slc6 and cc7 operating systems.

cmsgemos from branch master

Please use generic-amc-release-v3 of cmsgemos instead, found here.

One question. How does Travis CI update? e.g. if there is an update to cmsgemos what does one do to ensure that this update is included?

Also I think we need to expand this unit testing:

In addition, this PR adds a test of ana_scans.py --runType=scurve. The test will catch syntax errors and fatal exceptions in ana_scans.py and anaUltraScurve.py, as well as any file they import. The test will not catch other problems. Some changes to ana_scans.py were required in order to make it fail when the subcommands fail.

Let's expand this to include:

Also can the input files that we use as the "test data" be stored in the same file structure that ana_scans.py expects. This could also help us test chamberInfo.py.

lmoureaux commented 7 years ago

Ubuntu's ROOT packages

Can you confirm this is:

ROOT 5.34/36 (heads/v5-34-00-patches@v5-34-34-76-g57bae4c, Apr 08 2016, 12:05:00 on linuxx8664gcc)
amd64 root-system-bin amd64 5.34.14-1build1

Same architecture, major and minor version. Patch number is different, though. I don't know of a simple way to install a specific ROOT version on Debian (and I don't want to compile it).

Can you confirm these are:

Python 2.6.6 Python 2.7.5

Python 2.6.13 and 2.7.13 (more recent patch versions, no behavior change expected). I can look into specifying patch numbers, but I'm not sure whether Travis still supports 2.6.6 (since even 2.6.13 is deprecated as it's not supported by the Python team anymore).

cmsgemos from branch master

Please use generic-amc-release-v3 of cmsgemos instead, found here.

Checked, it uses the default branch, which is generic-amc-release-v3 for now. Should I specify the branch explicitly?

One question. How does Travis CI update? e.g. if there is an update to cmsgemos what does one do to ensure that this update is included?

The latest cmsgemos if fetched from git every time the test is run.

bdorney commented 7 years ago

Same architecture, major and minor version. Patch number is different, though. I don't know of a simple way to install a specific ROOT version on Debian (and I don't want to compile it).

Compiled sources are available, for example for v5.34.36: https://root.cern.ch/content/release-53436

Checked, it uses the default branch, which is generic-amc-release-v3 for now. Should I specify the branch explicitly?

No let's rely on the correct setup of the cmsgemos repo to point git to this branch as default. This can only be changed by an admin of the cmsgemos repo which I think includes only @jsturdy presently.

The latest cmsgemos if fetched from git every time the test is run.

Yeah I saw after looking at the code.

jsturdy commented 7 years ago

Sorry to not jump on this earlier, but it would be better if you can set it up to work with the docker container I set up for cmsgemos CI (work in progress, and once it's sorted, the plan was to simply plug in the other packages)

Other things to probably keep in mind moving forward:

lmoureaux commented 7 years ago

In today's update:

I considered using @jsturdy's Docker image, but I couldn't even run ls from inside the container. As I don't have the expertise to fix it (both on Docker and on how to setup cmsgemos), I went ahead with Ubuntu as the second-best solution. The tests themselves will be easily reusable on Docker anyway.

I considered using tox, but it looked like overkill (and overlapping with Travis). I considered using Python's own unittest module but IMHO it's a lot of code for little added value.

Still not addressed:

jsturdy commented 7 years ago

I tracked down a couple of issues with the docker container that was being used, and have managed to get things looking pretty much as expected from within the travis environment. If you can let me know what you would need to add to the container to complete your tests (unless you just want to run the installation commands in your travis script), I can update the container.

One other thing that would be optimal would be to separate the unit testing from the CI/CD setup, such that the unit tests can be run independently of the CI/CD, and will then easily plug into a functional CI/CD framework (there will be two, by virtue of the fact that the gitlab mirrors are using gitlab-ci, while the github repositories will use travis)

While moving along these lines, the best way forward will be for you to regularly do a git rebase to the mainline branch, which should be straightforward as long as you're not modifying any of the code unrelated to the travis aspects (which this PR shouldn't be doing anyway...)

jsturdy commented 7 years ago

closing as "On Hold"