Beispiel #1
0
def gitlab(request):
    gl = get_gitlab()

    create_group(GROUP_NAME)
    create_project_in_group(GROUP_NAME, PROJECT_NAME)
    create_readme_in_project(GROUP_AND_PROJECT_NAME)  # in master branch

    branches = [
        "protect_branch_but_allow_all",
        "protect_branch_and_disallow_all",
        "protect_branch_and_allow_merges",
        "protect_branch_and_allow_pushes",
        "protect_branch_and_allow_merges_access_levels",
        "protect_branch_and_allow_pushes_access_levels",
        "protect_branch",
    ]
    for branch in branches:
        gl.create_branch(GROUP_AND_PROJECT_NAME, branch, "master")

    def fin():
        # delete all created branches
        for branch_to_delete in branches:
            gl.delete_branch(GROUP_AND_PROJECT_NAME, branch_to_delete)

    request.addfinalizer(fin)
    return gl  # provide fixture value
def gitlab(request):
    gl = get_gitlab()

    create_group(GROUP_NAME)
    create_project_in_group(GROUP_NAME, PROJECT_NAME)
    create_readme_in_project(GROUP_AND_PROJECT_NAME)  # in main branch

    def fin():
        gl.delete_project(GROUP_AND_PROJECT_NAME)
        # TODO: find some smarter way to avoid 400 when trying to create project while it is still being deleted
        time.sleep(15)

    request.addfinalizer(fin)
    return gl  # provide fixture value
def gitlab(request):
    gl = get_gitlab()

    create_group(GROUP_NAME)
    create_project_in_group(GROUP_NAME, PROJECT_NAME)
    create_readme_in_project(GROUP_AND_PROJECT_NAME)  # in main branch

    delete_pipeline_schedules_from_project(GROUP_AND_PROJECT_NAME)

    another_branch = "scheduled/new-feature"
    gl.create_branch(GROUP_AND_PROJECT_NAME, another_branch, "main")

    gl.create_pipeline_schedule(
        GROUP_AND_PROJECT_NAME,
        "Existing schedule",
        "main",
        "0 * * * *",
        {"active": "true"},
    )
    gl.create_pipeline_schedule(
        GROUP_AND_PROJECT_NAME, "Existing schedule with vars", "main", "30 * * * *"
    )

    gl.create_pipeline_schedule(
        GROUP_AND_PROJECT_NAME, "Existing schedule to replace", "main", "30 1 * * *"
    )
    gl.create_pipeline_schedule(
        GROUP_AND_PROJECT_NAME,
        "Existing schedule to replace",
        another_branch,
        "30 2 * * *",
    )

    redundant_schedule = gl.create_pipeline_schedule(
        GROUP_AND_PROJECT_NAME, "Redundant schedule", "main", "0 * * * *"
    )
    gl.create_pipeline_schedule_variable(
        GROUP_AND_PROJECT_NAME, redundant_schedule["id"], "test_variable", "test_value"
    )

    def fin():
        # delete all created resources
        delete_pipeline_schedules_from_project(GROUP_AND_PROJECT_NAME)
        gl.delete_branch(GROUP_AND_PROJECT_NAME, another_branch)
        gl.delete_project(GROUP_AND_PROJECT_NAME)

    request.addfinalizer(fin)
    return gl  # provide fixture value
Beispiel #4
0
def gitlab(request):
    gl = get_gitlab()

    create_group(GROUP_NAME)
    create_project_in_group(GROUP_NAME, PROJECT_NAME)
    create_readme_in_project(GROUP_AND_PROJECT_NAME)  # in master branch
    branches_to_create = [
        'protected_branch1', 'protected_branch2', 'protected_branch3',
        'regular_branch1', 'regular_branch2'
    ]
    for branch in branches_to_create:
        gl.create_branch(GROUP_AND_PROJECT_NAME, branch, 'master')

    def fin():
        # delete all created branches
        for branch_to_delete in branches_to_create:
            gl.delete_branch(GROUP_AND_PROJECT_NAME, branch_to_delete)

    request.addfinalizer(fin)
    return gl  # provide fixture value
Beispiel #5
0
def gitlab(request):
    gl = get_gitlab()

    create_group(GROUP_NAME)
    create_project_in_group(GROUP_NAME, PROJECT_NAME)
    create_readme_in_project(GROUP_AND_PROJECT_NAME)  # in master branch

    branches = [
        "protect_branch_but_allow_all",
        "protect_branch_with_code_owner_approval_required",
        "protect_branch_and_disallow_all",
        "protect_branch_and_allow_merges",
        "protect_branch_and_allow_pushes",
        "protect_branch_and_allow_merges_access_levels",
        "protect_branch_and_allow_pushes_access_levels",
        "protect_branch",
    ]
    for branch in branches:
        gl.create_branch(GROUP_AND_PROJECT_NAME, branch, "master")

    # create_users(USER_BASE_NAME, 1)
    # add_users_to_group(GROUP_NAME, ["branches_user1"])
    # create_file_in_project(
    #     GROUP_AND_PROJECT_NAME,
    #     "protect_branch_with_code_owner_approval_required",
    #     "CODEOWNERS",
    #     "README.md @branches_user1",
    # )

    def fin():
        # delete all created branches
        for branch_to_delete in branches:
            gl.delete_branch(GROUP_AND_PROJECT_NAME, branch_to_delete)

    request.addfinalizer(fin)
    return gl  # provide fixture value