コード例 #1
0
def main(targets, file):
    if len(targets) == 0:
        targets = ["default"]

    if hasattr(file, 'name') \
       and isinstance(file.name, str) \
       and os.path.isfile(file.name):
        # If filename available and file exists, load file to allow docker-compose integration
        parameters = Parameters(file.name, targets, 1)
    else:
        parameters = Parameters(file, targets, 1)
    project = load_project(parameters)
    context = core.create_context(project, parameters)

    print("Running RunCI pipeline for the following target(s): %s" % str.join(" ", targets))
    unknown_targets = [t for t in targets if t not in [t.name for t in project.targets]]
    if any(unknown_targets):
        print("Unkown targets: %s" % str.join(" ", unknown_targets), file=sys.stderr)
        sys.exit(1)

    result = asyncio.run(run_project(context))

    if result == JobStatus.SUCCEEDED:
        print("Pipeline has run succesfully.")
        sys.exit(0)
    elif result == JobStatus.FAILED:
        print("Pipeline has failed.", file=sys.stderr)
        sys.exit(1)
    elif result == JobStatus.CANCELED:
        print("Pipeline has been canceled.", file=sys.stderr)
        sys.exit(2)
    else:
        print("Pipeline has been run but outcome is undetermined. Please report this as a bug.", file=sys.stderr)
        sys.exit(3)
コード例 #2
0
ファイル: test_core.py プロジェクト: lsibilla/runci
    def test_failing_build(self, mock, project, parameters, calls, noparallel):
        def side_effect(self, project):
            self._status = runner.RunnerStatus.FAILED

        mock.side_effect = side_effect

        context = core.create_context(project, parameters)
        tree = core.DependencyTree(context)
        tree.run(noparallel)
        self.assertEqual(tree.status, job.JobStatus.FAILED)
コード例 #3
0
ファイル: test_job.py プロジェクト: lsibilla/runci
 def test_invalid_step_type(self, mock):
     target = Target("test", "", [Step("test", "invalid", {})])
     project = Project([], [target])
     context = core.create_context(project, None)
     job = Job(context, target)
     job.run()
     self.assertEqual(job.status, JobStatus.FAILED)
     self.assertTrue(
         any([
             mock_call for mock_call in mock.mock_calls
             if isinstance(mock_call.args[0], JobStepUnknownTypeEvent)
         ]))
コード例 #4
0
ファイル: test_job.py プロジェクト: lsibilla/runci
    def test_exception(self, mock):
        class TestRunner(RunnerBase):
            async def run_internal(self, project: Project):
                raise Exception("Simulating an exception")

        target = Target("test", "", [Step("test", "mock", {})])
        project = Project([], [target])
        context = core.create_context(project, None)
        job = Job(context, target)
        job.run()
        self.assertEqual(job.status, JobStatus.FAILED)

        self.assertEqual(mock.call_count, 3)
        self.assertIsInstance(mock.mock_calls[0].args[0], JobStartEvent)
        self.assertIsInstance(mock.mock_calls[1].args[0],
                              JobStepUnknownTypeEvent)
        self.assertIsInstance(mock.mock_calls[2].args[0], JobFailureEvent)
コード例 #5
0
ファイル: test_job.py プロジェクト: lsibilla/runci
    def test_release_messages(self):
        command = self.test_command

        class TestRunner(RunnerBase):
            async def run_internal(self, context: Context):
                await self._run_process(["sh", "-c", command])

        target = Target("test", "", [Step("test", "mock", {})])
        project = Project([], [target])
        context = core.create_context(project, None)
        context.runners["mock"] = TestRunner
        job = Job(context, target)
        job.run()
        self.assertEqual(job.status, JobStatus.SUCCEEDED)

        self.assertTrue(job.has_new_events())
        asyncio.run(job.process_events())
        self.assertFalse(job.has_new_events())
コード例 #6
0
ファイル: test_core.py プロジェクト: lsibilla/runci
 def test_command_line_args(self, mock, project, parameters, calls,
                            noparallel):
     context = core.create_context(project, parameters)
     core.DependencyTree(context).run(noparallel)
     mock.assert_has_calls(calls)
コード例 #7
0
ファイル: test_core.py プロジェクト: lsibilla/runci
 def test_runner_run(self, mock, project, parameters, calls):
     context = core.create_context(project, parameters)
     core.DependencyTree(context).run()
     mock.assert_has_calls([call(context)])
コード例 #8
0
ファイル: test_core.py プロジェクト: lsibilla/runci
 def test_inexistent(self, project, parameters):
     with self.assertRaises(UnknownTargetException):
         context = core.create_context(project, parameters)
         core.DependencyTree(context).run()
コード例 #9
0
 def test_integration(self, mock):
     context = create_context(self.project, self.parameters)
     DependencyTree(context).run()
     mock.assert_called_once()
コード例 #10
0
 async def run():
     runner = DockerPullRunner(self.project.targets[0], self.step, lambda e: None)
     context = create_context(self.project, self.parameters)
     await runner.run(context)
コード例 #11
0
 async def run():
     runner = ComposeBuildRunner(None, self.step, lambda e: None)
     context = create_context(self.project, self.parameters)
     await runner.run(context)