Exemplo n.º 1
0
def run_workflow(base_url, org, repo):
    """Manually start the tests.yml workflow of a repository."""
    result = call('gh', 'workflow', 'run', 'tests.yml', '-R', f'{org}/{repo}')
    if result.returncode != 0:
        print('To enable manually starting workflows clone the repository'
              ' and run meta/config/config-package.py on it.')
        print('Command to clone:')
        print(f'git clone {base_url}/{repo}.git')
        return False
    return True
Exemplo n.º 2
0
    help='path to the packages.txt; script is called on each repository listed'
    ' inside',
    metavar='packages.txt')
parser.add_argument(
    'clones',
    type=path_factory('clones', is_dir=True),
    help='path to the directory where the clones of the repositories are'
    ' stored')

# idea from https://stackoverflow.com/a/37367814/8531312
args, sub_args = parser.parse_known_args()
packages = list_packages(args.packages_txt)

for package in packages:
    print(f'*** Running {args.script.name} on {package} ***')
    if (args.clones / package).exists():
        with change_dir(args.clones / package):
            print('Updating existing checkout …')
            call('git', 'restore', '.')
            call('git', 'checkout', 'master')
            call('git', 'pull')
    else:
        with change_dir(args.clones):
            print('Cloning repository …')
            call('git', 'clone',
                 f'https://github.com/zopefoundation/{package}')

    call_args = [sys.executable, args.script, args.clones / package]
    call_args.extend(sub_args)
    call(*call_args)
Exemplo n.º 3
0
branch_name = 'covert.meta.cfg-to-.meta.toml'
with change_dir(path) as cwd:
    with open('.meta.toml', 'w') as meta_f:
        meta_f.write(
            '# Generated from:\n'
            '# https://github.com/zopefoundation/meta/tree/master/config/'
            f'{src["template"]}\n')
        toml.dump(
            dest, meta_f,
            TomlArraySeparatorEncoderWithNewline(separator=',\n   ',
                                                 indent_first_line=True))

    branches = call('git',
                    'branch',
                    '--format',
                    '%(refname:short)',
                    capture_output=True).stdout.splitlines()
    if branch_name in branches:
        call('git', 'checkout', branch_name)
        updating = True
    else:
        call('git', 'checkout', '-b', branch_name)
        updating = False
    call('git', 'rm', '.meta.cfg')
    call('git', 'add', '.meta.toml')
    call('git', 'commit', '-m', 'Switching from .meta.cfg to .meta.toml.')
    config_package_args = [
        sys.executable,
        'config-package.py',
        path,
Exemplo n.º 4
0
    print(f'{path.name} is already configured for this config type, updating.')
else:
    print(f'{path.name} is not yet configured for this config type, adding.')
    with open(config_type_path / 'packages.txt', 'a') as f:
        f.write(f'{path.name}\n')

jinja_env = jinja2.Environment(
    loader=jinja2.FileSystemLoader([config_type_path, default_path]),
    variable_start_string='%(',
    variable_end_string=')s',
    keep_trailing_newline=True,
    trim_blocks=True,
    lstrip_blocks=True,
)

meta_cfg['meta']['commit-id'] = call(
    'git', 'log', '-n1', '--format=format:%H', capture_output=True).stdout
with_appveyor = meta_cfg['python'].get(
    'with-appveyor', False) or args.with_appveyor
meta_cfg['python']['with-appveyor'] = with_appveyor
with_pypy = meta_cfg['python'].get('with-pypy', False) or args.with_pypy
meta_cfg['python']['with-pypy'] = with_pypy
if args.with_legacy_python is None:
    with_legacy_python = meta_cfg['python'].get('with-legacy-python', True)
else:
    with_legacy_python = args.with_legacy_python
meta_cfg['python']['with-legacy-python'] = with_legacy_python
with_docs = meta_cfg['python'].get('with-docs', False) or args.with_docs
meta_cfg['python']['with-docs'] = with_docs
with_sphinx_doctests = meta_cfg['python'].get(
    'with-sphinx-doctests', False) or args.with_sphinx_doctests
meta_cfg['python']['with-sphinx-doctests'] = with_sphinx_doctests
Exemplo n.º 5
0
    print(f'{path.name} is not yet configured for this config type, adding.')
    with open(config_type_path / 'packages.txt', 'a') as f:
        f.write(f'{path.name}\n')

jinja_env = jinja2.Environment(
    loader=jinja2.FileSystemLoader([config_type_path, default_path]),
    variable_start_string='%(',
    variable_end_string=')s',
    keep_trailing_newline=True,
    trim_blocks=True,
    lstrip_blocks=True,
)

meta_cfg['meta']['commit-id'] = call('git',
                                     'log',
                                     '-n1',
                                     '--format=format:%H',
                                     capture_output=True).stdout
with_appveyor = meta_cfg['python'].get('with-appveyor',
                                       False) or args.with_appveyor
meta_cfg['python']['with-appveyor'] = with_appveyor
with_windows = meta_cfg['python'].get('with-windows',
                                      False) or args.with_windows
meta_cfg['python']['with-windows'] = with_windows
with_pypy = meta_cfg['python'].get('with-pypy', False) or args.with_pypy
meta_cfg['python']['with-pypy'] = with_pypy
with_future_python = (meta_cfg['python'].get('with-future-python', False)
                      or args.with_future_python)
meta_cfg['python']['with-future-python'] = with_future_python
if args.with_legacy_python is None:
    with_legacy_python = meta_cfg['python'].get('with-legacy-python', True)
Exemplo n.º 6
0
    """Manually start the tests.yml workflow of a repository."""
    result = call('gh', 'workflow', 'run', 'tests.yml', '-R', f'{org}/{repo}')
    if result.returncode != 0:
        print('To enable manually starting workflows clone the repository'
              ' and run meta/config/config-package.py on it.')
        print('Command to clone:')
        print(f'git clone {base_url}/{repo}.git')
        return False
    return True


for repo in repos:
    print(repo)
    wfs = call('gh',
               'workflow',
               'list',
               '--all',
               '-R',
               f'{org}/{repo}',
               capture_output=True).stdout
    test_line = [x for x in wfs.splitlines() if x.startswith('test')][0]
    if 'disabled_inactivity' not in test_line:
        print('    ☑️  already enabled')
        if args.force_run:
            run_workflow(base_url, org, repo)
        continue
    test_id = test_line.split()[-1]
    call('gh', 'workflow', 'enable', test_id, '-R', f'{org}/{repo}')
    if run_workflow(base_url, org, repo):
        print('    ✅ enabled')