Skip to content

Commit

Permalink
WIP: More work on project change logic (trilinos/Trilinos#3133)
Browse files Browse the repository at this point in the history
  • Loading branch information
bartlettroscoe committed Jul 19, 2018
1 parent 7d45503 commit 98268a9
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 31 deletions.
65 changes: 39 additions & 26 deletions test/ci_support/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,34 +131,47 @@ TRIBITS_ADD_ADVANCED_TEST( TribitsExampleProject_ProjectFileChangs_UnitTests
)


TRIBITS_ADD_ADVANCED_TEST( TribitsExampleProject_get_tribits_packages_from_files_list_1
OVERALL_WORKING_DIRECTORY TEST_NAME
OVERALL_NUM_MPI_PROCS 1

TEST_0
CMND "${CMAKE_COMMAND}"
ARGS -E copy
"${CMAKE_CURRENT_LIST_DIR}/test_data/tribits-example-project-changed-files-1.txt"
changed_files.txt

TEST_1
CMND "${CMAKE_COMMAND}"
ARGS
-D PROJECT_SOURCE_DIR="${${PROJECT_NAME}_TRIBITS_DIR}/examples/TribitsExampleProject"
-D TribitsExProj_DEPS_XML_OUTPUT_FILE=TribitsExProjPackageDependencies.cmake
-P "${${PROJECT_NAME}_TRIBITS_DIR}/ci_support/TribitsDumpDepsXmlScript.cmake"

TEST_2
CMND ${PYTHON_EXECUTABLE}
ARGS
"${${PROJECT_NAME}_TRIBITS_DIR}/ci_support/get-tribits-packages-from-files-list.py"
--deps-xml-file=TribitsExProjPackageDependencies.cmake
--files-list-file=changed_files.txt
PASS_REGULAR_EXPRESSION_ALL
"^ALL_PACKAGES,SimpleCxx\n"

FUNCTION(Test_TribitsExampleProject_get_tribits_packages_from_files_list
TEST_POSTFIX CHANGED_FILES_NAME MATCH_REGEX
)

TRIBITS_ADD_ADVANCED_TEST( TribitsExampleProject_get_tribits_packages_from_files_list_${TEST_POSTFIX}
OVERALL_WORKING_DIRECTORY TEST_NAME
OVERALL_NUM_MPI_PROCS 1

TEST_0
CMND "${CMAKE_COMMAND}"
ARGS -E copy
"${CMAKE_CURRENT_LIST_DIR}/test_data/${CHANGED_FILES_NAME}"
changed_files.txt

TEST_1
CMND "${CMAKE_COMMAND}"
ARGS
-D PROJECT_SOURCE_DIR="${${PROJECT_NAME}_TRIBITS_DIR}/examples/TribitsExampleProject"
-D TribitsExProj_DEPS_XML_OUTPUT_FILE=TribitsExProjPackageDependencies.cmake
-P "${${PROJECT_NAME}_TRIBITS_DIR}/ci_support/TribitsDumpDepsXmlScript.cmake"

TEST_2
CMND ${PYTHON_EXECUTABLE}
ARGS
"${${PROJECT_NAME}_TRIBITS_DIR}/ci_support/get-tribits-packages-from-files-list.py"
--deps-xml-file=TribitsExProjPackageDependencies.cmake
--files-list-file=changed_files.txt
--project-dir="${${PROJECT_NAME}_TRIBITS_DIR}/examples/TribitsExampleProject"
PASS_REGULAR_EXPRESSION_ALL
"${MATCH_REGEX}"

)

ENDFUNCTION()

Test_TribitsExampleProject_get_tribits_packages_from_files_list(
1 tribits-example-project-changed-files-1.txt "^ALL_PACKAGES,SimpleCxx\n" )

Test_TribitsExampleProject_get_tribits_packages_from_files_list(
2 tribits-example-project-changed-files-2.txt "^ALL_PACKAGES,WithSubpackages\n" )


#
# Test checkin-test.py script
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@
)
sys.path = [tribitsDirPath+"/examples/TribitsExampleProject/cmake"] + sys.path

print(sys.path)

from ProjectFileChange import *
import unittest

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PackagesList.cmake
packages/with_subpackages/Anything.txt
22 changes: 22 additions & 0 deletions tribits/ci_support/TribitsPackageFilePathUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,28 @@ def isGlobalBuildFileRequiringGlobalRebuild(self, modifiedFileFullPath):
return False


def getProjectChangeLogic(projectDir):

if not projectDir:
return DefaultProjectChangeLogic()

tribitsDirPath = os.path.abspath(
os.path.join(
os.path.dirname(os.path.abspath(__file__)),
"../..", "tribits"
)
)

old_sys_path = sys.path

try:
sys.path = [tribitsDirPath+"/examples/TribitsExampleProject/cmake"] + sys.path
import ProjectFileChange
return ProjectFileChange.ProjectChangeLogic()
finally:
sys.path = old_sys_path


def getPackageStructFromPath(projectDependencies, fullPath):
packageName = getPackageNameFromPath(projectDependencies, fullPath)
if packageName:
Expand Down
22 changes: 19 additions & 3 deletions tribits/ci_support/get-tribits-packages-from-files-list.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,17 @@
#

usageHelp = \
r"""get-tribits-packages-from-files-list.py --deps-xml-file=<DEPS_XML_FILE> --files-list-file=<FILES_LIST_FILE>
r"""get-tribits-packages-from-files-list.py --deps-xml-file=<DEPS_XML_FILE> \
--files-list-file=<FILES_LIST_FILE> [--project-dir=<projectDir>]
This script returns a comma-seprated list of all of the project's TriBITS SE
packages that must be directly tested for changes in the input list of files.
This may also include the special package name 'ALL_PACKAGES' which means that
at least one changed file (e.g. <projectDir>/CMakeLists.txt) should result in
having to test all of the TriBITS packages in the project. The logic for
which files should trigger testing all packages can be specialized for the
project through the Python module <projectDir>/cmake/ProjectFileChange.py.
project through the Python module <projectDir>/cmake/ProjectFileChange.py if
that file exists when passing in --project-dir=<projectDir>.
This script is used in continuous integration testing workflows involving
TriBITS projects. For such a scenario, the list files can come from:
Expand All @@ -78,15 +80,29 @@
"--files-list-file", dest="filesListFile", type="string", default=None,
help="File containing the list of modified files relative to project base directory, one file per line." )

clp.add_option(
"--project-dir", dest="projectDir", type="string", default="",
help="Base proejct directory. Used to acces more specialized logic beyond" \
+" what is known in the <DEPSXMLFILE>. If empty '', then it will be set" \
+" automatically if TriBITS is is the standard location w.r.t. the project" \
+" in relation to this script run from the TriBITS dir.")

(options, args) = clp.parse_args()

if not options.filesListFile:
raise Exception("Error, the option --files-list-file=FILENAME must be set!")

# ToDo: If options.projectDir is empty, then try to find a default one in case
# this


filesList = readStrFromFile(options.filesListFile).splitlines()

trilinosDependencies = getProjectDependenciesFromXmlFile(options.depsXmlFile)

packagesList = getPackagesListFromFilePathsList(trilinosDependencies, filesList, True)
projectChangeLogic = getProjectChangeLogic(options.projectDir)

packagesList = getPackagesListFromFilePathsList(trilinosDependencies, filesList, True,
projectChangeLogic)

print ','.join(packagesList)

0 comments on commit 98268a9

Please sign in to comment.