1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/tests/integration/targets/gitlab_merge_request/tasks/main.yml
patchback[bot] 4699568996
[PR #6605/9f47cdde backport][stable-7] New module: gitlab_merge_request.py (#6692)
New module: gitlab_merge_request.py (#6605)

* feat(gitlab_merge_request): initial module version

* feat(gitlab_merge_request): adding assignees & reviewers

* fix(gitlab_merge_request): sanity fixes

* chore(gitlab_merge_request): adding BOTMETA record

* chore(gitlab_merge_request): integration tests

* docs(gitlab_merge_request): updating modules documentation

* fix(gitlab_merge_request): proper module return values

* fix(gitlab_merge_request): remove duplicate target_branch query

* docs(gitlab_merge_request): apply improvements suggested from code review

Co-authored-by: Felix Fontein <felix@fontein.de>

* docs(gitlab_merge_request): updates to description and minor fixes based on code review

Co-authored-by: Felix Fontein <felix@fontein.de>

* chore(gitlab_merge_request): add aliases file for integration tests

* fix(gitlab_merge_request): use with syntax for IOErrors handling

Co-authored-by: Léo GATELLIER <26511053+lgatellier@users.noreply.github.com>

* fix(gitlab_merge_request): inverted message parameters

* refactor(gitlab_merge_request): use shared find_project method

* refactor(gitlab_merge_request): use username filter for user retrieval

* fix(gitlab_merge_request): handling of empty user search result

* test(gitlab_merge_request): extends integration tests suite for merge request changes

* chore(gitlab_merge_request): sanity validation & licensing fixes

* docs(gitlab_merge_request): formatting changes to documentation

Co-authored-by: Felix Fontein <felix@fontein.de>

* chore(gitlab_merge_request): licensing of test files fixed

Co-authored-by: Felix Fontein <felix@fontein.de>

* docs(gitlab_merge_request): extends description & adds code comments

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Léo GATELLIER <26511053+lgatellier@users.noreply.github.com>
(cherry picked from commit 9f47cdde32)

Co-authored-by: Ondrej Zvara <zvara.ondrej@gmail.com>
2023-06-15 08:42:19 +02:00

129 lines
4.3 KiB
YAML

---
####################################################################
# WARNING: These are designed specifically for Ansible tests #
# and should not be used as examples of how to write Ansible roles #
####################################################################
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
- name: Install required libs
pip:
name: python-gitlab
state: present
- block:
- name: Create {{ gitlab_project_name }}
gitlab_project:
api_url: "{{ gitlab_host }}"
validate_certs: true
api_token: "{{ gitlab_api_token }}"
name: "{{ gitlab_project_name }}"
group: "{{ gitlab_project_group }}"
default_branch: "{{ gitlab_target_branch }}"
initialize_with_readme: true
state: present
- name: Create branch {{ gitlab_source_branch }}
gitlab_branch:
api_url: "{{ gitlab_host }}"
api_token: "{{ gitlab_api_token }}"
project: "{{ gitlab_project_group }}/{{ gitlab_project_name }}"
branch: "{{ gitlab_source_branch }}"
ref_branch: "{{ gitlab_target_branch }}"
state: present
- name: Create Merge Request
gitlab_merge_request:
api_url: "{{ gitlab_host }}"
api_token: "{{ gitlab_api_token }}"
project: "{{ gitlab_project_group }}/{{ gitlab_project_name }}"
source_branch: "{{gitlab_source_branch}}"
target_branch: "{{gitlab_target_branch}}"
title: "Ansible test merge request"
description: "Test description"
labels: ""
state_filter: "opened"
assignee_ids: ""
reviewer_ids: ""
remove_source_branch: True
state: present
register: gitlab_merge_request_create
- name: Test Merge Request Created
assert:
that:
- gitlab_merge_request_create is changed
- name: Create Merge Request ( Idempotency test )
gitlab_merge_request:
api_url: "{{ gitlab_host }}"
api_token: "{{ gitlab_api_token }}"
project: "{{ gitlab_project_group }}/{{ gitlab_project_name }}"
source_branch: "{{gitlab_source_branch}}"
target_branch: "{{gitlab_target_branch}}"
title: "Ansible test merge request"
description: "Test description"
labels: ""
state_filter: "opened"
assignee_ids: ""
reviewer_ids: ""
remove_source_branch: True
state: present
register: gitlab_merge_request_create_idempotence
- name: Test module is idempotent
assert:
that:
- gitlab_merge_request_create_idempotence is not changed
- name: Update Merge Request Test
gitlab_merge_request:
api_url: "{{ gitlab_host }}"
api_token: "{{ gitlab_api_token }}"
project: "{{ gitlab_project_group }}/{{ gitlab_project_name }}"
source_branch: "{{gitlab_source_branch}}"
target_branch: "{{gitlab_target_branch}}"
title: "Ansible test merge request"
description_path: "{{gitlab_description_path}}"
labels: "{{ gitlab_labels }}"
state_filter: "opened"
assignee_ids: "{{ gitlab_assignee_ids }}"
reviewer_ids: ""
remove_source_branch: True
state: present
register: gitlab_merge_request_udpate
- name: Test merge request updated
assert:
that:
- gitlab_merge_request_udpate.mr.labels[0] == "{{ gitlab_labels }}"
- gitlab_merge_request_udpate.mr.assignees[0].username == "{{ gitlab_assignee_ids }}"
- "'### Description\n\nMerge Request test description' in gitlab_merge_request_udpate.mr.description"
- name: Delete Merge Request
gitlab_merge_request:
api_url: "{{ gitlab_host }}"
api_token: "{{ gitlab_api_token }}"
project: "{{ gitlab_project_group }}/{{ gitlab_project_name }}"
source_branch: "{{gitlab_source_branch}}"
target_branch: "{{gitlab_target_branch}}"
title: "Ansible test merge request"
state: absent
register: gitlab_merge_request_delete
- name: Test merge request is deleted
assert:
that:
- gitlab_merge_request_delete is changed
always:
- name: Clean up {{ gitlab_project_name }}
gitlab_project:
api_url: "{{ gitlab_host }}"
validate_certs: false
api_token: "{{ gitlab_api_token }}"
name: "{{ gitlab_project_name }}"
group: "{{ gitlab_project_group }}"
state: absent