1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
|
# 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:
- pre-build
- build
- test
- code-linting
- documentation
- release
workflow:
auto_cancel:
on_new_commit: interruptible
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
auto_cancel:
on_new_commit: none
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
when: never
- when: always
###################### 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, default, optimized)
.base-build:
script:
- if (git remote | grep -qw upstream) ; then
git remote remove upstream ;
fi
- git remote add -t $CI_DEFAULT_BRANCH --no-tags -f upstream https://gitlab.com/nsnam/ns-3-dev.git
- git diff --name-only upstream/$CI_DEFAULT_BRANCH | tee $FILES_CHANGED
# Run this job in the following cases: 1) default branch, 2) changes to source code, 3) changes to configurations.
# Skip this job in the opposite cases.
# File paths generated by git diff are relative to the working tree.
- |
if [[ $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH ]] &&
!(grep -qE ".*\.(cc|h)|CMakeLists.txt|bindings/|build-support/|ns3|utils/tests/.*\.(yaml|yml)" $FILES_CHANGED) ; then
echo "No source code or configurations changes found in this MR. Skipping this job.";
exit 0;
fi
- mkdir -p $CCACHE_BASEDIR_VALUE
- export CCACHE_BASEDIR=${PWD}
- export CCACHE_DIR=${PWD}/$CCACHE_BASEDIR_VALUE
- export MPI_CI=1
- ccache -M 3G # Set maximum cache size to 3GB
- ccache -F 0 # Remove the limit on number of files in the cache
- CXX=$COMPILER ./ns3 configure -d $MODE -GNinja --enable-examples --enable-tests --enable-asserts --enable-werror --enable-mpi
$EXTRA_OPTIONS
- ccache -z
- if [[ "$CI_JOB_STAGE" == "build" ]];
then ./ns3 build;
fi
- if [[ "$CI_JOB_STAGE" == "build" ]] && [[ "`./utils/ccache-miss-rate.py`" != "0" ]];
then `touch build/tests-$CI_COMMIT_REF_SLUG.txt`;
fi
- if [[ "$CI_JOB_STAGE" == "test" ]] && [[ "$MODE" != "debug" ]] && [[ -f build/tests-$CI_COMMIT_REF_SLUG.txt ]];
then ./test.py -n --verbose-failed;
if [[ $? == 0 ]];
then `rm build/tests-$CI_COMMIT_REF_SLUG.txt` || true;
fi;
fi
- ccache -s
# - ./ns3 clean
cache:
# Use separate key for each (debug/default/optimized) jobs because
# they run in parallel and will otherwise overwrite each other
# cache when they upload the cache archive at the end of the job,
# resulting in only the cache for the last finished configuration
# being stored.
#
# Do not distinguish between branches though to avoid
# recompilation of all the files when a new branch is created.
key: "ccache-$CI_JOB_NAME"
paths:
- $CCACHE_BASEDIR_VALUE/
interruptible: true
timeout: 12h
variables:
CCACHE_BASEDIR_VALUE: ns-3-ccache-storage
FILES_CHANGED: git-diff-name-only.txt
artifacts:
expire_in: 2 day
paths:
- build/
- .lock-*
# Weekly jobs for other distribution and compilers
include:
- "utils/tests/gitlab-ci-per-commit.yml"
- "utils/tests/gitlab-ci-alpine.yml"
- "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-scheduled.yml"
- "utils/tests/gitlab-ci-code-linting.yml"
- "utils/tests/gitlab-ci-doc.yml"
- "utils/tests/gitlab-ci-cppyy.yml"
- "utils/tests/gitlab-ci-release.yml"
- "utils/tests/gitlab-ci-build.yml"
- "utils/tests/gitlab-ci-macos.yml"
|