From 441ae70c64979b9082a0df36b2f0becd5c93c0d3 Mon Sep 17 00:00:00 2001 From: Natale Patriciello Date: Wed, 20 Jun 2018 19:36:03 +0200 Subject: [PATCH] Example CI for ns-3 and Gitlab --- src/core/test/ptr-test-suite.cc | 11 +++ src/network/test/buffer-test.cc | 11 +++ utils/tests/README.md | 36 ++++++++++ utils/tests/gitlab-ci-clang.yml | 70 +++++++++++++++++++ utils/tests/gitlab-ci-doc.yml | 44 ++++++++++++ utils/tests/gitlab-ci-fedora.yml | 76 ++++++++++++++++++++ utils/tests/gitlab-ci-gcc.yml | 115 +++++++++++++++++++++++++++++++ utils/tests/gitlab-ci-test.yml | 59 ++++++++++++++++ utils/tests/gitlab-ci-ubuntu.yml | 86 +++++++++++++++++++++++ utils/tests/gitlab-ci.yml | 83 ++++++++++++++++++++++ 10 files changed, 591 insertions(+) create mode 100644 utils/tests/README.md create mode 100644 utils/tests/gitlab-ci-clang.yml create mode 100644 utils/tests/gitlab-ci-doc.yml create mode 100644 utils/tests/gitlab-ci-fedora.yml create mode 100644 utils/tests/gitlab-ci-gcc.yml create mode 100644 utils/tests/gitlab-ci-test.yml create mode 100644 utils/tests/gitlab-ci-ubuntu.yml create mode 100644 utils/tests/gitlab-ci.yml diff --git a/src/core/test/ptr-test-suite.cc b/src/core/test/ptr-test-suite.cc index c6ba24b04..9587b6a0e 100644 --- a/src/core/test/ptr-test-suite.cc +++ b/src/core/test/ptr-test-suite.cc @@ -182,7 +182,18 @@ PtrTestCase::DoRun (void) { Ptr p; p = Create (this); +#if defined(__clang__) + #if __has_warning("-Wself-assign-overloaded") + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wself-assign-overloaded" + #endif +#endif p = p; +#if defined(__clang__) + #if __has_warning("-Wself-assign-overloaded") + #pragma clang diagnostic pop + #endif +#endif } NS_TEST_EXPECT_MSG_EQ (m_nDestroyed, 1, "002"); diff --git a/src/network/test/buffer-test.cc b/src/network/test/buffer-test.cc index 8d38e9481..1755b77da 100644 --- a/src/network/test/buffer-test.cc +++ b/src/network/test/buffer-test.cc @@ -189,7 +189,18 @@ BufferTest::DoRun (void) // test self-assignment { Buffer a = o; +#if defined(__clang__) + #if __has_warning("-Wself-assign-overloaded") + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wself-assign-overloaded" + #endif +#endif a = a; +#if defined(__clang__) + #if __has_warning("-Wself-assign-overloaded") + #pragma clang diagnostic pop + #endif +#endif } // test Remove start. diff --git a/utils/tests/README.md b/utils/tests/README.md new file mode 100644 index 000000000..9cbf35618 --- /dev/null +++ b/utils/tests/README.md @@ -0,0 +1,36 @@ + +./utils/tests directory +======================= + +## Table of Contents: + +1) [What is](#what-is) +2) [Testing script](#testing-script) +3) [Gitlab CI infrastructure](#gitlab-ci-infrastructure) + +## What is + +In this directory, we store documents related to our testing infrastructure. + +## Testing script +To fill. + +## Gitlab CI infrastructure + +To know more about the Gitlab CI feature, please refer to https://about.gitlab.com/product/continuous-integration/. We use the services offered by Gitlab to test our software in multiple ways. If you are interested how to run these tests on your fork, please read below. + +### ns-3 CI configuration + +We store our YML files under the directory ./utils/tests. The main file is named `gitlab-ci.yml`, and from there we include multiple files to expand the number (and the quality) of tests we perform. We use inheritance of jobs to avoid to write many lines of code. + +### Per commit jobs description + +After each commit, the infrastructure will test the grammar correctness by doing a build, with tests and examples enabled, in three modes: debug, release, optimized. The build is done with the default GCC of the Arch Linux distribution: more deep check are done daily and weekly. You can see the job script in `gitlab-ci.yml`. If the build stage is passed, the commits done on the master branch will also trigger a documentation update. Currently, we do not use the generated documentation as Gitlab pages, but we use a separate service to display the documentation through the web. + +### Daily jobs description + +Thanks to the "Schedule" feature of Gitlab, we setup pipelines that have to be run once per day. The scheduled pipeline has to define a variable, named `RELEASE`, that should be set to `daily`. In the scripts then, we check for the value of that variable and run the jobs accordingly. As daily jobs, we perform a test run in all the modes (debug, release, optimized) under Arch Linux, and they are defined in the file `gitlab-ci-test.yml`. + +### Weekly jobs description + +As weekly jobs, we perform the build, testing, and documentation stage in every platform we support (Ubuntu, Fedora, Arch Linux) with all the compilers we support (GCC and CLang). To add the support for your platform, please see how the jobs are constructed (for instance, the GCC jobs are in `gitlab-ci-gcc.yml`). We currently miss the jobs for OS X and Windows. diff --git a/utils/tests/gitlab-ci-clang.yml b/utils/tests/gitlab-ci-clang.yml new file mode 100644 index 000000000..48e8cc9d5 --- /dev/null +++ b/utils/tests/gitlab-ci-clang.yml @@ -0,0 +1,70 @@ +# NS3 CI script for CLANG + +# Any scheduled pipeline for CLANG should define a variable, named +# "RELEASE", that has a value "weekly". Also, a variable "CLANG" should be set +# to True. + +# We support CLANG 6 and 7 (8 in the near future). +# The test is done under Linux. + +.weekly-build-clang: + image: ubuntu:18.04 + extends: .base-build + only: + variables: + - $RELEASE == "weekly" + - $CLANG == "True" + before_script: + - apt-get --quiet update --yes + - apt-get --quiet install gcc g++ python python-dev qt5-default openmpi-bin openmpi-common openmpi-doc libopenmpi-dev gsl-bin libgsl-dev ccache flex bison libfl-dev sqlite sqlite3 libsqlite3-dev libxml2 libxml2-dev libgtk2.0-0 libgtk2.0-dev libboost-all-dev libgsl23 --yes + - apt-get --quiet install software-properties-common gnupg wget --yes + - echo -en "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-$CLANG main \n deb-src http://apt.llvm.org/bionic/ llvm-toolchain-bionic-$CLANG main" > /etc/apt/sources.list.d/llvm.list + - wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - + - apt-get --quiet update --yes + - apt-get --quiet install ca-certificates build-essential clang-$CLANG clang-tools-$CLANG clang-format-$CLANG python-clang-$CLANG libfuzzer-$CLANG-dev lldb-$CLANG lld-$CLANG $EXTRA --yes + variables: + COMPILER: clang++-$CLANG + +# CLANG 6 +weekly-build-clang-6-debug: + extends: .weekly-build-clang + variables: + CLANG: "6.0" + MODE: debug + EXTRA: "" + +weekly-build-clang-6-release: + extends: .weekly-build-clang + variables: + CLANG: "6.0" + MODE: release + EXTRA: "" + +weekly-build-clang-6-optimized: + extends: .weekly-build-clang + variables: + CLANG: "6.0" + MODE: optimized + EXTRA: "" + +# CLANG 7 +weekly-build-clang-7-debug: + extends: .weekly-build-clang + variables: + CLANG: 7 + MODE: debug + EXTRA: libc++-$CLANG-dev libc++abi-$CLANG-dev libomp-$CLANG-dev + +weekly-build-clang-7-release: + extends: .weekly-build-clang + variables: + CLANG: 7 + MODE: release + EXTRA: libc++-$CLANG-dev libc++abi-$CLANG-dev libomp-$CLANG-dev + +weekly-build-clang-7-optimized: + extends: .weekly-build-clang + variables: + CLANG: 7 + MODE: optimized + EXTRA: libc++-$CLANG-dev libc++abi-$CLANG-dev libomp-$CLANG-dev diff --git a/utils/tests/gitlab-ci-doc.yml b/utils/tests/gitlab-ci-doc.yml new file mode 100644 index 000000000..3b355dbcf --- /dev/null +++ b/utils/tests/gitlab-ci-doc.yml @@ -0,0 +1,44 @@ +# NS3 CI script for the documentation +# For the moment we do not install the generated documentation +# +.doc: + stage: documentation + before_script: + - apt-get update + - DEBIAN_FRONTEND=noninteractive apt-get install -y tzdata + - apt-get install -y doxygen graphviz make imagemagick dia texlive texlive-font-utils python3-sphinx latexmk texlive texlive-science texlive-formats-extra texlive-base python3-jinja2 python3-pygments texlive-fonts-extra + - sed -i "s/EPS,PDF,//g" /etc/ImageMagick-6/policy.xml + - sed -i "s/none/read\ |\ write/g" /etc/ImageMagick-6/policy.xml + image: ubuntu + artifacts: + paths: + - public + only: + - master + +doxygen: + extends: .doc + script: +# - mkdir -p public/doxygen + - doxygen doc/doxygen.conf +# - mv doc/html/ public/doxygen + +manual: + extends: .doc + script: +# - mkdir -p public/manual + - cd doc/manual + - make html + - make latexpdf +# - mv build/html ../../public/manual +# - mv build/latex/ns-3-manual.pdf ../../public/ + +models: + extends: .doc + script: +# - mkdir -p public/models + - cd doc/models + - make html + - make latexpdf +# - mv build/html ../../public/models +# - mv build/latex/ns-3-model-library.pdf ../../public diff --git a/utils/tests/gitlab-ci-fedora.yml b/utils/tests/gitlab-ci-fedora.yml new file mode 100644 index 000000000..617988e05 --- /dev/null +++ b/utils/tests/gitlab-ci-fedora.yml @@ -0,0 +1,76 @@ +# NS3 CI script for fedora + +# Any scheduled pipeline for Fedora should define a variable, named +# "RELEASE", that has a value "weekly". Also, a variable "FEDORA" should be set +# to True. + +# Please take a look at .gitlab-ci.yml to check the dependencies of Fedora jobs. + +# Weekly jobs: Fedora +.weekly-build-fedora: + extends: .base-build + only: + variables: + - $RELEASE == "weekly" + - $FEDORA == "True" + before_script: + - dnf install gcc gcc-c++ python python-devel ccache gsl gsl-devel libgcrypt gtk3 gtk3-devel sqlite sqlite-devel libxml2 libxml2-devel openmpi openmpi-devel boost-devel pygobject3-devel python3-gobject gobject-introspection-devel goocanvas2-devel graphviz-devel graphviz ipython --assumeyes + variables: + COMPILER: g++ + +# Fedora 27 +weekly-build-fedora-27-debug: + extends: .weekly-build-fedora + image: fedora:27 + variables: + MODE: debug + +weekly-build-fedora-27-release: + extends: .weekly-build-fedora + image: fedora:27 + variables: + MODE: release + +weekly-build-fedora-27-optimized: + extends: .weekly-build-fedora + image: fedora:27 + variables: + MODE: optimized + +# Fedora 28 +weekly-build-fedora-28-debug: + extends: .weekly-build-fedora + image: fedora:28 + variables: + MODE: debug + +weekly-build-fedora-28-release: + extends: .weekly-build-fedora + image: fedora:28 + variables: + MODE: release + +weekly-build-fedora-28-optimized: + extends: .weekly-build-fedora + image: fedora:28 + variables: + MODE: optimized + +# Fedora 29 +weekly-build-fedora-29-debug: + extends: .weekly-build-fedora + image: fedora:29 + variables: + MODE: debug + +weekly-build-fedora-29-release: + extends: .weekly-build-fedora + image: fedora:29 + variables: + MODE: release + +weekly-build-fedora-29-optimized: + extends: .weekly-build-fedora + image: fedora:29 + variables: + MODE: optimized diff --git a/utils/tests/gitlab-ci-gcc.yml b/utils/tests/gitlab-ci-gcc.yml new file mode 100644 index 000000000..dae234437 --- /dev/null +++ b/utils/tests/gitlab-ci-gcc.yml @@ -0,0 +1,115 @@ +# NS3 CI script for GCC + +# Any scheduled pipeline for GCC should define a variable, named +# "RELEASE", that has a value "weekly". Also, a variable "GCC" should be set +# to True. + +# We support from 4.9.2 to the latest version. Check if everything builds fine +# under debug, release, and optimized, on Linux. + +.weekly-build-gcc: + extends: .base-build + only: + variables: + - $RELEASE == "weekly" + - $GCC == "True" + before_script: + - apt-get --quiet update --yes + - apt-get --quiet install gcc g++ python python-dev qt5-default openmpi-bin openmpi-common openmpi-doc libopenmpi-dev ccache flex bison libfl-dev sqlite sqlite3 libsqlite3-dev libxml2 libxml2-dev libgtk-3-dev libboost-all-dev gsl-bin libgsl0-dev --yes + variables: + COMPILER: g++ + +# GCC 4.9 : it could be unsupported ? +weekly-build-gcc-4.9-debug: + extends: .weekly-build-gcc + image: gcc:4.9 + variables: + MODE: debug + +weekly-build-gcc-4.9-release: + extends: .weekly-build-gcc + image: gcc:4.9 + variables: + MODE: release + +weekly-build-gcc-4.9-optimized: + extends: .weekly-build-gcc + image: gcc:4.9 + variables: + MODE: optimized + +# GCC 5 +weekly-build-gcc-5-debug: + extends: .weekly-build-gcc + image: gcc:5 + variables: + MODE: debug + +weekly-build-gcc-5-release: + extends: .weekly-build-gcc + image: gcc:5 + variables: + MODE: release + +weekly-build-gcc-5-optimized: + extends: .weekly-build-gcc + image: gcc:5 + variables: + MODE: optimized + +# GCC 6 +weekly-build-gcc-6-debug: + extends: .weekly-build-gcc + image: gcc:6 + variables: + MODE: debug + +weekly-build-gcc-6-release: + extends: .weekly-build-gcc + image: gcc:6 + variables: + MODE: release + +weekly-build-gcc-6-optimized: + extends: .weekly-build-gcc + image: gcc:6 + variables: + MODE: optimized + +# GCC 7 +weekly-build-gcc-7-debug: + extends: .weekly-build-gcc + image: gcc:7 + variables: + MODE: debug + +weekly-build-gcc-7-release: + extends: .weekly-build-gcc + image: gcc:7 + variables: + MODE: release + +weekly-build-gcc-7-optimized: + extends: .weekly-build-gcc + image: gcc:7 + variables: + MODE: optimized + +# GCC 8 +weekly-build-gcc-8-debug: + extends: .weekly-build-gcc + image: gcc:8 + variables: + MODE: debug + +weekly-build-gcc-8-release: + extends: .weekly-build-gcc + image: gcc:8 + variables: + MODE: release + +weekly-build-gcc-8-optimized: + extends: .weekly-build-gcc + image: gcc:8 + variables: + MODE: optimized diff --git a/utils/tests/gitlab-ci-test.yml b/utils/tests/gitlab-ci-test.yml new file mode 100644 index 000000000..70b21ab73 --- /dev/null +++ b/utils/tests/gitlab-ci-test.yml @@ -0,0 +1,59 @@ +# NS3 CI script for testing + +# Defines the steps to run the tests +# Inherit with "extends: .base-test" and remember to set +# the following variables: COMPILER (g++, clang++, ...) and +# MODE (debug, release, optimized) + +.base-test: + stage: test + script: + - mkdir -p $CCACHE_BASEDIR_VALUE + - export CCACHE_BASEDIR=${PWD} + - export CCACHE_DIR=${PWD}/$CCACHE_BASEDIR_VALUE + - CXX="ccache $COMPILER" ./waf configure --enable-examples --enable-tests -d $MODE + - ./test.py + cache: + paths: + - $CCACHE_BASEDIR_VALUE/ + variables: + CCACHE_BASEDIR_VALUE: ns-3-ccache-storage + +# Run the test.py script with files compiled in debug mode +daily-test-debug: + extends: .base-test + image: base/archlinux + variables: + COMPILER: g++ + MODE: debug + only: + variables: + - $RELEASE == "daily" + before_script: + - pacman -Sy base-devel python ccache gsl libgcrypt gtk3 boost --noconfirm + +# Run the test.py script with files compiled in release mode +daily-test-release: + extends: .base-test + image: base/archlinux + variables: + COMPILER: g++ + MODE: release + only: + variables: + - $RELEASE == "daily" + before_script: + - pacman -Sy base-devel python ccache gsl libgcrypt gtk3 boost --noconfirm + +# Run the test.py script with files compiled in optimized mode +daily-test-optimized: + extends: .base-test + image: base/archlinux + variables: + COMPILER: g++ + MODE: optimized + only: + variables: + - $RELEASE == "daily" + before_script: + - pacman -Sy base-devel python ccache gsl libgcrypt gtk3 boost --noconfirm diff --git a/utils/tests/gitlab-ci-ubuntu.yml b/utils/tests/gitlab-ci-ubuntu.yml new file mode 100644 index 000000000..d5303b89c --- /dev/null +++ b/utils/tests/gitlab-ci-ubuntu.yml @@ -0,0 +1,86 @@ +# NS3 CI script for ubuntu + +# Any scheduled pipeline for Ubuntu should define a variable, named +# "RELEASE", that has a value "weekly". Also, the variale "UBUNTU" should be +# set to True. + +# Please take a look at .gitlab-ci.yml to check the dependencies of Ubuntu jobs. + +# Ubuntu base +.weekly-build-ubuntu: + extends: .base-build + only: + variables: + - $RELEASE == "weekly" + - $UBUNTU == "True" + before_script: + - apt-get --quiet update --yes + - apt-get --quiet install gcc g++ python python-dev qt5-default openmpi-bin openmpi-common openmpi-doc libopenmpi-dev gsl-bin libgsl-dev ccache flex bison libfl-dev sqlite sqlite3 libsqlite3-dev libxml2 libxml2-dev libgtk-3-dev libboost-all-dev $LIBGSL --yes + variables: + COMPILER: g++ + +# Ubuntu 16.04 (Until April 2021) +weekly-build-ubuntu-16.04-debug: + extends: .weekly-build-ubuntu + image: ubuntu:16.04 + variables: + MODE: debug + LIBGSL: libgsl2 + +weekly-build-ubuntu-16.04-release: + extends: .weekly-build-ubuntu + image: ubuntu:16.04 + variables: + MODE: release + LIBGSL: libgsl2 + +weekly-build-ubuntu-16.04-optimized: + extends: .weekly-build-ubuntu + image: ubuntu:16.04 + variables: + MODE: optimized + LIBGSL: libgsl2 + +# Ubuntu 18.04 (Until April 2023) +weekly-build-ubuntu-18.04-debug: + extends: .weekly-build-ubuntu + image: ubuntu:18.04 + variables: + MODE: debug + LIBGSL: libgsl23 + +weekly-build-ubuntu-18.04-release: + extends: .weekly-build-ubuntu + image: ubuntu:18.04 + variables: + MODE: release + LIBGSL: libgsl23 + +weekly-build-ubuntu-18.04-optimized: + extends: .weekly-build-ubuntu + image: ubuntu:18.04 + variables: + MODE: optimized + LIBGSL: libgsl23 + +# Ubuntu 18.10 (Until July 2019) +weekly-build-ubuntu-18.10-debug: + extends: .weekly-build-ubuntu + image: ubuntu:18.10 + variables: + MODE: debug + LIBGSL: libgsl23 + +weekly-build-ubuntu-18.10-release: + extends: .weekly-build-ubuntu + image: ubuntu:18.10 + variables: + MODE: release + LIBGSL: libgsl23 + +weekly-build-ubuntu-18.10-optimized: + extends: .weekly-build-ubuntu + image: ubuntu:18.10 + variables: + MODE: optimized + LIBGSL: libgsl23 diff --git a/utils/tests/gitlab-ci.yml b/utils/tests/gitlab-ci.yml new file mode 100644 index 000000000..bf8be50bd --- /dev/null +++ b/utils/tests/gitlab-ci.yml @@ -0,0 +1,83 @@ +# NS3 CI script + +# For naming purposes, we will prepend ".base-" on the jobs +# that are not complete and need to be extended (hopefully +# we write in the documentation before the job what should be +# added to have a working jobs). + +# As per Gitlab documentation, extends supports multi-level inheritance, +# however it is not recommended to use more than three levels. + + +# Any scheduled pipeline should define a variable, named "RELEASE", that +# indicates what this script is run for. Allowed values, for the moment, +# are "daily" and "weekly" to denote a daily (or weekly) job. + +# Our configuration is not strictly sequential, or by using different +# words, we do not expect the CI infrastructure to run build, test, and +# documentation jobs each time that a commit is done. We use a different +# configuration, still in definition. It will be in the documentation. + + +stages: + - build + - test + - documentation + + +###################### BUILD STAGE ############################################# + +# Defines the steps to run the tests +# Inherit with "extends: .base-build" and remember to set +# the following variables: COMPILER (g++, clang++, ...) and +# MODE (debug, release, optimized) +.base-build: + stage: build + script: + - mkdir -p $CCACHE_BASEDIR_VALUE + - export CCACHE_BASEDIR=${PWD} + - export CCACHE_DIR=${PWD}/$CCACHE_BASEDIR_VALUE + - CXX="ccache $COMPILER" ./waf configure --enable-examples --enable-tests -d $MODE + - ./waf + cache: + paths: + - $CCACHE_BASEDIR_VALUE/ + variables: + CCACHE_BASEDIR_VALUE: ns-3-ccache-storage + +# Defines the per-commit jobs. They are executed for any branch +per-commit-compile-debug: + extends: .base-build + image: base/archlinux + variables: + COMPILER: g++ + MODE: debug + before_script: + - pacman -Sy base-devel python ccache gsl libgcrypt gtk3 boost --noconfirm + +per-commit-compile-release: + extends: .base-build + image: base/archlinux + variables: + COMPILER: g++ + MODE: release + before_script: + - pacman -Sy base-devel python ccache gsl libgcrypt gtk3 boost --noconfirm + +per-commit-compile-optimized: + extends: .base-build + image: base/archlinux + variables: + COMPILER: g++ + MODE: optimized + before_script: + - pacman -Sy base-devel python ccache gsl libgcrypt gtk3 boost --noconfirm + +# Weekly jobs for other distribution and compilers +include: + - 'utils/tests/gitlab-ci-ubuntu.yml' + - 'utils/tests/gitlab-ci-fedora.yml' + - 'utils/tests/gitlab-ci-gcc.yml' + - 'utils/tests/gitlab-ci-clang.yml' + - 'utils/tests/gitlab-ci-test.yml' + - 'utils/tests/gitlab-ci-doc.yml'