mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-08 22:30:04 -07:00
New module: gitlab_issue.py (#7539)
* feat(gitlab_issue): adds module for gitlab issues management * Apply suggestions from code review Co-authored-by: Felix Fontein <felix@fontein.de> * Apply suggestions from code review Co-authored-by: Felix Fontein <felix@fontein.de> * fix(gitlab_issue): assignee_ids and labels as lists * docs(gitlab_issue): fix missing element types * Apply suggestions from code review Co-authored-by: Léo GATELLIER <26511053+lgatellier@users.noreply.github.com> * chore(gitlab_issue): remove unnecessary parameter checks * chore(gitlab_issue): renaming milestone_id parameter to milestone_search --------- Co-authored-by: Felix Fontein <felix@fontein.de> Co-authored-by: Léo GATELLIER <26511053+lgatellier@users.noreply.github.com>
This commit is contained in:
parent
58cce27d45
commit
f4a87fdbcb
6 changed files with 590 additions and 0 deletions
6
tests/integration/targets/gitlab_issue/aliases
Normal file
6
tests/integration/targets/gitlab_issue/aliases
Normal file
|
@ -0,0 +1,6 @@
|
|||
# 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
|
||||
|
||||
gitlab/ci
|
||||
disabled
|
15
tests/integration/targets/gitlab_issue/defaults/main.yml
Normal file
15
tests/integration/targets/gitlab_issue/defaults/main.yml
Normal file
|
@ -0,0 +1,15 @@
|
|||
---
|
||||
# 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
|
||||
|
||||
gitlab_branch: ansible_test_branch
|
||||
gitlab_project_name: ansible_test_project
|
||||
gitlab_project_group: ansible_test_group
|
||||
gitlab_host: ansible_test_host
|
||||
gitlab_api_token: ansible_test_api_token
|
||||
gitlab_labels: ansible_test_label
|
||||
gitlab_milestone_search: ansible_test_milestone_search
|
||||
gitlab_milestone_group_id: ansible_test_milestone_group_id
|
||||
gitlab_assignee_ids: ansible_test_assignee_ids
|
||||
gitlab_description_path: ansible_test_description_path
|
|
@ -0,0 +1,9 @@
|
|||
<!--
|
||||
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
|
||||
-->
|
||||
|
||||
### Description
|
||||
|
||||
Issue test description
|
150
tests/integration/targets/gitlab_issue/tasks/main.yml
Normal file
150
tests/integration/targets/gitlab_issue/tasks/main.yml
Normal file
|
@ -0,0 +1,150 @@
|
|||
---
|
||||
####################################################################
|
||||
# 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 }} project
|
||||
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_branch }}"
|
||||
initialize_with_readme: true
|
||||
state: present
|
||||
|
||||
- name: Create Issue
|
||||
gitlab_issue:
|
||||
api_token: "{{ gitlab_api_token }}"
|
||||
api_url: "{{ gitlab_host }}"
|
||||
description: "Test description"
|
||||
project: "{{ gitlab_project_group }}/{{ gitlab_project_name }}"
|
||||
state: present
|
||||
title: "Ansible test issue"
|
||||
register: gitlab_issue_create
|
||||
|
||||
- name: Test Issue Created
|
||||
assert:
|
||||
that:
|
||||
- gitlab_issue_create is changed
|
||||
|
||||
- name: Create Issue ( Idempotency test )
|
||||
gitlab_issue:
|
||||
api_token: "{{ gitlab_api_token }}"
|
||||
api_url: "{{ gitlab_host }}"
|
||||
description: "Test description"
|
||||
project: "{{ gitlab_project_group }}/{{ gitlab_project_name }}"
|
||||
state: present
|
||||
title: "Ansible test issue"
|
||||
register: gitlab_issue_create_idempotence
|
||||
|
||||
- name: Test Create Issue is Idempotent
|
||||
assert:
|
||||
that:
|
||||
- gitlab_issue_create_idempotence is not changed
|
||||
|
||||
- name: Update Issue Test ( Additions )
|
||||
gitlab_issue:
|
||||
api_token: "{{ gitlab_api_token }}"
|
||||
api_url: "{{ gitlab_host }}"
|
||||
assignee_ids: "{{ gitlab_assignee_ids }}"
|
||||
description_path: "{{ gitlab_description_path }}"
|
||||
labels: "{{ gitlab_labels }}"
|
||||
milestone_search: "{{ gitlab_milestone_search }}"
|
||||
milestone_group_id: "{{ gitlab_milestone_group_id }}"
|
||||
project: "{{ gitlab_project_group }}/{{ gitlab_project_name }}"
|
||||
state: present
|
||||
title: "Ansible test issue"
|
||||
register: gitlab_issue_update_additions
|
||||
|
||||
- name: Test Issue Updated ( Additions )
|
||||
assert:
|
||||
that:
|
||||
- gitlab_issue_update_additions.issue.labels[0] == "{{ gitlab_labels[0] }}"
|
||||
- gitlab_issue_update_additions.issue.assignees[0].username == "{{ gitlab_assignee_ids[0] }}"
|
||||
- "'### Description\n\nIssue test description' in gitlab_issue_update_additions.issue.description"
|
||||
- gitlab_issue_update_additions.issue.milestone.title == "{{ gitlab_milestone_search }}"
|
||||
|
||||
- name: Update Issue Test ( Persistence )
|
||||
gitlab_issue:
|
||||
api_token: "{{ gitlab_api_token }}"
|
||||
api_url: "{{ gitlab_host }}"
|
||||
description_path: "{{ gitlab_description_path }}"
|
||||
milestone_search: "{{ gitlab_milestone_search }}"
|
||||
milestone_group_id: "{{ gitlab_milestone_group_id }}"
|
||||
project: "{{ gitlab_project_group }}/{{ gitlab_project_name }}"
|
||||
state: present
|
||||
title: "Ansible test issue"
|
||||
register: gitlab_issue_update_persistence
|
||||
|
||||
- name: Test issue Not Updated ( Persistence )
|
||||
assert:
|
||||
that:
|
||||
- gitlab_issue_update_persistence.issue.labels[0] == "{{ gitlab_labels[0] }}"
|
||||
- gitlab_issue_update_persistence.issue.assignees[0].username == "{{ gitlab_assignee_ids[0] }}"
|
||||
|
||||
- name: Update Issue Test ( Removals )
|
||||
gitlab_issue:
|
||||
api_token: "{{ gitlab_api_token }}"
|
||||
api_url: "{{ gitlab_host }}"
|
||||
assignee_ids: []
|
||||
description_path: "{{ gitlab_description_path }}"
|
||||
labels: []
|
||||
milestone_search: ""
|
||||
milestone_group_id: ""
|
||||
project: "{{ gitlab_project_group }}/{{ gitlab_project_name }}"
|
||||
state: present
|
||||
title: "Ansible test issue"
|
||||
register: gitlab_issue_update_removal
|
||||
|
||||
- name: Test issue updated
|
||||
assert:
|
||||
that:
|
||||
- gitlab_issue_update_removal.issue.labels == []
|
||||
- gitlab_issue_update_removal.issue.assignees == []
|
||||
- gitlab_issue_update_removal.issue.milestone == None
|
||||
|
||||
- name: Delete Issue
|
||||
gitlab_issue:
|
||||
api_url: "{{ gitlab_host }}"
|
||||
api_token: "{{ gitlab_api_token }}"
|
||||
project: "{{ gitlab_project_group }}/{{ gitlab_project_name }}"
|
||||
title: "Ansible test issue"
|
||||
state: absent
|
||||
register: gitlab_issue_delete
|
||||
|
||||
- name: Test issue is deleted
|
||||
assert:
|
||||
that:
|
||||
- gitlab_issue_delete is changed
|
||||
|
||||
always:
|
||||
- name: Delete Issue
|
||||
gitlab_issue:
|
||||
api_url: "{{ gitlab_host }}"
|
||||
api_token: "{{ gitlab_api_token }}"
|
||||
project: "{{ gitlab_project_group }}/{{ gitlab_project_name }}"
|
||||
title: "Ansible test issue"
|
||||
state_filter: "opened"
|
||||
state: absent
|
||||
register: gitlab_issue_delete
|
||||
- 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
|
Loading…
Add table
Add a link
Reference in a new issue