-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes: Add CI functionality. On every sync project (with `ci_template` variable) check for updates and run selected template. See merge request polemarch/ce!156
- Loading branch information
Showing
17 changed files
with
333 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from typing import Text, NoReturn | ||
import logging | ||
import traceback | ||
from .models.tasks import BModel, Template | ||
|
||
|
||
logger = logging.getLogger('polemarch') | ||
|
||
|
||
class DefaultHandler: | ||
ci_types = { | ||
'template': Template | ||
} | ||
|
||
def __init__(self, repo, results): | ||
self.repo = repo | ||
self.repo_obj, self.result = results | ||
self.ci_vars = self.repo.proj.get_vars_prefixed('ci') | ||
|
||
def event_log(self, message: Text, *args, **kwargs) -> NoReturn: | ||
logger.info(message.format(*args, *kwargs)) | ||
|
||
def get_ci_call_object(self) -> [BModel, None]: | ||
ci_keys = self.ci_vars.keys() | ||
if not ci_keys: | ||
return None | ||
ci_type_name = list(ci_keys)[0] | ||
ci_model = self.ci_types[ci_type_name] | ||
return ci_model.objects.get(pk=self.ci_vars[ci_type_name]) | ||
|
||
def trigger_execution(self) -> NoReturn: | ||
if self.result: | ||
ci_object = self.get_ci_call_object() | ||
if ci_object: | ||
self.event_log('Start executing CI context.') | ||
try: | ||
ci_object.ci_run() | ||
except Exception: # nocv | ||
self.event_log(traceback.format_exc()) | ||
raise |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.