Commit 050f3c0c authored by Jan Kiene's avatar Jan Kiene
Browse files

Merge branch 'shared/ci-system-development' into 'main'

Implementation of CI system

See merge request !2
parents aea93062 bbdf8708
Loading
Loading
Loading
Loading

.gitlab-ci.yml

0 → 100644
+169 −0
Original line number Diff line number Diff line
variables:
  TESTV_DIR: "/usr/local/testv"


# prevent running two pipelines on pushes to merge request branches
workflow:
  rules:
    # see https://docs.gitlab.com/ee/ci/yaml/workflow.html#switch-between-branch-pipelines-and-merge-request-pipelines
    - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS && $CI_PIPELINE_SOURCE == "push"
      when: never
    - when: always


stages:
  - maintenance
  - build
  - test
  - compare


# template for all test jobs
.test-job:
  rules:
    - if: $MIRROR_ACCESS_TOKEN # Don't run in the mirror update pipeline (only then MIRROR_ACCESS_TOKEN is defined)
      when: never
    - when: on_success

# template test job on linux
.test-job-linux:
  extends: .test-job
  tags:
    - ivas-linux
  before_script:
    - if [ ! -d "$TESTV_DIR" ]; then mkdir -p $TESTV_DIR; fi
    - cp -r scripts/testv/* $TESTV_DIR/


# build all components of the project, i.e. codec itself, the unittests, the prerenderer and the standalone version of the TD object renderer
build-all-linux-make:
  extends: .test-job-linux
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
  stage: build
  script:
    - bash ci/build_all_linux.sh

build-codec-linux-cmake:
  extends: .test-job-linux
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
  stage: build
  script:
    - mkdir build
    - cd build
    - cmake ..
    - make -j

build-codec-instrumented-linux:
  extends: .test-job-linux
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
  stage: build
  script:
    - bash ci/build_codec_instrumented_linux.sh

# make sure that the codec builds with msan, asan and usan
build-codec-sanitizers-linux:
  extends: .test-job-linux
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
  stage: build
  script:
    - bash ci/build_codec_sanitizers_linux.sh


# test that runs all modes with 1s input signals
codec-smoke-test:
  extends: .test-job-linux
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
  stage: test
  script:
    - bash ci/smoke_test.sh
  artifacts:
    paths:
      - out/logs


# compare bit exactness between target and source branch
self-test-on-merge-request:
  extends: .test-job-linux
  stage: compare
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
  script:
    ### build test binaries, initial clean for paranoia reasons
    - make clean
    - mkdir build
    - cd build
    - cmake ..
    - make -j
    - mv IVAS_cod ../IVAS_cod_test
    - mv IVAS_dec ../IVAS_dec_test
    - cd ..
    - rm -rf build/*

    ### backup testvectors from source branch before switching to arget branch -> makes sure that up-to-date testv folder is used in case the branch makes changes to it
    - cp -r scripts/testv scripts/testv.bak

    ### checkout version to compare against
    # first delete local target branch to avoid conflicts when branch is cached and there are merge conflicts during fetching
    # depending on chaching, the branch may not be there, so prevent failure of this command -> should maybe be done smarter later
    - git branch -D $CI_MERGE_REQUEST_TARGET_BRANCH_NAME || true
    # needed when depth is lower than the number of commits in the branch
    - git fetch origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME:$CI_MERGE_REQUEST_TARGET_BRANCH_NAME

    ### compare to last target branch commit before pipeline was created
    - target_commit=$(git log $CI_MERGE_REQUEST_TARGET_BRANCH_NAME -1 --oneline --before=${CI_PIPELINE_CREATED_AT} --format=%H)
    - git checkout $target_commit

    ### build reference binaries
    - cd build
    - cmake ..
    - make -j
    - mv IVAS_cod ../IVAS_cod_ref
    - mv IVAS_dec ../IVAS_dec_ref
    - cd ..

    # TODO: instead check out the source commit again
    ### restore testv folder from branch
    - rm -rf scripts/testv
    - cp -r scripts/testv.bak scripts/testv

    ### run selftest
    - ls -altr scripts/testv
    - python3 ./scripts/self_test.py --encref IVAS_cod_ref --decref IVAS_dec_ref --enctest IVAS_cod_test --dectest IVAS_dec_test | tee test_output.txt

    ### analyse test output
    # check for crashes during the test, if any happened, fail the test
    - if cat test_output.txt | grep -c "Run errors were encountered for the following conditions:"; then echo "Codec had run errors"; exit 1; fi
    # check for non bitexact output and fail test if the merge request does not have a non-BE tag
    - if ! cat test_output.txt | grep -c "All [0-9]* tests are bitexact" && ! echo $CI_MERGE_REQUEST_TITLE | grep -c --ignore-case "\[non[ -]*be\]"; then echo "Non-bitexact cases without non-BE tag encountered"; exit 1; fi
  artifacts:
    paths:
      - test_output.txt
      - scripts/test/logs
      - scripts/ref/logs


# Pull state of a branch on 3GPP repo, push to a mirror repo.
pull-from-3gpp-forge:
  stage: maintenance
  rules:
    - if: $MIRROR_ACCESS_TOKEN # Only run in the mirror update pipeline (only then MIRROR_ACCESS_TOKEN is defined)
  script:
    # Set up git LFS for mirroring (see: https://github.com/git-lfs/git-lfs/issues/1762)
    - git lfs install --skip-smudge --local
    
    # Check out mirror branch - by default the runner checks out by commit hash, which results in detached head state
    - git checkout $CI_COMMIT_BRANCH
    
    # Pull commits from upstream
    - git remote add upstream https://forge.3gpp.org/rep/ivas-codec-pc/ivas-codec.git
    - git pull --ff-only --tags upstream $MIRROR_SOURCE_BRANCH
    - git lfs pull upstream

    # Push to mirror, include tags. Option `-o ci.skip` tells GitLab to skip CI for the pushed commits (assumed already tested upstream)
    - git push --tags -o ci.skip "https://${GITLAB_USER_LOGIN}:${MIRROR_ACCESS_TOKEN}@${CI_REPOSITORY_URL#*@}" "HEAD:${CI_COMMIT_BRANCH}"

ci/build_all_linux.sh

0 → 100755
+18 −0
Original line number Diff line number Diff line
#! /usr/bin/bash

if [ ! -d "lib_com" ]; then
    echo "not in root directory! - please run in IVAS root"
    exit 1
fi

# first build codec, everything else needs this anyway
make clean all
# build unittests
make unittests
# build prerenderer
cd scripts/prerenderer
make
# build standalone TD object renderer
cd ..
cd td_object_renderer/object_renderer_standalone
make
+11 −0
Original line number Diff line number Diff line
#! /usr/bin/bash

if [ ! -d "lib_com" ]; then
    echo "not in root directory! - please run in IVAS root"
    exit 1
fi

cd scripts
./prepare_instrumentation.sh
cd c-code_instrument
make
+15 −0
Original line number Diff line number Diff line
#! /usr/bin/bash

if [ ! -d "lib_com" ]; then
    echo "not in root directory! - please run in IVAS root"
    exit 1
fi

# CI linux container would do this, can stay commented if clang (v13) is in your path
#PATH=$PATH:/usr/lib/llvm-13/bin
make clean
make CLANG=1
make clean
make CLANG=2
make clean
make CLANG=3

ci/smoke_test.sh

0 → 100755
+12 −0
Original line number Diff line number Diff line
#! /usr/bin/bash

if [ ! -d "lib_com" ]; then
    echo "not in root directory! - please run in IVAS root"
    exit 1
fi

make clean all

# get all modes except SBA rate switching (which is broken currently)
list=$(./scripts/runIvasCodec.py -l | grep -v "SBA.*rs")
./scripts/runIvasCodec.py -p ./scripts/config/docker_linux.json -m $list -U 1
Loading