示例#1
0
def builds_set_current_cmd(args):
    to_set = None
    release = None
    if args['raw']:
        to_set = args['version']
    else:
        setting_latest = args['version'] == 'latest'
        release = find_latest_release(args['branch']) if setting_latest else find_release(int(args['version']))
        if not release:
            print("Unable to find version " + args['version'])
            if setting_latest and args['branch'] != '':
                print('Branch {} has no available versions (Bad branch/No image yet built)'.format(args['branch']))
        elif are_you_sure('change current version to {}'.format(release.key), args) and confirm_branch(release):
            print('Found release {}'.format(release))
            to_set = release.key
    if to_set is not None:
        log_new_build(args, to_set)
        if release and release.static_key:
            if not deploy_staticfiles(release):
                print("...aborted due to deployment failure!")
                sys.exit(1)
        else:
            old_deploy_staticfiles(args['branch'], to_set)
        set_current_key(args, to_set)
        if release:
            print("Marking as a release in sentry...")
            token = get_ssm_param("/compiler-explorer/sentryAuthToken")
            result = requests.post(
                f"https://sentry.io/api/0/organizations/compiler-explorer/releases/{release.version}/deploys/",
                data=dict(environment=args['env']),
                headers=dict(Authorization=f'Bearer {token}'))
            if not result.ok:
                raise RuntimeError(f"Failed to send to sentry: {result} {result.content}")
            print("...done", json.loads(result.content.decode()))
示例#2
0
    def conanproxy_login(self):
        url = f'{conanserver_url}/login'

        login_body = defaultdict(lambda: [])
        login_body['password'] = get_ssm_param('/compiler-explorer/conanpwd')

        request = requests.post(url, data = json.dumps(login_body), headers={"Content-Type": "application/json"})
        if not request.ok:
            self.logger.info(request.text)
            raise RuntimeError(f'Post failure for {url}: {request}')
        else:
            response = json.loads(request.content)
            self.conanserverproxy_token = response['token']
示例#3
0
文件: builds.py 项目: ojeda/infra
def builds_set_current(cfg: Config, branch: Optional[str], version: str,
                       raw: bool, confirm: bool):
    """Set the current version to VERSION for this environment.

    If VERSION is "latest" then the latest version (optionally filtered by --branch), is set.
    """
    if has_bouncelock_file(cfg):
        print(
            f"{cfg.env.value} is currently bounce locked. New versions can't be set until the lock is lifted"
        )
        sys.exit(1)
    to_set = None
    release = None
    if raw:
        to_set = version
    else:
        setting_latest = version == 'latest'
        release = find_latest_release(
            branch) if setting_latest else find_release(
                Version.from_string(version))
        if not release:
            print("Unable to find version " + version)
            if setting_latest and branch != '':
                print(
                    'Branch {} has no available versions (Bad branch/No image yet built)'
                    .format(branch))
        elif confirm:
            print(f'Found release {release}')
            to_set = release.key
        elif are_you_sure('change current version to {}'.format(release.key),
                          cfg) and confirm_branch(release.branch):
            print(f'Found release {release}')
            to_set = release.key
    if to_set is not None and release is not None:
        if (cfg.env.value != 'runner') and not runner_discoveryexists(
                cfg.env.value, release.version):
            if not confirm_action(
                    f'Compiler discovery has not run for {cfg.env.value}/{release.version}, are you sure you want to continue?'
            ):
                sys.exit(1)

        log_new_build(cfg, to_set)
        if release and release.static_key:
            if not deploy_staticfiles(release):
                print("...aborted due to deployment failure!")
                sys.exit(1)
        else:
            old_deploy_staticfiles(branch, to_set)
        set_current_key(cfg, to_set)
        if release:
            print("Marking as a release in sentry...")
            token = get_ssm_param("/compiler-explorer/sentryAuthToken")
            result = requests.post(
                f"https://sentry.io/api/0/organizations/compiler-explorer/releases/{release.version}/deploys/",
                data=dict(environment=cfg.env.value),
                headers=dict(Authorization=f'Bearer {token}'))
            if not result.ok:
                raise RuntimeError(
                    f"Failed to send to sentry: {result} {result.content.decode('utf-8')}"
                )
            print("...done", json.loads(result.content.decode()))