[libvirt] [PATCH V2] CI: also run tests using updated distro(s)

Claudio André claudioandre.br at gmail.com
Wed May 31 16:16:35 UTC 2017


Em 31/05/2017 12:38, Daniel P. Berrange escreveu:
> On Wed, May 31, 2017 at 12:21:05PM -0300, claudioandre.br at gmail.com wrote:
>> From: Claudio André <claudioandre.br at gmail.com>
>>
>> It is possible to test libvirt using other distros in Travis via Docker;
>> including (but not limited to) Fedora and Ubuntu.
>> ---
>> See it in action at https://travis-ci.org/claudioandre/libvirt/builds/237687907
>>
>>   .travis.yml        | 23 ++++++++++--------
>>   tests/travis-ci.sh | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>   2 files changed, 83 insertions(+), 10 deletions(-)
>>   create mode 100755 tests/travis-ci.sh
>>
>> diff --git a/.travis.yml b/.travis.yml
>> index 5a3e765..3ed2093 100644
>> --- a/.travis.yml
>> +++ b/.travis.yml
>> @@ -1,8 +1,6 @@
>>   sudo: false
>>   language: c
>>   dist: precise
>> -compiler:
>> -  - gcc
>>   cache: ccache
>>   addons:
>>     apt:
>> @@ -62,15 +60,14 @@ git:
>>   before_install:
>>     - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew update && brew install gnutls libgcrypt yajl gettext rpcgen ; fi
>>   
>> -# the custom PATH is just to pick up OS-X homebrew & its harmless on Linux
>> -before_script:
>> -  - PATH="/usr/local/opt/gettext/bin:/usr/local/opt/rpcgen/bin:$PATH" ./autogen.sh
>>   script:
>> -  - VIR_TEST_DEBUG=1 make -j3 && make -j3 syntax-check && make -j3 check
>> +  - tests/travis-ci.sh
>>   
>>   # Environments here are run in addition to the main environment defined above
>>   matrix:
>>     include:
>> +    - compiler: gcc
>> +      dist: precise
>>       - compiler: clang
>>         dist: precise
>>       - compiler: clang
>> @@ -79,10 +76,16 @@ matrix:
>>         dist: trusty
>>       - compiler: clang
>>         os: osx
>> -      script:
>> -        # many unit tests fail & so does syntax-check, so skip for now
>> -        # one day we must fix it though....
>> -        - make -j3
>> +    - services: docker
>> +      env: IMAGE=ubuntu:17.04 CCO=gcc
>> +      dist: trusty
> Why is this labelled 'trusty' if we're running 17.04 which is not 'trusty'

Two different things. Trusty is the Travis worker (the "base OS") and 
17.04 is the docker image.

> Also just call the env var 'CC' rather than 'CCO' as that is
> the more normal convention.

Ok, I did this to avoid to use the CC that already exists in the worker 
(base OS). Will change and test.

>> +  allow_failures:
>> +    - env: IMAGE=ubuntu:17.04 CCO=gcc
>> +    - env: IMAGE=ubuntu:17.04 CCO=clang
> Can you just fix the tests instead please.

They are fixed/passing. I will remove the allow failures.

>
>>   after_failure:
>>     - echo '============================================================================'
>> diff --git a/tests/travis-ci.sh b/tests/travis-ci.sh
>> new file mode 100755
>> index 0000000..07ec85d
>> --- /dev/null
>> +++ b/tests/travis-ci.sh
>> @@ -0,0 +1,70 @@
>> +#!/bin/bash -e
>> +
>> +function do_Install_Dependencies(){
>> +    echo
>> +    echo '-- Installing Dependencies --'
>> +
>> +    apt-get update -qq
>> +    apt-get -y -qq install \
>> +            build-essential git clang autoconf libtool libcmpicppimpl0 gettext \
>> +            xsltproc autopoint libxml2-dev libncurses5-dev libreadline-dev \
>> +            zlib1g-dev libgnutls28-dev libgcrypt11-dev libavahi-client-dev libsasl2-dev \
>> +            libxen-dev lvm2 libgcrypt11-dev libparted0-dev libdevmapper-dev uuid-dev \
>> +            libudev-dev libpciaccess-dev libcap-ng-dev libnl-3-dev libnl-route-3-dev \
>> +            libyajl-dev libpcap0.8-dev libnuma-dev libnetcf-dev libaudit-dev \
>> +            libxml2-utils libapparmor-dev dnsmasq-base librbd-dev w3c-markup-validator kmod > /dev/null
>> +}
> This isn't portable so we should at least check that we have the apt-get
> binary, and print out a message about porting it to other distros...

Not sure I get the point.
- Ok, it is not portable between Ubuntu versions (e.g., libgnutls-dev x 
libgnutls28-dev)
- I can do something like this:
if [ ubuntu 17.04 ]
   ok
else
   echo "please provide the installation of the needed dependencies"
   exit 1
fi

>> +
>> +function do_Show_Info(){
>> +    echo
>> +    echo '-- Environment --'
>> +    echo "Running on Docker: $DISTRO"
>> +    id
>> +    uname -a
>> +}
>> +
>> +
>> +function do_Show_Compiler(){
>> +
>> +    if [[ -n $CC ]]; then
>> +        echo
>> +        echo '-- Compiler in use --'
>> +        "$CC" --version
>> +    fi
>> +}
> I don't think we need separate functions for these two - just put
> it all in one place.
>
> In fact I think it is best to just run 'printenv' instead of
> special casing the 'CC' env variable.

Ok, I can add the printenv, but notice I need to print the version of 
the compiler used. So, I'll keep the 'CC' env stuff.

Ok, I can merge the two functions. But, please, notice that I have 2 
because I was thinking about debugging:
- as soon as possible, show info about the docker running environment. 
Docker run is ok?;
- install dependencies. Installation was ok?;
- then, show info about the compiler version (e.g., to help you in case 
of compiler warnings).

> +
>> +
>> +# ----------- Build and Test libvirt -----------
>> +
>> +if [[ -n $IMAGE ]]; then
>> +    # Run docker using the selected image; then build and test
>> +    docker run --privileged --cap-add=ALL -v /lib/modules:/lib/modules \
>> +      -v "$(pwd)":/cwd -e CC=$CCO -e DISTRO=$IMAGE "$IMAGE" sh -e -c " \
>> +        cd /cwd; \
>> +        tests/travis-ci.sh"
>> +    exit $?
>> +fi
>> +
>> +if [[ -n $DISTRO ]]; then
>> +    do_Show_Info
>> +    do_Install_Dependencies
>> +    do_Show_Compiler
>> +fi
>> +
>> +echo -en 'travis_fold:start:autogen\r'
>> +    echo '-- Running ./autogen.sh --'
>> +    # The custom PATH is just to pick up OS-X homebrew & its harmless on Linux
>> +    PATH="/usr/local/opt/gettext/bin:/usr/local/opt/rpcgen/bin:$PATH" ./autogen.sh
>> +echo -en 'travis_fold:end:autogen\r'
> Per the comment, this is only needed for OS-X, so should be put inside the
> the conditional for OS-X below

Ok.


Claudio




More information about the libvir-list mailing list