Beispiel #1
0
def PublishSelection(publishSelection, publishSelectionKey):
    cwd = BuildTools.TryChangeToDirectoryAndGetCwd(publishSelection)
    BuildTools.HandleTerminalCommandsSelection(publishSelection)

    if BuildTools.FILES_KEY in publishSelection:
        if BuildTools.TryGetFromDictionary(publishSelection,
                                           CONTAINER_ARTIFACT_KEY, True):
            PublishContainerSelection(publishSelection, publishSelectionKey)
        else:
            PublishArtifactSelection(publishSelection)

        BuildTools.HandleCopyFromContainer(publishSelection)

    os.chdir(cwd)
Beispiel #2
0
def RunSelection(runSelection):
    cwd = BuildTools.TryChangeToDirectoryAndGetCwd(runSelection)
    BuildTools.HandleTerminalCommandsSelection(runSelection)

    if BuildTools.FILES_KEY in runSelection:
        DockerComposeTools.DockerComposeUp(
            runSelection[BuildTools.FILES_KEY],
            BuildTools.TryGetFromDictionary(runSelection,
                                            ABORT_ON_CONTAINER_EXIT_KEY, True),
            BuildTools.TryGetFromDictionary(runSelection, DETACHED_KEY, False))

        BuildTools.HandleCopyFromContainer(runSelection)

    os.chdir(cwd)
def RunSelection(runSelection, selectionToRun):
    cwd = BuildTools.TryChangeToDirectoryAndGetCwd(runSelection)
    oldEnvironmentVariable = BuildTools.AddEnvironmentVariablesFromSelection(
        runSelection)
    BuildTools.HandleTerminalCommandsSelection(runSelection)
    TerminalTools.LoadDefaultEnvironmentVariablesFile()

    if BuildTools.FILES_KEY in runSelection:
        runComposeFile = BuildTools.GetAvailableComposeFilename(
            'run', selectionToRun)
        composeFiles = runSelection[BuildTools.FILES_KEY]
        if YamlTools.TryGetFromDictionary(runSelection,
                                          VERIFY_CONTAINER_EXIT_CODE, False):
            containerNames = BuildTools.MergeAndPopulateWithContainerNames(
                composeFiles, runComposeFile)
            if BuildTools.CONTAINER_NAMES_KEY in runSelection:
                containerNames = runSelection[BuildTools.CONTAINER_NAMES_KEY]
        else:
            containerNames = []
            DockerComposeTools.MergeComposeFiles(composeFiles, runComposeFile)

        try:
            DockerComposeTools.DockerComposeUp(
                [runComposeFile],
                YamlTools.TryGetFromDictionary(runSelection,
                                               ABORT_ON_CONTAINER_EXIT_KEY,
                                               True),
                YamlTools.TryGetFromDictionary(runSelection, DETACHED_KEY,
                                               False))
        except:
            BuildTools.RemoveComposeFileIfNotPreserved(runComposeFile,
                                                       runSelection)
            raise

        DockerImageTools.VerifyContainerExitCode(containerNames,
                                                 assertExitCodes=True)
        BuildTools.HandleCopyFromContainer(runSelection)

        if YamlTools.TryGetFromDictionary(runSelection,
                                          BuildTools.REMOVE_CONTAINERS_KEY,
                                          False):
            DockerComposeTools.DockerComposeRemove([runComposeFile])

        BuildTools.RemoveComposeFileIfNotPreserved(runComposeFile,
                                                   runSelection)

    BuildTools.RemoveEnvironmentVariables(oldEnvironmentVariable)
    os.chdir(cwd)
def TestSelection(testSelection):
    cwd = BuildTools.TryChangeToDirectoryAndGetCwd(testSelection)
    BuildTools.HandleTerminalCommandsSelection(testSelection)

    if BuildTools.FILES_KEY in testSelection:
        DockerComposeTools.ExecuteComposeTests(
            testSelection[BuildTools.FILES_KEY], 
            testSelection[CONTAINER_NAMES_KEY], False)

        BuildTools.HandleCopyFromContainer(testSelection)

        if BuildTools.TryGetFromDictionary(testSelection, REMOVE_CONTAINERS_KEY, False):
            DockerComposeTools.DockerComposeRemove(
                testSelection[BuildTools.FILES_KEY])

    os.chdir(cwd)
Beispiel #5
0
def PublishSelection(publishSelection, selectionToPublish):
    cwd = BuildTools.TryChangeToDirectoryAndGetCwd(publishSelection)
    oldEnvironmentVariable = BuildTools.AddEnvironmentVariablesFromSelection(
        publishSelection)
    BuildTools.HandleTerminalCommandsSelection(publishSelection)
    TerminalTools.LoadDefaultEnvironmentVariablesFile()

    if BuildTools.FILES_KEY in publishSelection:
        if YamlTools.TryGetFromDictionary(publishSelection,
                                          CONTAINER_ARTIFACT_KEY, True):
            PublishContainerSelection(publishSelection, selectionToPublish)
        else:
            PublishArtifactSelection(publishSelection)

        BuildTools.HandleCopyFromContainer(publishSelection)

    BuildTools.RemoveEnvironmentVariables(oldEnvironmentVariable)
    os.chdir(cwd)
def TestSelection(testSelection, selectionToTest):
    cwd = BuildTools.TryChangeToDirectoryAndGetCwd(testSelection)
    oldEnvironmentVariable = BuildTools.AddEnvironmentVariablesFromSelection(
        testSelection)
    BuildTools.HandleTerminalCommandsSelection(testSelection)
    TerminalTools.LoadDefaultEnvironmentVariablesFile()

    if BuildTools.FILES_KEY in testSelection:
        testComposeFile = BuildTools.GetAvailableComposeFilename(
            'test', selectionToTest)
        composeFiles = testSelection[BuildTools.FILES_KEY]
        containerNames = BuildTools.MergeAndPopulateWithContainerNames(
            composeFiles, testComposeFile)
        if BuildTools.CONTAINER_NAMES_KEY in testSelection:
            containerNames = testSelection[BuildTools.CONTAINER_NAMES_KEY]

        try:
            DockerComposeTools.ExecuteComposeTests(
                [testComposeFile],
                testContainerNames=containerNames,
                removeTestContainers=False,
                buildCompose=True,
                downCompose=False)
        except:
            BuildTools.RemoveComposeFileIfNotPreserved(testComposeFile,
                                                       testSelection)
            raise

        BuildTools.HandleCopyFromContainer(testSelection)
        DockerComposeTools.DockerComposeDown([testComposeFile])
        if YamlTools.TryGetFromDictionary(testSelection,
                                          BuildTools.REMOVE_CONTAINERS_KEY,
                                          False):
            DockerComposeTools.DockerComposeRemove([testComposeFile])

        BuildTools.RemoveComposeFileIfNotPreserved(testComposeFile,
                                                   testSelection)

    BuildTools.RemoveEnvironmentVariables(oldEnvironmentVariable)
    os.chdir(cwd)