mirror of
https://github.com/splunk/security_content
synced 2026-06-08 17:32:49 +00:00
Perform basic tests if no detections/tests have changed but CI code has changed
This commit is contained in:
@@ -35,6 +35,7 @@ class GithubService:
|
||||
branch2 = 'develop'
|
||||
g = git.Git('security_content')
|
||||
changed_ssa_test_files = []
|
||||
ci_changes = False
|
||||
|
||||
if branch1 != 'develop':
|
||||
differ = g.diff('--name-only', branch1, branch2)
|
||||
@@ -55,6 +56,10 @@ class GithubService:
|
||||
if file_path_new not in changed_ssa_test_files:
|
||||
changed_ssa_test_files.append(file_path_new)
|
||||
|
||||
# changed CI code
|
||||
if file_path == '.gitlab-ci.yml' or file_path.startswith('bin/ssa-end-to-end-testing'):
|
||||
ci_changes = True
|
||||
|
||||
# all SSA test files for nightly build
|
||||
else:
|
||||
changed_files = sorted(glob.glob('security_content/tests/*/*.yml'))
|
||||
@@ -64,7 +69,11 @@ class GithubService:
|
||||
if os.path.basename(file_path).startswith('ssa'):
|
||||
changed_ssa_test_files.append(file_path)
|
||||
|
||||
return changed_ssa_test_files
|
||||
# changed CI code
|
||||
if file_path == '.gitlab-ci.yml' or file_path.startswith('bin/ssa-end-to-end-testing'):
|
||||
ci_changes = True
|
||||
|
||||
return changed_ssa_test_files, ci_changes
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -39,22 +39,30 @@ def main(args):
|
||||
|
||||
# Retrieve Security Content
|
||||
github_service = GithubService(branch)
|
||||
ci_changes = False
|
||||
if test_file:
|
||||
if not os.path.isfile('security_content/tests/' + test_file):
|
||||
LOGGER.error('Can not find specified test file')
|
||||
sys.exit(1)
|
||||
test_files_ssa = [str("tests/" + test_file)]
|
||||
else:
|
||||
test_files_ssa = github_service.get_changed_test_files_ssa()
|
||||
test_files_ssa, ci_changes = github_service.get_changed_test_files_ssa()
|
||||
|
||||
LOGGER.info('changed/added GitHub files:')
|
||||
for test_file in test_files_ssa:
|
||||
LOGGER.info(test_file)
|
||||
|
||||
if len(test_files_ssa) == 0:
|
||||
if ci_changes:
|
||||
LOGGER.info('CI code has changed')
|
||||
|
||||
if len(test_files_ssa) == 0 and not ci_changes:
|
||||
LOGGER.info('Nothing to test for SSA smoke test.')
|
||||
sys.exit(0)
|
||||
|
||||
if len(test_files_ssa) == 0 and ci_changes and fast:
|
||||
LOGGER.error('Cannot test CI changes since no detections/tests have changed and running in fast mode.')
|
||||
sys.exit(-1)
|
||||
|
||||
# test DSP and SSA pipeline
|
||||
ssa_detection_testing = SSADetectionTesting(env, tenant, token)
|
||||
if not fast:
|
||||
|
||||
Reference in New Issue
Block a user