Esempio n. 1
0
    def run(self,
            action,
            skip_clone,
            skip_pull,
            skip,
            workspace,
            reuse,
            dry_run,
            parallel,
            with_dependencies,
            runtime,
            skip_secrets_prompt=False):
        """Run the workflow or a specific action.
        """
        new_wf = deepcopy(self.wf)

        if skip:
            new_wf = Workflow.skip_actions(self.wf, skip)

        if action:
            new_wf = Workflow.filter_action(self.wf, action, with_dependencies)

        new_wf.check_for_unreachable_actions(skip)

        WorkflowRunner.check_secrets(new_wf, dry_run, skip_secrets_prompt)
        WorkflowRunner.download_actions(new_wf, dry_run, skip_clone, self.wid)
        WorkflowRunner.instantiate_runners(runtime, new_wf, workspace, dry_run,
                                           skip_pull, self.wid)

        for s in new_wf.get_stages():
            WorkflowRunner.run_stage(runtime, new_wf, s, reuse, parallel)
Esempio n. 2
0
    def run(self,
            action,
            skip_clone,
            skip_pull,
            skip,
            workspace,
            reuse,
            dry_run,
            parallel,
            with_dependencies,
            engine,
            skip_secrets_prompt=False):
        """Run the workflow or a specific action.

        Args:
          action(str): Name of particular action being executed from workflow.
          skip_clone(bool): True if cloning action has to be skipped.
          skip_pull(bool): True if pulling action has to be skipped.
          skip(tuple): Tuple containing the actions to be skipped.
          workspace(str): Location of the workspace.
          reuse(bool): True if existing containers are to be reused.
          dry_run(bool): True if workflow flag is being dry-run.
          parallel(bool): True if actions are to be executed in parallel.
          with_dependencies(bool): True if with-dependencies flag is passed
                                    as an argument.
          engine(str): Name of the run time being used in workflow.
          skip_secrets_prompt(bool): True if part of the workflow has to
                                    be skipped.(Default value = False)

        Returns:
            None
        """
        new_wf = deepcopy(self.wf)

        if skip:
            new_wf = Workflow.skip_actions(self.wf, skip)

        if action:
            new_wf = Workflow.filter_action(self.wf, action, with_dependencies)

        new_wf.check_for_unreachable_actions(skip)

        WorkflowRunner.check_secrets(new_wf, dry_run, skip_secrets_prompt)
        WorkflowRunner.download_actions(new_wf, dry_run, skip_clone, self.wid)
        WorkflowRunner.instantiate_runners(engine, new_wf, workspace, dry_run,
                                           skip_pull, self.wid)

        for s in new_wf.get_stages():
            WorkflowRunner.run_stage(engine, new_wf, s, reuse, parallel)
Esempio n. 3
0
    def test_filter_action(self):
        self.create_workflow_file("""
        workflow "example" {
            resolves = "end"
            }

            action "a" {
            uses = "sh"
            args = "ls"
            }

            action "b" {
            uses = "sh"
            args = "ls"
            }

            action "c" {
            uses = "sh"
            args = "ls"
            }

            action "d" {
            needs = ["c"]
            uses = "sh"
            args = "ls"
            }

            action "e" {
            needs = ["d", "b", "a"]
            uses = "sh"
            args = "ls"
            }

            action "end" {
            needs = "e"
            uses = "sh"
            args = "ls"
            }
        """)
        wf = Workflow('/tmp/test_folder/a.workflow')
        wf.parse()
        changed_wf = Workflow.filter_action(wf, 'e')
        self.assertSetEqual(changed_wf.root, {'e'})
        self.assertDictEqual(
            changed_wf.action, {
                'e': {
                    'needs': [],
                    'uses': 'sh',
                    'args': ['ls'],
                    'name': 'e',
                    'next': set()
                }
            })

        changed_wf = Workflow.filter_action(wf, 'd')
        self.assertSetEqual(changed_wf.root, {'d'})
        self.assertDictEqual(
            changed_wf.action, {
                'd': {
                    'needs': [],
                    'uses': 'sh',
                    'args': ['ls'],
                    'name': 'd',
                    'next': set()
                }
            })

        changed_wf = Workflow.filter_action(wf, 'e', with_dependencies=True)
        self.assertSetEqual(changed_wf.root, {'b', 'a', 'c'})
        self.assertDictEqual(
            changed_wf.action, {
                'a': {
                    'uses': 'sh',
                    'args': ['ls'],
                    'name': 'a',
                    'next': {'e'}
                },
                'b': {
                    'uses': 'sh',
                    'args': ['ls'],
                    'name': 'b',
                    'next': {'e'}
                },
                'c': {
                    'uses': 'sh',
                    'args': ['ls'],
                    'name': 'c',
                    'next': {'d'}
                },
                'd': {
                    'needs': ['c'],
                    'uses': 'sh',
                    'args': ['ls'],
                    'name': 'd',
                    'next': {'e'}
                },
                'e': {
                    'needs': ['d', 'b', 'a'],
                    'uses': 'sh',
                    'args': ['ls'],
                    'name': 'e',
                    'next': set()
                }
            })

        changed_wf = Workflow.filter_action(wf, 'd', with_dependencies=True)
        self.assertSetEqual(changed_wf.root, {'c'})
        self.assertDictEqual(
            changed_wf.action, {
                'c': {
                    'uses': 'sh',
                    'args': ['ls'],
                    'name': 'c',
                    'next': {'d'}
                },
                'd': {
                    'needs': ['c'],
                    'uses': 'sh',
                    'args': ['ls'],
                    'name': 'd',
                    'next': set()
                }
            })