Commit 53535963 authored by Tapani Pihlajakuja's avatar Tapani Pihlajakuja
Browse files

Refactors and implements rules for running pipelines in main branch. Contains...

Refactors and implements rules for running pipelines in main branch. Contains also placeholder for long sanitizer test in issue #62.
parent a20eb24b
Loading
Loading
Loading
Loading
Loading
+107 −41
Original line number Diff line number Diff line
@@ -2,13 +2,16 @@ variables:
  TESTV_DIR: "/usr/local/testv"
  BUILD_OUTPUT: "build_output.txt"

# prevent running two pipelines on pushes to merge request branches

# This sets when pipelines are created. Jobs have more specific rules to restrict them.
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
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event' # Runs for merge requests
    - if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # Pushes to main
    - if: $CI_PIPELINE_SOURCE == 'schedule' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # Scheduled in main


stages:
@@ -18,21 +21,45 @@ stages:
  - compare


# template for all test jobs
.test-job:
# ---------------------------------------------------------------
# Job templates
# ---------------------------------------------------------------

# When designing templates, try not to use too much inheritance and
# if multiple templates and extended on, remember that on conflict,
# latest overwrites the parameter.

# templates for rules
.rules-basis:
  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
.rules-merge-request:
  extends: .rules-basis
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
    - if: $CI_PIPELINE_SOURCE == 'push'
      when: never

.rules-main-push:
  extends: .rules-basis
  rules:
    - if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH

.rules-main-scheduled:
  extends: .rules-basis
  rules:
    - if: $CI_PIPELINE_SOURCE == 'schedule' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH


# templates to define stages and platforms
.test-job-linux:
  extends: .test-job
  tags:
    - ivas-linux

.build-job-linux:
  extends: .test-job
  stage: build
  timeout: "2 minutes"
  tags:
@@ -55,46 +82,50 @@ stages:
      - 123


# ---------------------------------------------------------------
# Build jobs
# ---------------------------------------------------------------

build-codec-linux-make:
  extends: .build-job-with-check-for-warnings
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
  extends: 
    - .build-job-with-check-for-warnings
    - .rules-basis
  script:
    - make -j 2>&1 | tee $BUILD_OUTPUT
    # need to use the "|| exit $?" suffix to get the allowed_failure return code, otherwise the job fails with code 1...<
    - ci/check_for_warnings.py $BUILD_OUTPUT || exit $?

build-unittests-linux:
  extends: .build-job-with-check-for-warnings
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
  extends: 
    - .build-job-with-check-for-warnings
    - .rules-basis
  script:
    - make unittests -j 2>&1 | tee $BUILD_OUTPUT
    # need to use the "|| exit $?" suffix to get the allowed_failure return code, otherwise the job fails with code 1...<
    - ci/check_for_warnings.py $BUILD_OUTPUT || exit $?

build-prerenderer-linux:
  extends: .build-job-with-check-for-warnings
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
  extends: 
    - .build-job-with-check-for-warnings
    - .rules-basis
  script:
    - make -C scripts/prerenderer -j 2>&1 | tee $BUILD_OUTPUT
    # need to use the "|| exit $?" suffix to get the allowed_failure return code, otherwise the job fails with code 1...<
    - ci/check_for_warnings.py $BUILD_OUTPUT || exit $?

build-td-object-renderer-standalone-linux:
  extends: .build-job-with-check-for-warnings
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
  extends: 
    - .build-job-with-check-for-warnings
    - .rules-basis
  script:
    - make -C scripts/td_object_renderer/object_renderer_standalone -j 2>&1 | tee $BUILD_OUTPUT
    # need to use the "|| exit $?" suffix to get the allowed_failure return code, otherwise the job fails with code 1...<
    - ci/check_for_warnings.py $BUILD_OUTPUT || exit $?

build-codec-linux-cmake:
  extends: .build-job-with-check-for-warnings
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
  extends: 
    - .build-job-with-check-for-warnings
    - .rules-basis
  script:
    - mkdir build
    - cd build
@@ -105,28 +136,31 @@ build-codec-linux-cmake:
    - ci/check_for_warnings.py $BUILD_OUTPUT || exit $?

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

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


# ---------------------------------------------------------------
# Test jobs for merge requests
# ---------------------------------------------------------------

# test that runs all modes with 1s input signals
codec-smoke-test:
  extends: .test-job-linux-needs-testv-dir
  # temporarily restrict this job to the only runner which (so far) seems to runit without problems
  extends: 
    - .test-job-linux-needs-testv-dir
    - .rules-merge-request
  timeout: "5 minutes"
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
  stage: test
  needs: [ "build-codec-linux-cmake" ]
  script:
@@ -141,11 +175,11 @@ codec-smoke-test:

# code selftest testvectors with memory-sanitizer binaries
msan-on-merge-request-linux:
  extends: .test-job-linux
  extends: 
    - .test-job-linux
    - .rules-merge-request
  stage: test
  needs: [ "build-codec-sanitizers-linux" ]
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
  script:
    - make clean
    - make -j CLANG=1
@@ -156,11 +190,11 @@ msan-on-merge-request-linux:

# code selftest testvectors with address-sanitizer binaries
asan-on-merge-request-linux:
  extends: .test-job-linux
  extends: 
    - .test-job-linux
    - .rules-merge-request
  stage: test
  needs: [ "build-codec-sanitizers-linux" ]
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
  script:
    - make clean
    - make -j CLANG=2
@@ -171,11 +205,11 @@ asan-on-merge-request-linux:

# compare bit exactness between target and source branch
self-test-on-merge-request:
  extends: .test-job-linux
  extends: 
    - .test-job-linux
    - .rules-merge-request
  stage: compare
  needs: [ "build-codec-linux-cmake", "codec-smoke-test" ]
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
  timeout: "10 minutes"
  script:
    ### build test binaries, initial clean for paranoia reasons
@@ -259,6 +293,38 @@ self-test-on-merge-request:
      junit: report-junit.xml


# ---------------------------------------------------------------
# Test jobs for main branch
# ---------------------------------------------------------------

codec-comparison-on-main-push:
  extends:
    - .test-job-linux
    - .rules-main-push
  stage: compare
  needs: [ "build-codec-linux-cmake" ]
  timeout: "30 minutes" # To be revisited
  script:
    - echo "Linux, run longer comparison to previous main push"
    - git rev-parse HEAD # Current
    - git rev-parse HEAD~1 # Previous


sanitizer-test-on-main-scheduled:
  extends: .test-job-linux-needs-testv-dir
  stage: test
  rules:
    # only run in scheduled pipeline that passes this env var
    - if: $SANITIZER_TEST_IN_FMT
  script:
    - echo "Running scheduled sanitizer"
    # - python3 ci/run_scheduled_sanitizer_test.py $SANITIZER_TEST_IN_FMT $SANITIZER_TEST_OUT_FMTS


# ---------------------------------------------------------------
# Other jobs
# ---------------------------------------------------------------

# Pull state of a branch on 3GPP repo, push to a mirror repo.
pull-from-3gpp-forge:
  stage: maintenance