Commit 6fe40276 authored by Nicolas Gelot's avatar Nicolas Gelot
Browse files

Initial commit

parents
Pipeline #146431 failed with stages
in 59 seconds
stages:
- build
- deploy
default:
image: python:3.10-slim
before_script:
- apt-get update
- apt-get install -y git
- pip install flit==3.4.0
check:
stage: build
script:
- flit install --deps develop
- black --check .
- flake8 .
- isort --check .
package:
stage: build
script:
- flit build
publish:
stage: deploy
variables:
FLIT_USERNAME: gitlab-ci-token
FLIT_PASSWORD: ${CI_JOB_TOKEN}
FLIT_INDEX_URL: ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi
script:
- flit publish
# Python library to extend Kiwi feature
Kiwi TCMS Gitlab plugin customizes the creation of Gitlab issue to follow the
E Foundation issue [template](https://gitlab.e.foundation/e/backlog/-/blob/master/.gitlab/issue_templates/issue-template-bug.md).
## Install
First install the python package
pip install .
### Setup gitlab tracker
Update the Kiwi settings like below
```python
EXTERNAL_BUG_TRACKERS += ["kiwi_efoundation_extras.issuetracker.Gitlab"]
```
Then from the kiwi admin page path `<domain>/admin/testcases/bugsystem/`, you can
setup the installed tracker.
You can also refer to the Kiwi documentation about [customization](https://kiwitcms.org/blog/tags/customization/)
from tcms.core.contrib.linkreference.models import LinkReference
from tcms.issuetracker import types
class Gitlab(types.Gitlab):
def report_issue_from_testexecution(self, execution, user):
repo_id = self.it_class.repo_id(self.bug_system)
project = self.rpc.projects.get(repo_id)
new_issue = project.issues.create(
{
"title": f"Failed test: {execution.case.summary}",
"description": self._report_comment(execution),
}
)
# and also add a link reference that will be shown in the UI
LinkReference.objects.get_or_create(
execution=execution,
url=new_issue.attributes["web_url"],
is_defect=True,
)
return new_issue.attributes["web_url"]
def fetch_username(self, execution):
"""Try to match kiwi and gitlab username"""
for attr in ["username", "email"]:
username = getattr(execution.assignee, attr)
users = self.rpc.users.list(search=username)
if len(users) == 1:
return users[0].username
return None
def _report_comment(self, execution):
"""
Returns the comment which is used in the original defect report.
"""
username = self.fetch_username(execution)
username = f"@{username}" if username else "unkown"
comment = f"""
- /e/ version: {execution.build.name}
- Device model(s):
- Device rooted: yes/no
## Summary
Filed from execution {execution.get_full_url()} and reported by {username}
## The problem
**Steps to reproduce**
Run the test case [{execution.case.summary}]({execution.case.get_full_url()})
**What is the current behavior?**
This test case fails with build {execution.build.name}
**What is the expected correct behavior?**
<What you should see instead>
## Technical informations
**Relevant logs (`adb logcat`)**
<Paste any relevant logs in the codeblock bellow>
```
```
**Relevant screenshots**
<Screenshots of the problem>
## Solutions
**Workaround**
<To get the feature working or at least to make the device usable>
**Possible fixes**
<Any idea to fix the issue or a link to the line of code that might be the cause for this problem>
/label ~Bug
""" # noqa: E501
return comment
[build-system]
requires = ["flit_core >=3.2,<4"]
build-backend = "flit_core.buildapi"
[project]
name = "kiwi_efoundation_extras"
version = "0.1"
description = "E Foundation Python library to extend Kiwi features"
authors = [
{name = "Nicolas Gelot", email = "nicolas.gelot@e.email"},
]
readme = "README.md"
classifiers = [
"Environment :: Console",
"Intended Audience :: Developers",
"Intended Audience :: System Administrators",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Operating System :: POSIX",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Topic :: Software Development",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Software Development :: Quality Assurance",
"Topic :: Software Development :: Testing",
"Topic :: Software Development :: Testing :: Acceptance"
]
requires-python = ">=3.8"
dependencies = [
"kiwitcms >= 10.4",
]
[project.optional-dependencies]
check = [
"flake8 == 4.0.1",
"black == 21.10b0",
"isort == 5.10.1",
]
[project.urls]
Source = "https://gitlab.e.foundation/e/infra/kiwi/kiwi_efoundation_extras"
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment