Files
o3de/scripts/build/TestImpactAnalysis/tiaf_driver.py
T
jonawals a3d14e217e Change TIAF seed criteria. (#1857)
We currently cannot predict when a given snapshot will be taken. This is
problematic as test impact analysis assumes that the coverage data will
be updated after each run. As we have no control over when our coverage
data will persist we will instead always seed when the pipeline and
branch is one of the seeding pipelines, otherwise we will attempt to
read that seed data and perform test impact analysis (if no seed data is
present we will fall back to a regular, uninstrumented run of all test
targets).

This approach has the following implications:

1. PR builds will benefit from test impact analysis as the seed data is
    (hopefully) available at the time the snapshot is created.

2. Builds for the aforementioned seeding branches and pipelines will not
    benefit from test impact analysis and will incur the cost of seeding
    regardless of whether or not that generated seed data ends up in the
    snapshot.

Signed-off-by: John <jonawals@amazon.com>
2021-07-07 11:47:36 +01:00

65 lines
3.4 KiB
Python

#
# Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
#
import argparse
from tiaf import TestImpact
import sys
import os
import datetime
import json
import socket
def parse_args():
def file_path(value):
if os.path.isfile(value):
return value
else:
raise FileNotFoundError(value)
def timout_type(value):
value = int(value)
if value <= 0:
raise ValueError("Timer values must be positive integers")
return value
def test_failure_policy(value):
if value == "continue" or value == "abort" or value == "ignore":
return value
else:
raise ValueError("Test failure policy must be 'abort', 'continue' or 'ignore'")
parser = argparse.ArgumentParser()
parser.add_argument('--config', dest="config", type=file_path, help="Path to the test impact analysis framework configuration file", required=True)
parser.add_argument('--src-branch', dest="src_branch", help="The branch that is being build", required=True)
parser.add_argument('--dst-branch', dest="dst_branch", help="For PR builds, the destination branch to be merged to, otherwise empty")
parser.add_argument('--seeding-branches', dest="seeding_branches", type=lambda arg: arg.split(','), help="Comma separated branches that seeding will occur on", required=True)
parser.add_argument('--pipeline', dest="pipeline", help="Pipeline the test impact analysis framework is running on", required=True)
parser.add_argument('--seeding-pipelines', dest="seeding_pipelines", type=lambda arg: arg.split(','), help="Comma separated pipeline that seeding will occur on", required=True)
parser.add_argument('--dest-commit', dest="dst_commit", help="Commit to run test impact analysis on (ignored when seeding)", required=True)
parser.add_argument('--suite', dest="suite", help="Test suite to run", required=True)
parser.add_argument('--test-failure-policy', dest="test_failure_policy", type=test_failure_policy, help="Test failure policy for regular and test impact sequences (ignored when seeding)", required=True)
parser.add_argument('--safeMode', dest="safe_mode", action='store_true', help="Run impact analysis tests in safe mode (ignored when seeding)")
parser.add_argument('--testTimeout', dest="test_timeout", type=timout_type, help="Maximum run time (in seconds) of any test target before being terminated", required=False)
parser.add_argument('--globalTimeout', dest="global_timeout", type=timout_type, help="Maximum run time of the sequence before being terminated", required=False)
parser.set_defaults(test_timeout=None)
parser.set_defaults(global_timeout=None)
args = parser.parse_args()
return args
if __name__ == "__main__":
try:
args = parse_args()
tiaf = TestImpact(args.config, args.dst_commit, args.src_branch, args.dst_branch, args.pipeline, args.seeding_branches, args.seeding_pipelines)
return_code = tiaf.run(args.suite, args.test_failure_policy, args.safe_mode, args.test_timeout, args.global_timeout)
# Non-gating will be removed from this script and handled at the job level in SPEC-7413
#sys.exit(return_code)
sys.exit(0)
except:
# Non-gating will be removed from this script and handled at the job level in SPEC-7413
sys.exit(0)