diff --git a/action.yml b/action.yml index 1a6f2a4..19c55a2 100644 --- a/action.yml +++ b/action.yml @@ -36,7 +36,21 @@ inputs: required: false default: '' unittest_dependencies: - description: 'List of bundle items to use as unittest dependencies.' + description: '(Deprecated) use test_dependencies+test_strategy instead. This option forces test strategy to be ALL.' + required: false + default: '' + test_dependencies: + description: 'Build bundle dependencies used for tests.' + required: false + default: '' + test_strategy: + description: | + The strategy used for building and running tests. May be ALL, INTEGRATION, or UNIT. + - INTEGRATION: The bundle is trimmed to only include the test_dependencies all tests are run. + - UNIT: The bundle is trimmed to only include the test_dependencies and unit tests are run. + - ALL: A 2-stage build is performed with the first step using the + test_dependencies to build the unit tests and the second step + building the full bundle for integration tests. required: false default: '' self_test: @@ -57,8 +71,10 @@ runs: TARGET_REPO_DIR: ${{ inputs.target_repo_dir }} BUNDLE_REPOSITORY: ${{ inputs.bundle_repository }} CI_SELF_TEST: ${{ inputs.self_test }} - UNITTEST_BUNDLE_DEPENDENCIES: ${{ inputs.unittest_dependencies }} JEDI_CI_TOKEN: ${{ inputs.jedi_ci_token }} + UNITTEST_DEPENDENCIES: ${{ inputs.unittest_dependencies }} + TEST_DEPENDENCIES: ${{ inputs.test_dependencies }} + TEST_STRATEGY: ${{ inputs.test_strategy }} branding: icon: 'play' diff --git a/ci_action/implementation.py b/ci_action/implementation.py index 1de1691..7417d6d 100644 --- a/ci_action/implementation.py +++ b/ci_action/implementation.py @@ -148,24 +148,28 @@ def prepare_and_launch_ci_test( # Move the original bundle file to the original file. shutil.move(bundle_file, bundle_original) - # Rewrite the bundle cmake file twice - # First, rewrite the unit test bundle file with the build group commit hashes + test_dependencies = config['test_dependencies'] + test_strategy = config['test_strategy'] + + # Rewrite the bundle cmake file with the selected projects for the first build stage. with open(bundle_file_unittest, 'w') as f: - enabled_bundles = set(config['unittest_dependencies'] + [config['target_project_name']]) bundle.rewrite_build_group_whitelist( file_object=f, - enabled_bundles=enabled_bundles, + enabled_bundles=test_dependencies, build_group_commit_map=repo_to_commit_hash, ) - - # Create an integration test file. - with open(bundle_integration, 'w') as f: - bundle.rewrite_build_group_blacklist( - file_object=f, - disabled_bundles=set(), - build_group_commit_map=repo_to_commit_hash, - ) - LOG.info(f'{timer.checkpoint()}\n Rewrote bundle for build groups.') + LOG.info(f'{timer.checkpoint()}\n Wrote CMakeLists file with ' + f'bundles: {test_dependencies}.') + + # Create an integration test bundle definition if necessary. + if test_strategy == 'all': + with open(bundle_integration, 'w') as f: + bundle.rewrite_build_group_blacklist( + file_object=f, + disabled_bundles=set(), + build_group_commit_map=repo_to_commit_hash, + ) + LOG.info(f'{timer.checkpoint()}\n Wrote second CMakeLists file with bundles.') # Add resources to the bundle by copying all files in /app/shell to jedi_ci_resources shutil.copytree( @@ -244,15 +248,32 @@ def prepare_and_launch_ci_test( # write the test github check runs to the PR. for build_environment in chosen_build_environments: - checkrun_id_map = github_client.create_check_runs( - build_environment, - config['repo_name'], - config['owner'], - config['trigger_commit'], - test_annotations.next_ci_suffix) - LOG.info(f'{timer.checkpoint()}\nCreated check runs for {build_environment}.') - - # Note checkrun_id_map is dict {'unit': unit_run.id, 'integration': integration_run.id} + + # Set default check run IDs to 0 since this value is used in the test runner to + # determine if a check run update is a no-op. + integration_run_id = 0 + unit_run_id = 0 + + # Create GitHub check runs for the unit and integration tests (as required by strategy). + if test_strategy in ('all', 'unit'): + unit_run_id = github_client.create_check_run( + github_client.UNIT_TEST_PREFIX, + build_environment, + config['repo_name'], + config['owner'], + config['trigger_commit'], + test_annotations.next_ci_suffix) + if test_strategy in ('all', 'integration'): + integration_run_id = github_client.create_check_run( + github_client.INTEGRATION_TEST_PREFIX, + build_environment, + config['repo_name'], + config['owner'], + config['trigger_commit'], + test_annotations.next_ci_suffix) + LOG.info(f'{timer.checkpoint()}\nCreated check runs for build_environment \n' + f' - unit: {unit_run_id}\n - integration: {integration_run_id}.') + debug_time = 60 * 30 if test_annotations.debug_mode else 0 build_identity = ( f'{config["repo_name"]}-' @@ -277,9 +298,9 @@ def prepare_and_launch_ci_test( unittest_tag=config['unittest_tag'], trigger_sha=config['trigger_commit'], trigger_pr=str(config['pull_request_number']), - integration_run_id=checkrun_id_map['integration'], - unit_run_id=checkrun_id_map['unit'], - unittest_dependencies=' '.join(enabled_bundles), + integration_run_id=integration_run_id, + unit_run_id=unit_run_id, + unittest_dependencies=' '.join(test_dependencies), test_script=config['test_script'], ) job_arn = job['jobArn'] diff --git a/ci_action/library/github_client.py b/ci_action/library/github_client.py index 6556b08..b9c131a 100644 --- a/ci_action/library/github_client.py +++ b/ci_action/library/github_client.py @@ -172,10 +172,11 @@ def cancel_prior_unfinished_check_runs(repo, owner, pr_number, history_limit=20) return github_app.cancel_prior_unfinished_check_runs(repo, owner, pr_number, history_limit) -def create_check_runs(build_environment, repo, owner, trigger_commit, next_suffix): - """Create check runs (unit and integration) for a given build environment. +def create_check_run(prefix, build_environment, repo, owner, trigger_commit, next_suffix): + """Create check run for a given build environment. Args: + prefix: the prefix of the check run name. build_environment: intel, gcc, or gcc11 (or any other supported build environment). repo: The name of the repository. @@ -185,21 +186,14 @@ def create_check_runs(build_environment, repo, owner, trigger_commit, next_suffi pre-release test images in the job name. Returns: - Struct of check run ID's. - { - "integration": 14645415163, - "unit": 14645415264, - } + The run ID of the new check run. """ build_environment_name = build_environment + next_suffix github_app = GitHubAppClientManager.init_from_environment() - unit_run_name = f'{UNIT_TEST_PREFIX}: {build_environment_name}' - integration_run_name = f'{INTEGRATION_TEST_PREFIX}: {build_environment_name}' - unit_run = github_app.create_check_run( - repo, owner, trigger_commit, unit_run_name) - integration_run = github_app.create_check_run( - repo, owner, trigger_commit, integration_run_name) - return {'unit': unit_run.id, 'integration': integration_run.id} + run_name = f'{prefix}: {build_environment_name}' + run = github_app.create_check_run( + repo, owner, trigger_commit, run_name) + return run.id @lru_cache(maxsize=1) diff --git a/ci_action/main.py b/ci_action/main.py index c1676c6..38b993d 100644 --- a/ci_action/main.py +++ b/ci_action/main.py @@ -103,18 +103,32 @@ def get_environment_config(): self_test = os.environ.get('CI_SELF_TEST', 'false').lower() == 'true' test_script = os.environ.get('TEST_SCRIPT', 'run_tests.sh') - # Test dependencies as bundle items - test_deps = [d.strip() for d in os.environ.get('UNITTEST_BUNDLE_DEPENDENCIES', '').split(' ')] - filtered_test_deps = [] - for td in test_deps: - if td: - filtered_test_deps.append(td) - # Get the target project name. If not passed explicitly, use the repo name. target_project_name = os.environ.get('TARGET_PROJECT_NAME', '') if not target_project_name.strip(): target_project_name = repo_name + # Collect the test dependencies from the environment variables. + unittest_deps_env = os.environ.get('UNITTEST_DEPENDENCIES', '').strip() + unittest_deps = [d.strip() for d in unittest_deps_env.split(' ') if d.strip()] + test_deps_env = os.environ.get('TEST_DEPENDENCIES', '').strip() + test_deps = [d.strip() for d in test_deps_env.split(' ') if d.strip()] + + test_strategy = os.environ.get('TEST_STRATEGY', 'all').lower() + if test_strategy not in ['all', 'integration', 'unit']: + raise ValueError('Option "test_strategy" must be one of "ALL", "INTEGRATION", or "UNIT".') + + # Handle deprecated config option 'unittest_dependencies'. + if test_deps and unittest_deps: + raise ValueError('Config option "unittest_dependencies" and ' + '"test_dependencies" cannot be set simultaneously.') + elif unittest_deps: + test_deps = unittest_deps + test_strategy = 'all' + + # Ensure that the test dependencies include the target project. + test_deps = [d for d in set(test_deps + [target_project_name])] + config = { 'repository': repository, 'owner': owner, @@ -129,7 +143,8 @@ def get_environment_config(): 'bundle_branch': default_bundle_branch, 'bundle_repository': bundle_repository, 'self_test': self_test, - 'unittest_dependencies': filtered_test_deps, + 'test_dependencies': test_deps, + 'test_strategy': test_strategy, 'unittest_tag': test_tag, 'test_script': test_script, 'target_project_name': target_project_name, diff --git a/shell/run_tests.sh b/shell/run_tests.sh index 634761a..a94033c 100755 --- a/shell/run_tests.sh +++ b/shell/run_tests.sh @@ -91,8 +91,34 @@ CI_SCRIPTS_DIR=${CI_SCRIPTS_DIR} CC="${CC}" CXX="${CXX}" UNIT_DEPENDENCIES=${UNIT_DEPENDENCIES} +UNIT_RUN_ID=${UNIT_RUN_ID} +INTEGRATION_RUN_ID=${INTEGRATION_RUN_ID} EOF +# The check run IDs might not both be set depending on the test strategy. +# In order to handle all test strategies, we will check these values +# address them in order of their use. Unused test IDs will be set to 0 +# and those are handled gracefully by the helper functions which treat +# update and modify calls as a no-op. +if [ $UNIT_RUN_ID -ne 0 ] && [ $INTEGRATION_RUN_ID -ne 0 ]; then + export FIRST_CHECK_RUN_ID=$UNIT_RUN_ID + export SECOND_CHECK_RUN_ID=$INTEGRATION_RUN_ID +elif [ $UNIT_RUN_ID -ne 0 ] && [ $INTEGRATION_RUN_ID -eq 0 ]; then + export FIRST_CHECK_RUN_ID=$UNIT_RUN_ID + export SECOND_CHECK_RUN_ID=0 +elif [ $UNIT_RUN_ID -eq 0 ]&& [ $INTEGRATION_RUN_ID -ne 0 ]; then + export FIRST_CHECK_RUN_ID=$INTEGRATION_RUN_ID + export SECOND_CHECK_RUN_ID=0 +fi + +# For local testing, check runs are created by this script in which case the prior logic +# is overridden. +if [ "${CREATE_CHECK_RUNS}" == "yes" ]; then + export FIRST_CHECK_RUN_ID=$(util.check_run_new $TRIGGER_REPO_FULL "unit" $TRIGGER_SHA) + export SECOND_CHECK_RUN_ID=$(util.check_run_new $TRIGGER_REPO_FULL "integration" $TRIGGER_SHA) + export UNIT_RUN_ID=$FIRST_CHECK_RUN_ID + export INTEGRATION_RUN_ID=$SECOND_CHECK_RUN_ID +fi echo "--------------------------------------------------------------" echo "Platform debug info" @@ -123,8 +149,8 @@ if [ "${CREATE_CHECK_RUNS}" == "yes" ]; then fi # Update check-runs to include the batch job URL is included. -util.check_run_runner_allocated $TRIGGER_REPO_FULL $INTEGRATION_RUN_ID -util.check_run_start_build $TRIGGER_REPO_FULL $UNIT_RUN_ID +util.check_run_start_build $TRIGGER_REPO_FULL $FIRST_CHECK_RUN_ID +util.check_run_runner_allocated $TRIGGER_REPO_FULL $SECOND_CHECK_RUN_ID # Get all GitLFS repositories from s3. pushd ${JEDI_BUNDLE_DIR} @@ -155,32 +181,22 @@ sed -i "s#CDASH_URL#${CDASH_URL}#g" "${JEDI_BUNDLE_DIR}/CTestConfig.cm sed -i "s#CDASH_URL#${CDASH_URL}#g" "${JEDI_BUNDLE_DIR}/CTestConfig.cmake" sed -i "s#TEST_TARGET_NAME#${TRIGGER_REPO}#g" "${JEDI_BUNDLE_DIR}/CTestConfig.cmake" -# Update the CMakeLists.txt files to include cdash integration. Note that the test -# uses two different CMakeLists.txt files for unit and integration tests (starting with -# unit tests) and each file needs the cdash integration. Both of these cmake files -# were prepared by the GitHub action test launcher. -echo "include(cmake/cdash-integration.cmake)" >> "${JEDI_BUNDLE_DIR}/CMakeLists.txt.integration" -echo "" >> "${JEDI_BUNDLE_DIR}/CMakeLists.txt.integration" -echo "include(CTest)" >> "${JEDI_BUNDLE_DIR}/CMakeLists.txt.integration" -echo "" >> "${JEDI_BUNDLE_DIR}/CMakeLists.txt.integration" +# Update the CMakeLists.txt files to include cdash integration. Note that the test may +# use two different CMakeLists.txt files for unit and integration tests (starting with +# unit tests) and each file needs the cdash integration. These cmake files are +# prepared by the GitHub action test launcher. +if [ -f "${JEDI_BUNDLE_DIR}/CMakeLists.txt.integration" ]; then + echo "include(cmake/cdash-integration.cmake)" >> "${JEDI_BUNDLE_DIR}/CMakeLists.txt.integration" + echo "" >> "${JEDI_BUNDLE_DIR}/CMakeLists.txt.integration" + echo "include(CTest)" >> "${JEDI_BUNDLE_DIR}/CMakeLists.txt.integration" + echo "" >> "${JEDI_BUNDLE_DIR}/CMakeLists.txt.integration" +fi # Update the unittest CMakeLists.txt file to include cdash integration. echo "include(cmake/cdash-integration.cmake)" >> "${JEDI_BUNDLE_DIR}/CMakeLists.txt" echo "" >> "${JEDI_BUNDLE_DIR}/CMakeLists.txt" echo "include(CTest)" >> "${JEDI_BUNDLE_DIR}/CMakeLists.txt" echo "" >> "${JEDI_BUNDLE_DIR}/CMakeLists.txt" - -if [ $? -ne 0 ]; then - if grep -qi "remote: Invalid username or password." configure_1.log; then - util.check_run_fail $TRIGGER_REPO_FULL $UNIT_RUN_ID "Failure: see jcsda-internal/CI/issues/137" - else - util.check_run_fail $TRIGGER_REPO_FULL $UNIT_RUN_ID "Bundle configuration failed" - fi - util.check_run_skip $TRIGGER_REPO_FULL $INTEGRATION_RUN_ID - util.evaluate_debug_timer_then_cleanup - exit 0 -fi - # Add the oasim, ropp, and rttov compiler flags if the unittests have one # of these dependencies. Note that the same compiler flags are used for # integration tests, so a package without these unittest dependencies will @@ -213,15 +229,11 @@ ecbuild \ -DCTEST_UPDATE_VERSION_ONLY=FALSE \ -DBUILD_IODA_CONVERTERS=ON \ -DBUILD_PYIRI=ON \ - ${COMPILER_FLAGS[@]} "${JEDI_BUNDLE_DIR}" | tee configure_2.log + ${COMPILER_FLAGS[@]} "${JEDI_BUNDLE_DIR}" if [ $? -ne 0 ]; then - if grep -qi "remote: Invalid username or password." configure_2.log; then - util.check_run_fail $TRIGGER_REPO_FULL $UNIT_RUN_ID "Failure: see jcsda-internal/CI/issues/137" - else - util.check_run_fail $TRIGGER_REPO_FULL $UNIT_RUN_ID "Bundle configuration failed" - fi - util.check_run_skip $TRIGGER_REPO_FULL $INTEGRATION_RUN_ID + util.check_run_fail $TRIGGER_REPO_FULL $FIRST_CHECK_RUN_ID "Bundle configuration failed" + util.check_run_skip $TRIGGER_REPO_FULL $SECOND_CHECK_RUN_ID util.evaluate_debug_timer_then_cleanup exit 0 fi @@ -231,16 +243,21 @@ find $JEDI_BUNDLE_DIR -type f -exec touch -d "$SOURCE_BACKDATE_TIMESTAMP" {} \; make -j $BUILD_PARALLELISM if [ $? -ne 0 ]; then - util.check_run_fail $TRIGGER_REPO_FULL $UNIT_RUN_ID "compilation failed" - util.check_run_skip $TRIGGER_REPO_FULL $INTEGRATION_RUN_ID + util.check_run_fail $TRIGGER_REPO_FULL $FIRST_CHECK_RUN_ID "compilation failed" + util.check_run_skip $TRIGGER_REPO_FULL $SECOND_CHECK_RUN_ID util.evaluate_debug_timer_then_cleanup exit 0 fi -util.check_run_start_test $TRIGGER_REPO_FULL $UNIT_RUN_ID +# If unit run id is 0 +util.check_run_start_test $TRIGGER_REPO_FULL $FIRST_CHECK_RUN_ID # Run unit tests. -ctest -L $UNITTEST_TAG --timeout 500 -C RelWithDebInfo -D ExperimentalTest +if [ "${UNIT_RUN_ID}" -eq 0 ]; then + ctest --timeout 500 -C RelWithDebInfo -D ExperimentalTest +else + ctest -L $UNITTEST_TAG --timeout 500 -C RelWithDebInfo -D ExperimentalTest +fi # Upload ctests. ctest -C RelWithDebInfo -D ExperimentalSubmit -M Continuous -- --track Continuous --group Continuous @@ -249,19 +266,20 @@ echo "CDash URL: $(util.create_cdash_url "${BUILD_DIR}/Testing")" # This is a temporary hack to allow UFO tests to pass until we resolve the # flakes and/or persistent failures. Once UFO testing failures are resolved -# we can hard-code this failure rate to zero and remove this logic. +# we can hard-code this failure rate to zero and remove this logic. Also +# if the unit run id is 0 then the first run is an integration test. ALLOWED_UNIT_FAIL_RATE=0 -if [ $UNITTEST_TAG = 'ufo' ]; then +if [ $UNITTEST_TAG = 'ufo' ] || [ $UNIT_RUN_ID -eq 0 ]; then ALLOWED_UNIT_FAIL_RATE=1 fi # Close out the check run for unit tests and mark success or failure. -util.check_run_end $TRIGGER_REPO_FULL $UNIT_RUN_ID $ALLOWED_UNIT_FAIL_RATE +util.check_run_end $TRIGGER_REPO_FULL $FIRST_CHECK_RUN_ID $ALLOWED_UNIT_FAIL_RATE # Decision point: if the unit tests failed then we should mark the integration # tests as skipped and end test execution. if ! util.check_run_eval_test_xml $ALLOWED_UNIT_FAIL_RATE ; then - util.check_run_skip $TRIGGER_REPO_FULL $INTEGRATION_RUN_ID + util.check_run_skip $TRIGGER_REPO_FULL $SECOND_CHECK_RUN_ID util.evaluate_debug_timer_then_cleanup exit 0 fi @@ -269,7 +287,14 @@ fi # # Build and run integration tests. This section will not be run if we detect -# a failure above (implemented) +# a failure above. + +# If a second build and test execution is needed then we will expect both run IDs +# to be non-zero. If the second run ID is 0 then we can cleanup and exit early +if [ "${SECOND_CHECK_RUN_ID}" -eq 0 ]; then + util.evaluate_debug_timer_then_cleanup + exit 0 +fi # Swap out the unittest cmake file for the integration test version. These # files were created by the GitHub action test launcher. @@ -280,30 +305,27 @@ echo "---- JEDI Bundle CMakeLists.txt - integration tests -----" cat $JEDI_BUNDLE_DIR/CMakeLists.txt echo "-------------------------------------------------------" -# Delete test output to force re-generation of BuildID -TEST_TAG=$(head -1 "${BUILD_DIR}/Testing/TAG") - # Start the integration test run. -util.check_run_start_build $TRIGGER_REPO_FULL $INTEGRATION_RUN_ID +util.check_run_start_build $TRIGGER_REPO_FULL $SECOND_CHECK_RUN_ID if [ $? -ne 0 ]; then - util.check_run_fail $TRIGGER_REPO_FULL $INTEGRATION_RUN_ID "Bundle configuration failed" + util.check_run_fail $TRIGGER_REPO_FULL $SECOND_CHECK_RUN_ID "Bundle configuration failed" util.evaluate_debug_timer_then_cleanup exit 0 fi ecbuild \ - -Wno-dev \ - -DCMAKE_BUILD_TYPE=RelWithDebInfo \ - -DCDASH_OVERRIDE_SYSTEM_NAME="${JEDI_COMPILER}-Container" \ - -DCDASH_OVERRIDE_SITE=AWSBatch \ - -DCDASH_OVERRIDE_GIT_BRANCH=${TRIGGER_PR} \ - -DCTEST_UPDATE_VERSION_ONLY=FALSE \ - -DBUILD_IODA_CONVERTERS=ON \ - -DBUILD_PYIRI=ON \ - ${COMPILER_FLAGS[@]} "${JEDI_BUNDLE_DIR}" + -Wno-dev \ + -DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DCDASH_OVERRIDE_SYSTEM_NAME="${JEDI_COMPILER}-Container" \ + -DCDASH_OVERRIDE_SITE=AWSBatch \ + -DCDASH_OVERRIDE_GIT_BRANCH=${TRIGGER_PR} \ + -DCTEST_UPDATE_VERSION_ONLY=FALSE \ + -DBUILD_IODA_CONVERTERS=ON \ + -DBUILD_PYIRI=ON \ + ${COMPILER_FLAGS[@]} "${JEDI_BUNDLE_DIR}" if [ $? -ne 0 ]; then - util.check_run_fail $TRIGGER_REPO_FULL $INTEGRATION_RUN_ID "ecbuild failed" + util.check_run_fail $TRIGGER_REPO_FULL $SECOND_CHECK_RUN_ID "ecbuild failed" util.evaluate_debug_timer_then_cleanup exit 0 fi @@ -313,14 +335,17 @@ find $JEDI_BUNDLE_DIR -type f -exec touch -d "$SOURCE_BACKDATE_TIMESTAMP" {} \; make -j $BUILD_PARALLELISM if [ $? -ne 0 ]; then - util.check_run_fail $TRIGGER_REPO_FULL $INTEGRATION_RUN_ID "compilation failed" + util.check_run_fail $TRIGGER_REPO_FULL $SECOND_CHECK_RUN_ID "compilation failed" util.evaluate_debug_timer_then_cleanup exit 0 fi -util.check_run_start_test $TRIGGER_REPO_FULL $INTEGRATION_RUN_ID +# Delete test output to force re-generation of BuildID +TEST_TAG=$(head -1 "${BUILD_DIR}/Testing/TAG") + +util.check_run_start_test $TRIGGER_REPO_FULL $SECOND_CHECK_RUN_ID -# Run tests. +# Run integration tests. ctest -LE "${UNITTEST_TAG}|gsibec|rttov|oasim|ropp-ufo" --timeout 180 -C RelWithDebInfo -D ExperimentalTest # Upload ctests. @@ -334,7 +359,9 @@ TEST_TAG=$(head -1 "${BUILD_DIR}/Testing/TAG") ls -al "${BUILD_DIR}/Testing/${TEST_TAG}/" # Complete integration tests and allow a failure rate up to 3% -util.check_run_end $TRIGGER_REPO_FULL $INTEGRATION_RUN_ID 3 + +export ALLOWED_INTEGRATION_FAIL_RATE=3 +util.check_run_end $TRIGGER_REPO_FULL $SECOND_CHECK_RUN_ID $ALLOWED_INTEGRATION_FAIL_RATE # Upload codecov data if gcc compiler is used. if [ "$JEDI_COMPILER" = "gcc" ] && [ -f "${JEDI_BUNDLE_DIR}/${TRIGGER_REPO}/.codecov.yml" ]; then diff --git a/shell/util.sh b/shell/util.sh index 444cd6b..0467b5f 100755 --- a/shell/util.sh +++ b/shell/util.sh @@ -86,6 +86,9 @@ util.check_run_runner_allocated() { fi repo=$1 run_id=$2 + if [ $run_id -eq 0 ]; then + return 0 + fi # Note: when the test is updated to indicate a runner is allocated we do # not include the public log link since it is not available until after all # tests on a build host are complete. @@ -111,6 +114,9 @@ util.check_run_fail() { repo=$1 run_id=$2 fail_reason=$3 + if [ $run_id -eq 0 ]; then + return 0 + fi ${CI_SCRIPTS_DIR}/github_api/check_run.py update \ --app-private-key="${GITHUB_APP_PRIVATE_KEY_FILE}" \ --app-id="${GITHUB_APP_ID}" \ @@ -137,6 +143,9 @@ util.check_run_skip() { fi repo=$1 run_id=$2 + if [ $run_id -eq 0 ]; then + return 0 + fi ${CI_SCRIPTS_DIR}/github_api/check_run.py update \ --app-private-key="${GITHUB_APP_PRIVATE_KEY_FILE}" \ --app-id="${GITHUB_APP_ID}" \ @@ -162,6 +171,9 @@ util.check_run_successful_skip() { fi repo=$1 run_id=$2 + if [ $run_id -eq 0 ]; then + return 0 + fi ${CI_SCRIPTS_DIR}/github_api/check_run.py update \ --app-private-key="${GITHUB_APP_PRIVATE_KEY_FILE}" \ --app-id="${GITHUB_APP_ID}" \ @@ -186,6 +198,9 @@ util.check_run_start_build() { fi repo=$1 run_id=$2 + if [ $run_id -eq 0 ]; then + return 0 + fi # As with runner_allocated we don't include the public log link. ${CI_SCRIPTS_DIR}/github_api/check_run.py update \ --app-private-key="${GITHUB_APP_PRIVATE_KEY_FILE}" \ @@ -209,6 +224,9 @@ util.check_run_start_test() { fi repo=$1 run_id=$2 + if [ $run_id -eq 0 ]; then + return 0 + fi # As with runner_allocated we don't include the public log link. ${CI_SCRIPTS_DIR}/github_api/check_run.py update \ --app-private-key="${GITHUB_APP_PRIVATE_KEY_FILE}" \ @@ -235,6 +253,9 @@ util.check_run_end() { fi repo=$1 run_id=$2 + if [ $run_id -eq 0 ]; then + return 0 + fi max_fail_ppc=$3 cdash_url=$(util.create_cdash_url "${BUILD_DIR}/Testing") test_xml=$(util.find_test_xml)