Commit 82077f6d authored by Tapani Pihlajakuja's avatar Tapani Pihlajakuja
Browse files

Initial commit of CI build scripts from IVAS PC wiki. Author of content in...

Initial commit of CI build scripts from IVAS PC wiki. Author of content in this commit is Jan Kiene.
parent 87494e3f
Loading
Loading
Loading
Loading

.gitlab_ci.yml

0 → 100644
+155 −0
Original line number Diff line number Diff line
variables:
  TESTV_DIR: "/testv"
  TOOLS_DIR: "/tools"

# 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 for using an ubuntu 22.04 image in docker
.test-job-ubuntu:
  extends: .test-job
  image: $CI_REGISTRY_IMAGE/ubuntu_22.04:latest
  tags:
    - exec::docker

# 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:
  extends: .test-job-ubuntu
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
  stage: build
  script:
    - bash ci/build_all_linux.sh

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

# make sure that the codec builds with msan, asan and usan
build-codec-sanitizers-linux:
  extends: .test-job-ubuntu
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
  stage: build
  script:
    # need to patch PATH so that `clang` is available
    - PATH=$PATH:/usr/lib/llvm-13/bin
    - bash ci/build_codec_sanitizers_linux.sh

# test that runs all modes with 1s input signals
codec-smoke-test:
  extends: .test-job-ubuntu
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
  stage: test
  tags:
    - exec::docker
    - res::ivas-testv
  script:
    - bash ci/smoke_test.sh
  artifacts:
    paths:
      - summary.txt

# compare bit exactness between target and source branch
self-test-on-merge-request:
  extends: .test-job-ubuntu
  stage: compare
  tags:
    - exec::docker
    - res::ivas-testv
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
  script:
    ### build test binaries, clean for paranoia reasons
    - make clean all
    - mv IVAS_cod IVAS_cod_test
    - mv IVAS_dec IVAS_dec_test

    ### checkout version to compare against
    # first delete local target branch to avoid conflicts when branch is cached and there are merge conflicts during fetching
    - git branch -D $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
    # 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

    ## 1. variant: use target branch directly -> includes possible race condition
    #- git checkout $CI_MERGE_REQUEST_TARGET_BRANCH_NAME

    ## 2. variant: compare to last common commit ("start" of branch after all possible merge-backs)
    #- last_source_commit=$(git log -n 1 --pretty=format:"%H")
    #- last_target_commit=$(git log -n 1 --pretty=format:"%H" $CI_MERGE_REQUEST_TARGET_BRANCH_NAME)
    #- split_commit=$(git merge-base $last_source_commit $last_target_commit)
    #- git checkout $split_commit

    ## 3. variant: compare to last master 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
    - make clean all
    - mv IVAS_cod IVAS_cod_ref
    - mv IVAS_dec IVAS_dec_ref

    ### copy testv dir to necessary place
    - cp -r $TESTV_DIR ./scripts/testv
    ### run selftest
    - test_output=test_output.txt
    - python3 ./scripts/self_test.py --encref IVAS_cod_ref --decref IVAS_dec_ref --enctest IVAS_cod_test --dectest IVAS_dec_test | tee $test_output

    ### analyse test output
    # check for crashes during the test, if any happened, fail the test
    - if cat $test_output | 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 | 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:
      - ./scripts/ref/logs
      - ./scripts/test/logs
      - ./scripts/self_test_summary.txt


# 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
    
    # 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 -e "SBA" -e "_rs")
./scripts/runIvasCodec.py -p ./scripts/config/docker_linux.json -m $list -U 1
Loading