Exemplo n.º 1
0
 def test_format_feature_branch_as_main(self):
     '''
     If BRANCHES_TAG_AS_MAIN is true, do not prepend branch name
     '''
     ivs = ImageVersionStep()
     os.environ[environment.BRANCHES_TAG_AS_MAIN] = 'True'
     os.environ[environment.GIT_BRANCH] = 'origin/a-feature-branch'
     main_branch_version = ivs.get_version('2.3.2')
     excepted = "2.3.2"
     self.assertEqual(main_branch_version, excepted)
Exemplo n.º 2
0
    def __init__(self):
        self.log = logging.getLogger(__name__)

        self.pipeline_steps = pipeline.create_pipeline_from_array([
            # Print Docker version
            DockerVersion(),
            # Configure pipeline
            SetupStep(),
            # Login to docker registry
            DockerLoginStep(),
            # Check the content of docker.conf
            ReadConfFileStep(
                'docker.conf',
                [environment.IMAGE_NAME, pipeline_data.IMAGE_VERSION]),
            # Create new image version major.minor.path_githash
            ImageVersionStep(),
            # Check old dependencies
            DependenciesCheckStep(),
            # Check Dockerfile exists
            DockerFileStep(),
            # Check Dockerfiles FROM statement
            FromImageStep(),
            # Check that ENTRYPOINT is not used
            # InstructionStep()
            # Write information about the current build to a json-file.
            BuildEnvironmentToFileStep(),
            # Scan the repo for passwords, tokens or other suspicious looking strings
            RepoSupervisorStep(),
            # Create docker --build-arg
            DockerCreateBuildArgStep(),
            # Build the image to local registry
            BuildLocalStep(),
            # It never to late to party
            CelebrateStep(),
            # Test run the image
            DryRunStep(),
            # Run unit tests
            UnitTestStep(),
            # Run integration tests
            IntegrationTestStep(),
            # Do something (leftover?)
            TestImageStep(),
            # EXPERIMENTAL ONLY: Docker-slim
            DockerSlimStep(),
            # Tag the built image with image version
            TagImageStep(),
            # Push the tagged image to a repository
            PushPublicImageStep(),
            PushAzureImageStep(),
            PushImageStep(),
            DoneStep()
        ])
Exemplo n.º 3
0
 def test_format_feature_branchand_hash(self):
     os.environ[environment.GIT_COMMIT] = "12345ai87q23b4sud6fyae"
     ivs = ImageVersionStep()
     self.assertEqual(
         ivs.append_commit_hash("origin.a.feature.branch-2.3.2"),
         "origin.a.feature.branch-2.3.2_12345ai")
Exemplo n.º 4
0
 def test_format_feature_branch(self):
     ivs = ImageVersionStep()
     os.environ[environment.GIT_BRANCH] = 'origin/a-feature-branch'
     feature_branch_version = ivs.get_version('2.3.2')
     excepted = "origin.a.feature.branch-2.3.2"
     self.assertEqual(feature_branch_version, excepted)
Exemplo n.º 5
0
 def test_format_main_main_branch(self):
     ivs = ImageVersionStep()
     os.environ[environment.GIT_BRANCH] = 'origin/main'
     branch = ivs.get_version('2.3.2')
     excepted = "2.3.2"
     self.assertEqual(branch, excepted)
Exemplo n.º 6
0
 def test_format_image_version_to_long(self):
     os.environ[environment.GIT_BRANCH] = 'origin/master'
     ivs = ImageVersionStep()
     ImageVersionStep.handle_step_error = mock.MagicMock()
     ivs.get_sem_ver('1.2.321', 1)
     ImageVersionStep.handle_step_error.assert_called_once()
Exemplo n.º 7
0
 def test_format_image_version_with_build_number_as_patch_and_hash(self):
     os.environ[environment.GIT_COMMIT] = "12345ai87q23b4sud6fyae"
     ivs = ImageVersionStep()
     self.assertEqual(ivs.append_commit_hash("1.2.123"), "1.2.123_12345ai")
Exemplo n.º 8
0
 def test_format_image_version_with_build_number_as_patch(self):
     os.environ[environment.GIT_BRANCH] = 'origin/master'
     ivs = ImageVersionStep()
     result = ivs.get_sem_ver('1.2', 123)
     self.assertEqual(result, '1.2.123')