def test(): import github from mergify_engine import gh_pr from mergify_engine import utils utils.setup_logging() config.log() gh_pr.monkeypatch_github() parts = sys.argv[1].split("/") LOG.info("Getting repo %s ..." % sys.argv[1]) integration = github.GithubIntegration(config.INTEGRATION_ID, config.PRIVATE_KEY) installation_id = utils.get_installation_id(integration, parts[3]) token = integration.get_access_token(installation_id).token g = github.Github(token) user = g.get_user(parts[3]) repo = user.get_repo(parts[4]) LOG.info("Protecting repo %s branch %s ..." % (sys.argv[1], sys.argv[2])) rule = rules.get_branch_rule(repo, sys.argv[2]) configure_protection_if_needed(repo, sys.argv[2], rule)
def test(): from mergify_engine import gh_pr from mergify_engine import utils utils.setup_logging() config.log() gh_pr.monkeypatch_github() parts = sys.argv[1].split("/") LOG.info("Getting repo %s ..." % sys.argv[1]) if True: # With access_token got from oauth token = sys.argv[2] g = github.Github(token) user = g.get_user(parts[3]) repo = user.get_repo(parts[4]) pull = repo.get_pull(int(parts[6])) update_branch(pull, token) else: # With access_token got from integration integration = github.GithubIntegration(config.INTEGRATION_ID, config.PRIVATE_KEY) installation_id = utils.get_installation_id(integration, parts[3]) token = integration.get_access_token(installation_id).token update_branch(pull, "x-access-token:%s" % token)
def main(): utils.setup_logging() config.log() gh_pr.monkeypatch_github() if config.FLUSH_REDIS_ON_STARTUP: utils.get_redis().flushall() with rq.Connection(utils.get_redis()): worker = rq.Worker(['default']) worker.work()
def main(): # pragma: no cover utils.setup_logging() config.log() gh_pr.monkeypatch_github() r = utils.get_redis_for_rq() if config.FLUSH_REDIS_ON_STARTUP: r.flushall() with rq.Connection(r): worker = rq.Worker(['default']) if config.SENTRY_URL: client = raven.Client(config.SENTRY_URL, transport=HTTPTransport) register_sentry(client, worker) worker.work()
def main(): # pragma: no cover parser = argparse.ArgumentParser(description='Mergify RQ Worker.') parser.add_argument('--fqdn', help='FQDN of the node', default=utils.get_fqdn()) parser.add_argument("worker_id", type=int, help='Worker ID') args = parser.parse_args() utils.setup_logging() config.log() gh_pr.monkeypatch_github() MergifyWorker(args.fqdn, args.worker_id).work()
import requests.sessions import rq import testtools import vcr from mergify_engine import backports from mergify_engine import config from mergify_engine import engine from mergify_engine import gh_branch from mergify_engine import gh_pr from mergify_engine import gh_update_branch from mergify_engine import rules from mergify_engine import utils from mergify_engine import web gh_pr.monkeypatch_github() LOG = logging.getLogger(__name__) RECORD_MODE = os.getenv("MERGIFYENGINE_RECORD_MODE", "none") CASSETTE_LIBRARY_DIR_BASE = 'mergify_engine/tests/fixtures/cassettes' FAKE_DATA = "whatdataisthat" FAKE_HMAC = utils.compute_hmac(FAKE_DATA.encode("utf8")) CONFIG = """ rules: default: protection: required_status_checks: strict: True contexts: - continuous-integration/fake-ci