Пример #1
0
    def test_sub_values_are_invalid_raises_exception(self):
        input_yaml = 'python: "3.7"\r\naddons:\r\n  firefox:\r\n        - "invalid_version"'
        with self.assertRaises(ValueError):
            PipeLineScriptParser().parse(input_yaml)

        input_yaml = 'python: "invalid_version"\r\naddons:\r\n  firefox:\r\n        - "60.0"'
        with self.assertRaises(ValueError):
            PipeLineScriptParser().parse(input_yaml)

        input_yaml = 'addons:\r\n   chrome:\r\n     - "60.0"'
        with self.assertRaises(ValueError):
            PipeLineScriptParser().parse(input_yaml)
Пример #2
0
    def is_valid(self):
        valid = super(PipeLineModelForm, self).is_valid()
        if not valid:
            return False

        try:
            PipeLineScriptParser().parse(script=self.data['script'])
        except (ValueError, AttributeError) as e:
            traceback.print_exc()
            self.add_error('script', str(e))
            return False
        return True
Пример #3
0
    def restart(self, pipeline_result: PipeLineResult):
        try:
            script = PipeLineScriptParser().parse(pipeline_result.config)

            pipeline_results = [pipeline_result]
            futures = [
                self.executor.submit(self.run_docker_process,
                                     pipeline_result.command, pipeline_result)
            ]

            if self.pipeline.is_github_pipeline:
                self.watchers.submit(self.start_watcher, pipeline_results,
                                     futures)
        except ValueError as e:
            logging.exception("Error during restart!")
            if self.pipeline.is_github_pipeline:
                self.set_ci_status(status=GithubEventStatus.FAILURE,
                                   description=str(e))
Пример #4
0
    def test_yaml_is_correct_returns_parsed_dict_with_correct_values(self):
        expected_results = {
            'language': 'python',
            'python': ["3.7"],
            'script': ['python unittest discover', 'python something'],
            'after_install': 'coverage',
        }

        input_yaml = 'language: python\r\n' \
                     'python:\r\n' \
                     '- "3.7"\r\n' \
                     'script:\r\n' \
                     '  - "python unittest discover"\r\n' \
                     '  - "python something"\r\n' \
                     'after_install: "coverage"'

        output_yaml = PipeLineScriptParser().parse(input_yaml)
        self.assertEquals(expected_results, output_yaml)
Пример #5
0
    def run_pipeline(self):
        try:
            script = PipeLineScriptParser().parse(self.pipeline.script)
            if self.pull_request_number != -1:
                command_generator = PipeLineCommandGenerator(
                    parsed_script=script,
                    repository=self.pipeline.repo_url,
                    number=self.pull_request_number)
            else:
                command_generator = PipeLineCommandGenerator(
                    parsed_script=script,
                    repository=self.pipeline.repo_url,
                    branch=self.branch,
                    revision=self.revision)
            commands = command_generator.get_commands()
            last_results = PipeLineResult.objects.filter(
                pipeline=self.pipeline).last()
            version = last_results.version + 1 if last_results else 1

            pipeline_results = []
            futures = []
            for subversion, command in enumerate(commands):
                language = script['language']
                language_version = script[language][subversion]
                pipeline_result, future = self.create_entry_and_start_pipeline(
                    command, self.pipeline, version, subversion, language,
                    language_version)
                pipeline_results.append(pipeline_result)
                futures.append(future)

            if self.pipeline.is_github_pipeline:
                self.watchers.submit(self.start_watcher, pipeline_results,
                                     futures)
        except ValueError as e:
            if self.pipeline.is_github_pipeline:
                self.set_ci_status(status=GithubEventStatus.FAILURE,
                                   description=str(e))
Пример #6
0
 def test_invalid_yaml_raises_exception(self):
     with self.assertRaises(ValueError):
         PipeLineScriptParser().parse("string:\r\naaaaa")
Пример #7
0
 def test_empty_yaml_raises_exception(self):
     with self.assertRaises(ValueError):
         PipeLineScriptParser().parse("")
Пример #8
0
 def test_yaml_has_invalid_key_raises_exception(self):
     with self.assertRaises(ValueError):
         PipeLineScriptParser().parse("before_install: true\r\nduck_me: true")