def run_function_core_tests(request): """When we are called by GH we want to run the jenkins builds It's called for each push on the plone repo, so we look which tests needs to run for the given repository and branch: """ # bail out early if it's just a github check payload = json.loads(request.POST['payload']) if 'ref' not in payload: return json.dumps({'message': 'pong'}) # lots of variables repo_name = payload['repository']['name'] repo = payload['repository']['full_name'] branch = payload['ref'].split('/')[-1] # who pushed the commits? who = get_user(payload['pusher']) data = get_info(payload, repo, branch) timestamp, changeset, changeset_long, fake, skip, source_or_checkout = data if not fake and not skip: request.registry.notify(NewCoreDevPush(payload, request)) # If it is a push to buildout.coredev, # update sources and checkouts and quit if repo == 'plone/buildout.coredev': logger.info('Commit: on coredev - do nothing') if source_or_checkout: get_sources_and_checkouts(request) return json.dumps( {'message': 'Thanks! Commit to coredev, nothing to do'}) ## # It's not a commit to coredev repo ## # if it's a skip commit, log and done if skip: logger.info(f'Commit: skip CI - {repo} - {branch} do nothing') return json.dumps({'message': 'Thanks! Skipping CI'}) # if the repo+branch are not in any plone version sources.cfg, # log and done plone_versions = plone_versions_targeted(repo, branch, request) if not plone_versions: # Error repo not in sources logger.info(f'Commit: not in sources - {repo} - {branch} do nothing') return json.dumps( {'message': 'Thanks! Commits done on a branch, nothing to do'}) ## # a commit on a branch that's part of a plone version ## checkouts = get_pickled_data(request.registry.settings['checkouts_file']) for plone_version in plone_versions: # if the repository is not on checkouts.cfg things could be broken # at a later point when it's added, warn about it!! if repo_name not in checkouts[plone_version]: warn_repo_not_in_checkouts(plone_version, request, who, repo, branch, payload) commit_on_plone_version(plone_version, request, payload, changeset, changeset_long, timestamp) return json.dumps({'message': 'Thanks! Plone Jenkins CI will run tests'})
def run_function_core_tests(request): """When we are called by GH we want to run the jenkins builds It's called for each push on the plone repo, so we look which tests needs to run for the given repository and branch: """ # bail out early if it's just a github check payload = json.loads(request.POST['payload']) if 'ref' not in payload: return json.dumps({'message': 'pong'}) # lots of variables changeset = '' changeset_long = '' commits_info = [] timestamp = datetime.datetime.now(GMT1()).isoformat() fake = False skip = False source_or_checkout = False commit_data = None message = '' sources = get_pickled_data(request.registry.settings['sources_file']) checkouts = get_pickled_data(request.registry.settings['checkouts_file']) repo_name = payload['repository']['name'] repo = payload['repository']['full_name'] branch = payload['ref'].split('/')[-1] # who pushed the commits? who = get_user(payload['pusher']) # gather information about the commits. There are three special cases: # - fake: the commit was made by mr.roboto itself # - skip: the committer requested to skip CI for this commit, # usually done by the release team to avoid flooding Jenkins # - sources_or_checkouts: either sources.cfg or checkouts.cfg has been # changed (the data stored locally needs to be updated maybe) for commit in payload['commits']: # get the commit data structure commit_data = get_info_from_commit(commit) commits_info.append(commit_data) files = '\n'.join(commit_data['files']) if '[fc]' in commit_data['short_commit_msg']: fake = True if '[ci skip]' in commit_data['full_commit_msg']: skip = True if 'sources.cfg' in files or 'checkouts.cfg' in files: source_or_checkout = True # prepare a changeset text message data = { 'push': payload, 'commit': commit, 'files': files, 'diff': commit_data['diff'], } changeset += templates['github_commit.pt'](**data) changeset_long += templates['jenkins_changeset.pt'](**data) # get a timestamp for later usage when creating commits timestamp = commit['timestamp'] message = 'Commit on {0} {1} {2}'.format(repo, branch, commit['id']) add_log(request, commit_data['reply_to'], message) if not fake and not skip: request.registry.notify(NewCoreDevPush(payload, request)) # If it is a push to buildout.coredev, # update sources and checkouts and quit if repo == 'plone/buildout.coredev': add_log( request, commit_data['reply_to'], 'Commit to coredev - do nothing' ) if source_or_checkout: get_sources_and_checkouts(request) return json.dumps({'message': 'Thanks!'}) ## # It's not a commit to coredev repo ## # if it's a skip commit, log and done if skip: msg = 'Commit skipping CI - {0} - {1} do nothing' add_log(request, who, msg.format(repo, branch)) return json.dumps({'message': 'Thanks! Skipping CI'}) # if the repo+branch are not in any plone version sources.cfg, # log and done elif (repo, branch) not in sources: # Error repo not sources msg = 'Commit not in sources - {0} - {1} do nothing' add_log(request, who, msg.format(repo, branch)) return json.dumps( {'message': 'Thanks! Commits done on a branch, nothing to do'} ) ## # a commit on a branch that's part of a plone version ## affected_plone_versions = sources[(repo, branch)] for plone_version in affected_plone_versions: # if the repository is not on checkouts.cfg things could be broken # at a later point when it's added, warn about it!! if repo_name not in checkouts[plone_version]: request.registry.notify( CommitAndMissingCheckout( who, request, repo, branch, plone_version, payload['pusher']['email'] # duplicated, already on 'who' ) ) # commit to the plone version branch. This way jenkins will trigger a # build and will get the latest changes from the repository that # triggered this view commit_to_coredev( request, payload, plone_version, changeset, changeset_long, timestamp, ) add_log(request, who, message) return json.dumps( {'message': 'Thanks! Plone Jenkins CI will run tests'} )
def update_pickles(context, request): get_sources_and_checkouts(request) return json.dumps({'message': 'updated!'})
def update_pickles(context, request): get_sources_and_checkouts(request) return {'message': 'updated!'}
def run_function_core_tests(request): """When we are called by GH we want to run the jenkins builds It's called for each push on the plone repo, so we look which tests needs to run for the given repository and branch: """ # bail out early if it's just a github check payload = json.loads(request.POST['payload']) if 'ref' not in payload: return json.dumps({'message': 'pong'}) # lots of variables repo_name = payload['repository']['name'] repo = payload['repository']['full_name'] branch = payload['ref'].split('/')[-1] # who pushed the commits? who = get_user(payload['pusher']) data = get_info(payload, repo, branch) timestamp, changeset, changeset_long, fake, skip, source_or_checkout = data if not fake and not skip: request.registry.notify(NewCoreDevPush(payload, request)) # If it is a push to buildout.coredev, # update sources and checkouts and quit if repo == 'plone/buildout.coredev': logger.info('Commit: on coredev - do nothing') if source_or_checkout: get_sources_and_checkouts(request) return json.dumps({'message': 'Thanks! Commit to coredev, nothing to do'}) ## # It's not a commit to coredev repo ## # if it's a skip commit, log and done if skip: logger.info(f'Commit: skip CI - {repo} - {branch} do nothing') return json.dumps({'message': 'Thanks! Skipping CI'}) # if the repo+branch are not in any plone version sources.cfg, # log and done plone_versions = plone_versions_targeted(repo, branch, request) if not plone_versions: # Error repo not in sources logger.info(f'Commit: not in sources - {repo} - {branch} do nothing') return json.dumps( {'message': 'Thanks! Commits done on a branch, nothing to do'} ) ## # a commit on a branch that's part of a plone version ## checkouts = get_pickled_data(request.registry.settings['checkouts_file']) for plone_version in plone_versions: # if the repository is not on checkouts.cfg things could be broken # at a later point when it's added, warn about it!! if repo_name not in checkouts[plone_version]: warn_repo_not_in_checkouts( plone_version, request, who, repo, branch, payload ) commit_on_plone_version( plone_version, request, payload, changeset, changeset_long, timestamp ) return json.dumps({'message': 'Thanks! Plone Jenkins CI will run tests'})
def run_function_core_tests(request): """When we are called by GH we want to run the jenkins builds It's called for each push on the plone repo, so we look which tests needs to run for the given repository and branch: """ # bail out early if it's just a github check payload = json.loads(request.POST['payload']) if 'ref' not in payload: return json.dumps({'message': 'pong'}) # lots of variables repo_name = payload['repository']['name'] repo = payload['repository']['full_name'] branch = payload['ref'].split('/')[-1] # who pushed the commits? who = get_user(payload['pusher']) data = get_info(payload, repo, branch) timestamp = data[0] changeset = data[1] changeset_long = data[2] fake = data[3] skip = data[4] source_or_checkout = data[5] if not fake and not skip: request.registry.notify(NewCoreDevPush(payload, request)) # If it is a push to buildout.coredev, # update sources and checkouts and quit if repo == 'plone/buildout.coredev': logger.info('Commit: on coredev - do nothing') if source_or_checkout: get_sources_and_checkouts(request) return json.dumps( {'message': 'Thanks! Commit to coredev, nothing to do'} ) ## # It's not a commit to coredev repo ## # if it's a skip commit, log and done if skip: msg = 'Commit: skip CI - {0} - {1} do nothing' logger.info(msg.format(repo, branch)) return json.dumps({'message': 'Thanks! Skipping CI'}) # if the repo+branch are not in any plone version sources.cfg, # log and done plone_versions = plone_versions_targeted(repo, branch, request) if not plone_versions: # Error repo not in sources msg = 'Commit: not in sources - {0} - {1} do nothing' logger.info(msg.format(repo, branch)) return json.dumps( {'message': 'Thanks! Commits done on a branch, nothing to do'} ) ## # a commit on a branch that's part of a plone version ## checkouts = get_pickled_data(request.registry.settings['checkouts_file']) for plone_version in plone_versions: # if the repository is not on checkouts.cfg things could be broken # at a later point when it's added, warn about it!! if repo_name not in checkouts[plone_version]: request.registry.notify( CommitAndMissingCheckout( who, request, repo, branch, plone_version, payload['pusher']['email'] # duplicated, already on 'who' ) ) # commit to the plone version branch. This way jenkins will trigger a # build and will get the latest changes from the repository that # triggered this view commit_to_coredev( request, payload, plone_version, changeset, changeset_long, timestamp, ) return json.dumps( {'message': 'Thanks! Plone Jenkins CI will run tests'} )