# The master toctree document. master_doc = 'index' # General information about the project. project = 'treelite' copyright = '2017, DMLC. All rights reserved.' # pylint: disable=W0622 author = 'DMLC developers' # Read version info with open('../VERSION', 'r') as f: VERSION = f.readlines()[0] version = VERSION release = VERSION git_tag = str(git.tag('-l', '--points-at', 'HEAD')).rstrip('\n') git_commit = str(git('rev-parse', '--short', 'HEAD')).rstrip('\n') if git_tag: # tag exists intro_landing_release = 'You are currently browsing the documentation of ' +\ 'a stable version of treelite: **{}**.'.format(git_tag) nav_ver = git_tag else: # tag does not exist; part of "latest" intro_landing_release = 'You are currently browsing the documentation of ' +\ 'a development version of treelite: '+\ 'commit **{}**.'.format(git_commit) nav_ver = 'dev, commit {}'.format(git_commit) # Make dropdown menu for version selection with open('_templates/logo-text.html', 'w') as f: f.write(r""" <a href="{{ homepage() }}" class="text-logo">
def _tag_stable_forks(layer_list, charm_list, k8s_version, bundle_rev, filter_by_tag, bugfix, dry_run): """Tags stable forks to a certain bundle revision for a k8s version layer_list: YAML spec containing git repos and their upstream/downstream properties bundle_rev: bundle revision to tag for a particular version of k8s git tag (ie. ck-{bundle_rev}), this would mean we tagged current stable branches for 1.14 with the latest charmed kubernetes(ck) bundle rev of {bundle_rev} TODO: Switch to different merge strategy git checkout master git checkout -b staging git merge stable -s ours git checkout stable git reset staging """ layer_list = yaml.safe_load(Path(layer_list).read_text(encoding="utf8")) charm_list = yaml.safe_load(Path(charm_list).read_text(encoding="utf8")) new_env = os.environ.copy() for layer_map in layer_list + charm_list: for layer_name, repos in layer_map.items(): tags = repos.get("tags", None) if tags: if not any(match in filter_by_tag for match in tags): continue downstream = repos["downstream"] if bugfix: tag = f"{k8s_version}+{bundle_rev}" else: tag = f"ck-{k8s_version}-{bundle_rev}" if not repos.get("needs_tagging", True): log.info(f"Skipping {layer_name} :: does not require tagging") continue log.info(f"Tagging {layer_name} ({tag}) :: {repos['downstream']}") if not dry_run: downstream = f"https://{new_env['CDKBOT_GH_USR']}:{new_env['CDKBOT_GH_PSW']}@github.com/{downstream}" identifier = str(uuid.uuid4()) os.makedirs(identifier) for line in git.clone(downstream, identifier, _iter=True): log.info(line) git.config("user.email", "*****@*****.**", _cwd=identifier) git.config("user.name", "cdkbot", _cwd=identifier) git.config("--global", "push.default", "simple") git.checkout("stable", _cwd=identifier) try: for line in git.tag("--force", tag, _cwd=identifier, _iter=True, _bg_exc=False): log.info(line) for line in git.push( "--force", "origin", tag, _cwd=identifier, _bg_exc=False, _iter=True, ): log.info(line) except sh.ErrorReturnCode as error: log.info( f"Problem tagging: {error.stderr.decode().strip()}, will skip for now.." )
def sync_tags(self, repo, bitbucket_account_id, bitbucket_access_token, github_account_id, github_access_token): # Everytime, tags are fetched from remote (bitbucket) and then pushed to github repo_name = repo['name'] prefixed_repo_name = self.prefix + repo_name github_link = repo['github_link'] bitbucket_link = repo['bitbucket_link'] # Use this instead of setting the authenticated link as a new remote. # Remote links get stored in git config github_link_domain = github_link.split("//")[1] authenticated_github_link = f"https://{github_account_id}:{github_access_token}@{github_link_domain}" bitbucket_link_domain = bitbucket_link.split("//")[1] authenticated_bitbucket_link = f"https://{bitbucket_account_id}:{bitbucket_access_token}@{bitbucket_link_domain}" git.remote('set-url', 'origin', bitbucket_link) self.log.debug("Syncing Tags. Set origin to BitBucket", repo_name=repo_name, bitbucket_link=bitbucket_link) # Fetch tags from origin (bitbucket) self.log.info("Fetching refs (tags) from origin", repo_name=repo_name) # git.fetch('origin') git.fetch(authenticated_bitbucket_link) self.log.debug("Fetched refs (tags) from BitBucket", result="SUCCESS", repo_name=repo_name) # List all tags tags = git.tag().split('\n') tags = [tag.lstrip().rstrip() for tag in tags if tag] success_tags = [] failed_tags = [] # Set origin to github # git.remote('set-url', 'origin', github_link) self.log.debug("Syncing tags. Set origin to Github", repo_name=prefixed_repo_name, repo_prefix=self.prefix, github_link=github_link) # Push each tag individually, log error if any fails and continue to next tag for tag_name in tags: self.log.info("Syncing tag for repository", repo_name=repo_name, tag_name=tag_name) try: tag_refspec = f"refs/tags/{tag_name}:refs/tags/{tag_name}" git.push(authenticated_github_link, tag_refspec) self.log.debug("Pushed tag for repository", result="SUCCESS", repo_name=prefixed_repo_name, repo_prefix=self.prefix, tag_name=tag_name) success_tags.append(tag_name) except ErrorReturnCode as e: # Redact or remove the access token before logging stderr = utils.StringUtils.redact_error( e.stderr, github_access_token, "<ACCESS-TOKEN>") self.log.error("Failed to push tag to github", result="FAILED", repo_name=prefixed_repo_name, repo_prefix=self.prefix, tag_name=tag_name, exit_code=e.exit_code, stderr=stderr) failed_tags.append(tag_name) continue tags_sync_success = set(tags) == set(success_tags) return tags_sync_success, tags, failed_tags