import os import subprocess import sys import zipfile from third_party.python import colorlog, requests from third_party.python.absl import app, flags handler = colorlog.StreamHandler() handler.setFormatter(colorlog.ColoredFormatter('%(log_color)s%(levelname)s: %(message)s')) log = colorlog.getLogger(__name__) log.addHandler(handler) log.propagate = False # Needed to stop double logging?g flags.DEFINE_string('github_token', os.environ.get('GITHUB_TOKEN'), 'Github API token') flags.DEFINE_string('circleci_token', os.environ.get('CIRCLECI_TOKEN'), 'CircleCI API token') flags.DEFINE_string('signer', None, 'Release signer binary') flags.DEFINE_bool('dry_run', False, "Don't actually do the release, just print it.") flags.mark_flag_as_required('github_token') FLAGS = flags.FLAGS PRERELEASE_MESSAGE = """ This is a prerelease version of Please. Bugs and partially-finished features may abound. Caveat usor! """ class ReleaseGen:
#!/usr/bin/env python3 # # Script to generate a big tree of BUILD files to measure parsing performance. # Accordingly, it doesn't create any corresponding source files. import os import random import shutil import subprocess from math import log10 from third_party.python.absl import app, flags from third_party.python.progress.bar import Bar flags.DEFINE_string('plz', 'plz', 'Binary to run to invoke plz') flags.DEFINE_integer('size', 100000, 'Number of BUILD files to generate') flags.DEFINE_integer('seed', 42, 'Random seed') flags.DEFINE_string('root', 'tree', 'Directory to put all files under') flags.DEFINE_boolean('format', True, 'Autoformat all the generated files') flags.DEFINE_boolean('progress', True, 'Display animated progress bars') FLAGS = flags.FLAGS # List of 'representative' directory names of the kind of names programmers would use. DIRNAMES = [ 'src', 'main', 'cmd', 'tools', 'utils', 'common', 'query',
import json import os import subprocess import time from third_party.python import colorlog from third_party.python.absl import app, flags handler = colorlog.StreamHandler() handler.setFormatter( colorlog.ColoredFormatter('%(log_color)s%(levelname)s: %(message)s')) log = colorlog.getLogger(__name__) log.addHandler(handler) log.propagate = False # Needed to stop double logging? flags.DEFINE_string('plz', 'plz', 'Binary to run to invoke plz') flags.DEFINE_integer('num_threads', 10, 'Number of parallel threads to give plz') flags.DEFINE_string('output', 'results.json', 'File to write results to') flags.DEFINE_string('revision', 'unknown', 'Git revision') flags.DEFINE_integer('number', 5, 'Number of times to run test') flags.DEFINE_string('root', 'tree', 'Directory to run in') FLAGS = flags.FLAGS def plz() -> list: """Returns the plz invocation for a subprocess.""" return [ FLAGS.plz, '--repo_root', FLAGS.root,
import hashlib import json import logging import os import subprocess import sys import zipfile from third_party.python import colorlog, requests from third_party.python.absl import app, flags logging.root.handlers[0].setFormatter( colorlog.ColoredFormatter('%(log_color)s%(levelname)s: %(message)s')) flags.DEFINE_string('github_token', os.environ.get('GITHUB_TOKEN'), 'Github API token') flags.DEFINE_bool('dry_run', False, "Don't actually do the release, just print it.") flags.mark_flag_as_required('github_token') FLAGS = flags.FLAGS class ReleaseGen: def __init__(self, github_token: str, dry_run: bool = False): self.url = 'https://api.github.com' self.releases_url = self.url + '/repos/thought-machine/please-servers/releases' self.upload_url = self.releases_url.replace( 'api.', 'uploads.') + '/<id>/assets?name=' self.session = requests.Session() self.session.verify = '/etc/ssl/certs/ca-certificates.crt' if not dry_run:
import json import logging import os import re import pkgutil import subprocess import sys import tarfile from third_party.python import colorlog, requests from third_party.python.absl import app, flags logging.root.handlers[0].setFormatter( colorlog.ColoredFormatter('%(log_color)s%(levelname)s: %(message)s')) flags.DEFINE_string('github_token', None, 'Github API token') flags.DEFINE_bool('dry_run', False, "Don't actually do the release, just print it.") flags.DEFINE_string('version', None, 'Version to release (default is current)') flags.mark_flag_as_required('github_token') FLAGS = flags.FLAGS class BottleUploader: def __init__(self, github_token: str, dry_run: bool = False, version: str = ''): self.url = 'https://api.github.com' self.please_url = self.url + '/repos/thought-machine/please/releases/latest' self.releases_url = self.url + '/repos/thought-machine/homebrew-please/releases'
"""Script to create Github releases & generate release notes.""" import json import logging import os import subprocess import sys import zipfile from third_party.python import colorlog, requests from third_party.python.absl import app, flags logging.root.handlers[0].setFormatter( colorlog.ColoredFormatter('%(log_color)s%(levelname)s: %(message)s')) flags.DEFINE_string('github_token', None, 'Github API token') flags.DEFINE_string('signer', None, 'Release signer binary') flags.DEFINE_bool('dry_run', False, "Don't actually do the release, just print it.") flags.mark_flag_as_required('github_token') FLAGS = flags.FLAGS PRERELEASE_MESSAGE = """ This is a prerelease version of Please. Bugs and partially-finished features may abound. Caveat usor! """ class ReleaseGen: def __init__(self, github_token: str, dry_run: bool = False):