Something went wrong. Try again.
forked from cz-nic/bird
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690################################################################ ########## DO NOT EDIT THIS FILE BY HAND ########## ##################################################################### ########## This file is autogenerated from gitlab/. ########## Edit those files and run `make gitlab` instead. ########## ################################################################
spec: inputs: netlab: description: "Manually run netlab tests" type: boolean default: false build: description: "Manually run build tests" type: boolean default: false packages: description: "Manually run packaging (will run also build tests anyway)" type: boolean default: false release-fixup: description: "Suffix for package build (if other than 1, this is a rebuild of a release)" type: number default: 1 release-desc: description: "Package build description (change this for release rebuild)" type: string default: "upstream package" docker-all: description: "Rebuild all dockers" type: boolean default: false docker-regex: description: "Rebuild dockers matching this regex" type: string default: 'NOTHING' # this is another hack because of gitlab syntax quirks docker-one: description: "Rebuild this one docker (keep empty for none)" type: string default: '' options: - ''{%- for docker in [ { "name": "docbuilder" } ] + distros %} - {{ docker["name"] }}{%- endfor %}
---
variables: DEBIAN_FRONTEND: noninteractive LC_ALL: C.UTF-8 GIT_STRATEGY: fetch DOCKER_CMD: docker --config="$HOME/.docker/$CI_JOB_ID/" IMG_BASE: registry.nic.cz/labs/bird TOOLS_DIR: /home/gitlab-runner/bird-tools STAYRTR_BINARY: /usr/local/bin/stayrtr GITLAB_API_URL: ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/
stages: - consistency - image - build - pkg - install - test
## Common rule snippets{%- set is_push = '($CI_PIPELINE_SOURCE == "push")' %}{%- set is_mreq = '($CI_PIPELINE_SOURCE == "merge_request_event")' %}{%- set is_manual = '($CI_PIPELINE_SOURCE == "web")' %}{%- set is_api = '($CI_PIPELINE_SOURCE == "api")' %}{%- set is_sched = '($CI_PIPELINE_SOURCE == "schedule")' %}{%- set is_stable = '($CI_COMMIT_BRANCH =~ /' ~ stable_branch_regex ~ '/)' %}{%- set not_stable = '($CI_COMMIT_BRANCH !~ /' ~ stable_branch_regex ~ '/)' %}
{%- set is_release_commit = '($CI_COMMIT_MESSAGE =~ /^NEWS and version update/)' %}{%- set is_wip = '($CI_COMMIT_MESSAGE =~ /^(fixup! )*WIP/)' %}{%- set is_tag = '$CI_COMMIT_TAG' %}
{%- set inputs_packages = '"$[[ inputs.packages ]]" == "true"' %}{%- set inputs_build = '"$[[ inputs.build ]]" == "true"' %}{%- set inputs_netlab = '"$[[ inputs.netlab ]]" == "true"' %}{%- set inputs_docker_all = '"$[[ inputs.docker-all ]]" == "true"' %}
workflow: rules: - if: '{{ is_manual }}' variables: wf_kind: manual wf_prefix: '[MAN] ' wf_desc: '$CI_COMMIT_TITLE' PKG_RELINFO: '$[[ inputs.release-desc ]]' PKG_FIXUP: '$[[ inputs.release-fixup ]]' - if: '{{ is_sched }}' variables: wf_kind: scheduled wf_prefix: '[SCD] ' wf_desc: '$CI_COMMIT_TITLE' - if: '{{ is_tag }}' variables: wf_kind: tag wf_prefix: '[TAG] ' wf_desc: '$CI_COMMIT_TAG' - if: '{{ is_push }}' variables: wf_kind: regular wf_prefix: '' wf_desc: '$CI_COMMIT_TITLE' - if: '{{ is_stable }} && {{ is_release_commit }}' variables: wf_kind: release wf_prefix: '[RELEASE] ' wf_desc: '$CI_COMMIT_BRANCH' - if: '{{ is_release_commit }}' variables: wf_kind: release-candidate wf_prefix: '[RC] ' wf_desc: '$CI_COMMIT_BRANCH' - when: always variables: wf_kind: unknown wf_prefix: '[$CI_PIPELINE_SOURCE] ' wf_desc: '$CI_COMMIT_TITLE'
name: '$wf_prefix$wf_desc'
# Note: We would love to just write "if: $[[ inputs.packages ]]"# but that's impossible because the value is expected to be a string.## Should be fixable by several lines in# lib/gitlab/ci/pipeline/expression/statement.rb# but I don't have time to do that contribution to gitlab now.
{%- macro rule(when, yesno) -%} - if: '{{ when }}' when: {% if yesno %}on_success{% else %}never{% endif %}{%- endmacro -%}
{%- macro rdef(yesno) -%} - when: {% if yesno %}on_success{% else %}never{% endif %}{%- endmacro -%}
## Default rules for regular jobs.default-rules:# Manual, API and Scheduled jobs have an explicit input setting.# Do not run anything unless explicitly requested for these. {{ rule(is_manual, False) }} {{ rule(is_api, False) }} {{ rule(is_sched, False) }}# Do not run anything for WIP commits {{ rule(is_wip, False) }}# Tags only happen on releases, don't run full automation {{ rule(is_tag, False) }} {{ rdef(True) }}
## Pipeline information dumppipeline-infodump: stage: consistency image: registry.nic.cz/labs/bird:docbuilder script: - | echo "### Variables ###"{%- for VAR in [ "CI_JOB_ID", "CI_COMMIT_SHA", "CI_COMMIT_BRANCH", "CI_COMMIT_TAG", "CI_COMMIT_TITLE", "CI_COMMIT_MESSAGE", "CI_PIPELINE_SOURCE", "CI_MERGE_REQUEST_IID", "GITLAB_API_URL", "wf_kind",] %} echo "\${{ VAR }} = ${{ VAR }}"{%- endfor %} echo echo "### Inputs ###" echo "Netlab: $[[ inputs.netlab ]]" echo "Build: $[[ inputs.build ]]" echo "Packages: $[[ inputs.packages ]]" echo "Docker all: $[[ inputs.docker-all ]]" echo "Docker regex: $[[ inputs.docker-regex ]]" echo "Docker one: $[[ inputs.docker-one ]]"
## Pipeline consistency checkpipeline-uptodate: stage: consistency image: registry.nic.cz/labs/bird:docbuilder script: - autoreconf -i - ./configure - touch gitlab/template.yml.j2 - make gitlab-venv - git status --porcelain - git diff --exit-code rules: - !reference [ .default-rules ]
## Build Docker consistency checkdocker-uptodate: stage: consistency image: registry.nic.cz/labs/bird:docbuilder script: - autoreconf -i - ./configure - touch gitlab/data.yml.j2 - make gitlab-docker VENV=1 - touch gitlab/docker/docbuilder/Dockerfile # Docbuilder is a static image, not rebuilt by the templates - find gitlab/docker/ -type f -not -newer gitlab/data.yml.j2 - '[ "`find gitlab/docker/ -type f -not -newer gitlab/data.yml.j2 | wc -l`" == "0" ]' - git status --porcelain - git diff --exit-code rules: - !reference [ .default-rules ]
## Consistency checks for stable branchescommit-messages: stage: consistency image: registry.nic.cz/labs/bird:docbuilder script: - tools/git-check-commits rules: {{ rule(is_stable, True) }} {{ rule(is_release_commit, True) }} {{ rdef(False) }}
## Tag checktag-collect: stage: consistency image: registry.nic.cz/labs/bird:docbuilder script: - python3 -m venv venv - . venv/bin/activate - pip3 install requests - tools/git-check-tag-local $CI_COMMIT_TAG - tools/git-check-tag-ci $CI_COMMIT_SHA artifacts: paths: - obj/doc/bird-singlepage.html - obj/doc/prog-singlepage.html - bird-*.tar.gz - pkg/pkgs/* - pkg/srcpkgs/* rules: {{ rule(is_tag, True) }} {{ rdef(False) }}
############################## Docker builder rebuild ############################### We are running all the build / packaging tests in Dockers (unless otherwise)# and these are rules to build these docker images. These are expensive to run# and should run only if needed.## Modify the appropriate dockerfile to rebuild these images
.docker: &docker-build stage: image needs: [] # docker-uptodate maybe? script: - $DOCKER_CMD login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.nic.cz # Make sure we refresh the base image if it updates (eg. security updates, etc) # If we do just the build, cache is always reused and the freshness of the # base image is never checked. However, pull always asks and updates the # image only if it changed ‒ therefore, the cache is used unless there's a # change. - $DOCKER_CMD pull `sed -ne 's/^FROM //p' "gitlab/docker/$IMG_NAME/Dockerfile"` - $DOCKER_CMD build -t "bird:$IMG_NAME" "gitlab/docker/$IMG_NAME" - $DOCKER_CMD tag "bird:$IMG_NAME" "$IMG_BASE:$IMG_NAME" - $DOCKER_CMD push "$IMG_BASE:$IMG_NAME" after_script: - rm -rf "$HOME/.docker/$CI_JOB_ID/" # cleanup the credentials tags: # That's Docker in Docker - dind
{% for docker in [ { "name": "docbuilder" } ] + distros %}docker-{{ docker["name"] }}: variables: IMG_NAME: "{{ docker["name"] }}"
rules: # Only rebuild if explicitly requested - if: '{{ inputs_docker_all }}' - if: '"{{ docker["name"] }}" =~ /$[[ inputs.docker-regex ]]/' - if: '"{{ docker["name"] }}" == "$[[ inputs.docker-one ]]"' {{ rdef(False) }}
<<: *docker-build{% endfor %}
####################################################### Linux distro build tests inside Docker builders #######################################################
## Build stage## Now we compile and run unit tests ... in every single distribution.# Every task needs its docker, see above.
.build-base-rules: - if: '{{ inputs_build }}' - if: '{{ inputs_packages }}' - !reference [ .default-rules ]
.build: &build-base stage: build rules: - !reference [ .build-base-rules ] script: - if [ "$CI_PIPELINE_SOURCE" == "merge_request_event" ]; then export BRANCH=mergerequest-$CI_MERGE_REQUEST_IID; else export BRANCH=$CI_COMMIT_BRANCH; fi - tools/version && ( echo -n "BIRD version "; tools/version ) > version-expected - | STABLE_VERSION="`cat VERSION`" if [ "$CI_COMMIT_MESSAGE" == "NEWS and version update " ] || [ "$[[ inputs.release-fixup ]]" -gt "1" ]; then if [ "${STABLE_VERSION}" == "`tools/version`" ]; then echo "Stable version precheck OK" else echo "Stable version discrepancy: $STABLE_VERSION vs. $(tools/version)" exit 1 fi else if grep -qF "BIRD version ${STABLE_VERSION}+branch" version-expected; then true else echo -n "Commit $CI_COMMIT_SHA message $CI_COMMIT_MESSAGE claims version " cat version-expected echo "Expected version ${STABLE_VERSION}+branch... instead" exit 1 fi fi - | if [ -n "$CROSSBUILD_ARCH" ]; then dpkg-architecture -A $CROSSBUILD_ARCH > crossbuild.sh . crossbuild.sh export CONFIGURE_OPTIONS="--host=${DEB_TARGET_GNU_TYPE} ${CONFIGURE_OPTIONS}" export CROSS_RUN=qemu-${CROSSBUILD_ARCH} fi - autoreconf - ./configure CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" ${CONFIGURE_OPTIONS} # Detect which make is available - MAKE=make - which gmake 2>/dev/null >/dev/null && MAKE=gmake - $MAKE VERBOSE=1 - $MAKE VERBOSE=1 TEST_RETRY_VERBOSE=1 check # Build docs when tools are available - if which linuxdoc pdflatex sgmlsasp >/dev/null ; then $MAKE docs ; fi # Check that the reported version is the right one - ulimit -c unlimited; ${CROSS_RUN} ./bird --version |& grep -v 'Cannot disable transparent huge pages' | tee obj/version-built - diff obj/version-built version-expected after_script: - if find -name 'core' -or -name 'core.*'; then git clone https://gitlab.nic.cz/labs/bird-group/debugpack; pushd debugpack; pip install -e .; popd; find '(' -name 'core' -or -name 'core.*' ')' -exec debugpack pack '{}' ';'; fi artifacts: when: on_failure untracked: true
.build-docker-linux-amd64: &build-docker-linux-amd64 <<: *build-base tags: - docker - linux - amd64
{% for dist in distros %}build-{{dist["name"]}}: <<: *build-docker-linux-amd64 needs: - job: docker-{{ dist["name"] }} optional: true image: registry.nic.cz/labs/bird:{{ dist["name"] }}{%- if 'variables' in dist %} variables:{{ dist["variables"] | to_yaml | indent(4, true) }}{%- endif %}{%- if "crossarch" in dist %}{% for ca in dist.crossarch %}crossbuild-{{ ca }}-{{ dist["name"] }}: <<: *build-docker-linux-amd64 needs: - job: docker-{{ dist["name"] }} optional: true image: registry.nic.cz/labs/bird:{{ dist["name"] }} variables: CROSSBUILD_ARCH: {{ ca }}{%- if 'variables' in dist %}{{ dist["variables"] | to_yaml | indent(4, true) }}{%- endif %}{% endfor %}{%- endif %}{% endfor %}
######################################################### A special task for preparing the release archives #########################################################build-release: image: registry.nic.cz/labs/bird:docbuilder needs: - job: docker-docbuilder optional: true stage: build tags: - docker - linux script: - if [ "$CI_PIPELINE_SOURCE" == "merge_request_event" ]; then export BRANCH=mergerequest-$CI_MERGE_REQUEST_IID; else export BRANCH=$CI_COMMIT_BRANCH; fi - autoreconf - ./configure --with-protocols= --disable-client - make obj/doc/bird-singlepage.html obj/doc/prog-singlepage.html - if grep '<pre><code>PARSER FAILED ' obj/doc/bird-singlepage.html obj/doc/prog-singlepage.html; then echo "Documentation build is broken!"; false; fi - tools/make-archive artifacts: paths: - obj/doc/bird-singlepage.html - obj/doc/prog-singlepage.html - bird-*.tar.gz expire_in: 1 day rules: !reference [ .build-base-rules ]
# Packaging rules# As we support some ancient versions of different distributions,# we need to keep several different machineries. It's not so bad# but it's bad nevertheless.## We do NOT build separate documentation packages in these rules.
.pkg-base: &pkg-base rules: - if: '{{ inputs_packages }}' {{ rule(is_tag, False) }} {{ rule(is_release_commit, True) }} {{ rule(not_stable, False) }} - !reference [ .default-rules ]
.pkg-deb: &pkg-deb <<: *pkg-base stage: pkg script: - if [ "$CI_PIPELINE_SOURCE" == "merge_request_event" ]; then export BRANCH=mergerequest-$CI_MERGE_REQUEST_IID; else export BRANCH=$CI_COMMIT_BRANCH; fi - tools/make-deb artifacts: paths: - pkg/pkgs/* - pkg/srcpkgs/*
.pkg-rpm: &pkg-rpm <<: *pkg-base stage: pkg script: - if [ "$CI_PIPELINE_SOURCE" == "merge_request_event" ]; then export BRANCH=mergerequest-$CI_MERGE_REQUEST_IID; else export BRANCH=$CI_COMMIT_BRANCH; fi - STABLE_BUILDDIR=true tools/make-rpm artifacts: paths: - pkg/pkgs/* - pkg/srcpkgs/*
{% for dist in distros %}pkg-{{ dist["name"] }}: <<: *pkg-{{ dist["type"] }} needs: - job: build-{{ dist["name"] }} artifacts: false - job: build-release image: registry.nic.cz/labs/bird:{{ dist["name"] }}{%- if 'variables' in dist %} variables:{{ dist["variables"] | to_yaml | indent(4, true) }}{%- endif %}{%- if "crossarch" in dist %}{% for ca in dist.crossarch %}crosspkg-{{ ca }}-{{ dist["name"] }}: <<: *pkg-{{ dist["type"] }} needs: - job: crossbuild-{{ ca }}-{{ dist["name"] }} artifacts: false - job: build-release image: registry.nic.cz/labs/bird:{{ dist["name"] }} variables: CROSSBUILD_ARCH: {{ ca }}{%- if 'variables' in dist %}{{ dist["variables"] | to_yaml | indent(4, true) }}{%- endif %}{% endfor %}{%- endif %}{% endfor %}
## Package installability checks
.install-deb: &install-deb <<: *pkg-base stage: install script: # setup crossbuild architecture - | if [ -n "$CROSSBUILD_ARCH" ]; then dpkg-architecture -A $CROSSBUILD_ARCH > crossbuild.sh . crossbuild.sh export CROSS_RUN=qemu-${CROSSBUILD_ARCH} fi # check that bird is _not_ installed now and no user or group bird exists - | if bird --version >/dev/null 2>&1; then echo "Error: BIRD unexpectedly installed" exit 1 fi if id -g bird >/dev/null 2>&1; then echo "Error: User group 'bird' unexpectedly exist before installation" exit 1 fi if id -u bird >/dev/null 2>&1; then echo "Error: User 'bird' unexpectedly exist before installation" exit 1 fi # install packages - find pkg/pkgs/ -type f -name '*.deb' '(' -ls -exec dpkg -i '{}' ';' ')' # test that installation is successful - ./tools/test-install "$CI_COMMIT_MESSAGE"
.install-rpm: &install-rpm <<: *pkg-base stage: install script: # check that bird is _not_ installed now and no user or group bird exists - | if bird --version >/dev/null 2>&1; then echo "Error: BIRD unexpectedly installed" exit 1 fi if id -g bird >/dev/null 2>&1; then echo "Error: User group 'bird' exist before installation" exit 1 fi if id -u bird >/dev/null 2>&1; then echo "Error: User 'bird' exist before installation" exit 1 fi # install packages - find pkg/pkgs/ -type f -name '*.rpm' '(' -ls -exec $RPM_INSTALL_CMD '{}' ';' ')' # test that installation is successful - ./tools/test-install "$CI_COMMIT_MESSAGE"
{% for dist in distros %}install-{{ dist["name"] }}: <<: *install-{{ dist["type"] }} needs: - job: pkg-{{ dist["name"] }} image: registry.nic.cz/labs/bird:{{ dist["name"] }} variables:{%- if dist["name"][:12] == "opensuse-16." %} RPM_INSTALL_CMD: zypper --non-interactive --no-gpg-checks in{%- elif dist["type"] == "rpm" %} RPM_INSTALL_CMD: rpm -i{%- endif %}
{%- for ca in dist.crossarch %}crossinstall-{{ ca }}-{{ dist["name"] }}: <<: *install-{{ dist["type"] }} needs: - job: crosspkg-{{ ca }}-{{ dist["name"] }} image: registry.nic.cz/labs/bird:{{ dist["name"] }} variables:{%- if dist["name"][:12] == "opensuse-16." %} RPM_INSTALL_CMD: zypper --non-interactive --no-gpg-checks in{%- elif dist["type"] == "rpm" %} RPM_INSTALL_CMD: rpm -i{%- endif %} CROSSBUILD_ARCH: {{ ca }}{%- endfor %}{% endfor %}
##################################### Non-linux build tests in QEMU #####################################.build-birdlab-base: &build-birdlab-base <<: *build-base stage: build needs: []# script:# - export BRANCH=$CI_COMMIT_BRANCH# - autoreconf# - ./configure $CONFIGURE_OPTIONS# - gmake# - gmake check
{% for test in birdlab %}build-birdlab-{{ test['name'] }}: <<: *build-birdlab-base{%- if 'variables' in test %} variables:{{ test['variables'] | to_yaml | indent(4, true) }}{%- endif %} tags: - birdlab-{{ test['dist'] if 'dist' in test else test['name'] }} - amd64{% endfor %}
########################### Partial build tests ###########################
.build-only: &build-only <<: *build-docker-linux-amd64 image: registry.nic.cz/labs/bird:{{ partial_build_image["name"] }} needs: - job: docker-{{ partial_build_image["name"] }} optional: true
{% for test in partial_build %}partial-build-linux-{{ test["protocols"] }}: <<: *build-only variables: CONFIGURE_OPTIONS: --with-protocols={{ test["protocols"] }}{% endfor %}
################################## Netlab functionality tests ##################################
.netlab-rules: &netlab-rules rules: - if: '{{ inputs_netlab }}' - !reference [ .default-rules ]
build-netlab: <<: *netlab-rules stage: build needs: [] variables: BDIR: build-netlab tags: - netlab - amd64 script: - if [ "$CI_PIPELINE_SOURCE" == "merge_request_event" ]; then export BRANCH=mergerequest-$CI_MERGE_REQUEST_IID; else export BRANCH=$CI_COMMIT_BRANCH; fi - autoreconf - mkdir $BDIR - cd $BDIR - ../configure - make artifacts: paths: - $BDIR/bird - $BDIR/birdc expire_in: 2 hours
.netlab-test: &test-base <<: *netlab-rules stage: test needs: [build-netlab] tags: - netlab - amd64 script: - sudo rm -rf netlab-failure - DIR=$(pwd) - cd $TOOLS_DIR - sudo git clean -fx - sudo git checkout -f master - git pull --ff-only - "mv $DIR/build-netlab/* netlab/common/" - ln -s $STAYRTR_BINARY netlab/common/stayrtr - cd netlab - sudo ./stop - ulimit -f 1048576 # Protect the filesystem from overflowing by log bloat - sudo ./runtest -s {{ netlab.dataset }} -m check $TEST_NAME after_script: - DIR=$(pwd) - cd $TOOLS_DIR/netlab - sudo ./stop || echo "Stop failed" - "mkdir -p $DIR/netlab-failure" - git status --porcelain > $DIR/netlab-failure.log - for f in $(git status --porcelain | sed -rn 's#^.[^DRT] netlab/##p'); do mkdir -p $DIR/netlab-failure/$(dirname $f); sudo chmod a+rw $f; sudo mv $f $DIR/netlab-failure/$(dirname $f); done artifacts: when: on_failure untracked: true
{% for test in netlab.tests %}test-{{ test["name"] }}: <<: *test-base variables: TEST_NAME: cf-{{ test["name"] }}{% endfor %}