diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a66624cc9b4db066aaff3c9a77849147458ba933..82f826e6ff37085fa48b687d41e41c011948e034 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,6 @@ variables: TESTV_DIR: "/usr/local/testv" - + BUILD_OUTPUT: "build_output.txt" # prevent running two pipelines on pushes to merge request branches workflow: @@ -37,19 +37,54 @@ stages: 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: +# template for build jobs to include the check for warnings +.build-job-with-check-for-warnings: extends: .test-job-linux + stage: build + allow_failure: + exit_codes: + - 123 + + +build-codec-linux-make: + extends: .build-job-with-check-for-warnings + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + 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' - stage: build script: - - bash ci/build_all_linux.sh + - 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' + 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' + 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: .test-job-linux + extends: .build-job-with-check-for-warnings rules: - if: $CI_PIPELINE_SOURCE == 'merge_request_event' stage: build @@ -57,7 +92,10 @@ build-codec-linux-cmake: - mkdir build - cd build - cmake .. - - make -j + - cd .. + - make -C build -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-instrumented-linux: extends: .test-job-linux diff --git a/ci/check_for_warnings.py b/ci/check_for_warnings.py new file mode 100755 index 0000000000000000000000000000000000000000..c9240e040ab0edc402b554462fcf917ee2c12cf5 --- /dev/null +++ b/ci/check_for_warnings.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 +import argparse +import sys + + +SEARCH_FOR = "warning:" +RETURN_FOUND = 123 + + +def main(log_file): + with open(log_file) as f: + lines_with_warnings = [l for l in f.readlines() if SEARCH_FOR in l] + + n_warnings = len(lines_with_warnings) + if n_warnings > 0: + print(f"========== Found {n_warnings} warnings: =========") + for l in lines_with_warnings: + print(l) + return RETURN_FOUND + else: + return 0 + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument( + "compilation-output", + type=str, + help="text output of compilation process to analyze", + ) + args = vars(parser.parse_args()) + ret_code = main(args[ "compilation-output" ]) + sys.exit(ret_code)