-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Arisu Tachibana <[email protected]>
- Loading branch information
0 parents
commit d0946c8
Showing
9 changed files
with
232 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.kci-dev.toml | ||
__pycache__/ | ||
poetry.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[connection] | ||
host="https://127.0.0.1" | ||
token="example" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# kci-dev | ||
|
||
Stand alone tool for Linux Kernel developers and maintainers that can test local Linux Kernel commits or patch (*.mbox, *.patch) on a enabled KernelCI server | ||
|
||
## Quickstart | ||
|
||
```sh | ||
poetry install | ||
poetry run kci-dev | ||
``` | ||
|
||
or | ||
|
||
```sh | ||
python kci-dev/kci-dev.py | ||
``` | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
import click | ||
from subcommands import commit | ||
from subcommands import patch | ||
|
||
|
||
@click.group( | ||
help="Stand alone tool for Linux Kernel developers and maintainers that can test local Linux Kernel changes on a enabled KernelCI server" | ||
) | ||
@click.version_option("0.0.1", prog_name="kci-dev") | ||
def cli(): | ||
pass | ||
|
||
|
||
def run(): | ||
cli.add_command(commit.commit) | ||
cli.add_command(patch.patch) | ||
cli() | ||
|
||
|
||
if __name__ == "__main__": | ||
run() |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
import click | ||
import toml | ||
import requests | ||
import json | ||
from git import Repo | ||
|
||
|
||
def api_connection(host): | ||
click.secho("api connect: " + host, fg="green") | ||
return host | ||
|
||
|
||
def find_diff(path, branch, repository): | ||
repo = Repo(path) | ||
assert not repo.bare | ||
hcommit = repo.iter_commits("origin/master.." + branch) | ||
commits = [] | ||
for i in hcommit: | ||
commits.append(repo.git.show(i)) | ||
return commits | ||
|
||
|
||
def send_build(url, patch, branch, treeurl, token): | ||
headers = { | ||
"Content-Type": "application/json; charset=utf-8", | ||
"Authorization": "Bearer {}".format(token), | ||
} | ||
values = { | ||
"treeurl": treeurl, | ||
"branch": branch, | ||
"commit": "example", | ||
"kbuildname": "example", | ||
"testname": "example", | ||
} | ||
response = requests.post(url, headers=headers, files={"patch": patch}, data=values) | ||
click.secho(response.status_code, fg="green") | ||
click.secho(response.json(), fg="green") | ||
|
||
|
||
def load_toml(settings): | ||
with open(settings) as fp: | ||
config = toml.load(fp) | ||
return config | ||
|
||
|
||
@click.command(help="Test commits from a local Kernel repository") | ||
@click.option( | ||
"--repository", | ||
default="mainline", | ||
help="define the kernel upstream repository where to test local changes", | ||
) | ||
@click.option("--branch", default="master", help="define the repository branch") | ||
@click.option( | ||
"--private", | ||
default=False, | ||
is_flag=True, | ||
help="define if the test results will be published", | ||
) | ||
@click.option( | ||
"--path", | ||
default=".", | ||
help="define the directory of the local tree with local changes", | ||
) | ||
@click.option("--settings", default=".kci-dev.toml", help="path of toml setting file") | ||
def commit(repository, branch, private, path, settings): | ||
config = load_toml(settings) | ||
url = api_connection(config["connection"]["host"]) | ||
diff = find_diff(path, branch, repository) | ||
send_build(url, diff, branch, repository, config["connection"]["token"]) | ||
|
||
|
||
if __name__ == "__main__": | ||
main_kcidev() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
import click | ||
import toml | ||
import requests | ||
import json | ||
from git import Repo | ||
|
||
|
||
def api_connection(host): | ||
click.secho("api connect: " + host, fg="green") | ||
return host | ||
|
||
|
||
def send_build(url, patch, branch, treeurl, token): | ||
headers = { | ||
"Content-Type": "application/json; charset=utf-8", | ||
"Authorization": "Bearer {}".format(token), | ||
} | ||
values = { | ||
"treeurl": treeurl, | ||
"branch": branch, | ||
"commit": "example", | ||
"kbuildname": "example", | ||
"testname": "example", | ||
} | ||
response = requests.post(url, headers=headers, files={"patch": patch}, data=values) | ||
click.secho(response.status_code, fg="green") | ||
click.secho(response.json(), fg="green") | ||
|
||
|
||
def load_toml(settings): | ||
with open(settings) as fp: | ||
config = toml.load(fp) | ||
return config | ||
|
||
|
||
@click.command(help="Test a patch or a mbox file") | ||
@click.option( | ||
"--repository", | ||
default="mainline", | ||
help="define the kernel upstream repository where to test local changes", | ||
) | ||
@click.option("--branch", default="master", help="define the repository branch") | ||
@click.option( | ||
"--private", | ||
default=False, | ||
is_flag=True, | ||
help="define if the test results will be published", | ||
) | ||
@click.option("--patch", required=True, help="mbox or patch file path") | ||
@click.option("--settings", default=".kci-dev.toml", help="path of toml setting file") | ||
def patch(repository, branch, private, patch, settings): | ||
config = load_toml(settings) | ||
url = api_connection(config["connection"]["host"]) | ||
patch = open(patch, "rb") | ||
send_build(url, patch, branch, repository, config["connection"]["token"]) | ||
|
||
|
||
if __name__ == "__main__": | ||
main_kcidev() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
[tool.poetry] | ||
name = "kci-dev" | ||
version = "0.0.1" | ||
description = "Stand alone tool for Linux Kernel developers and maintainers that can test local Linux Kernel changes on a enabled KernelCI server" | ||
authors = ["Arisu Tachibana <[email protected]>"] | ||
license = "LGPL-2.1-or-later" | ||
readme = "README.md" | ||
packages = [ | ||
{include = "kci-dev"}, | ||
{include = "subcommands", from="kci-dev"}, | ||
] | ||
repository = "https://github.com/kernelci/kci-dev" | ||
classifiers = [ | ||
'Development Status :: 1 - Planning', | ||
'Environment :: Console', | ||
'Intended Audience :: Developers', | ||
'Operating System :: OS Independent', | ||
'Topic :: Software Development', | ||
'Topic :: Software Development :: Libraries', | ||
'Programming Language :: Python', | ||
'Programming Language :: Python :: 3', | ||
'Programming Language :: Python :: 3.8', | ||
'Programming Language :: Python :: 3.9', | ||
'Programming Language :: Python :: 3.10', | ||
'Programming Language :: Python :: Implementation :: CPython', | ||
'Programming Language :: Python :: Implementation :: PyPy' | ||
] | ||
|
||
[tool.poetry.dependencies] | ||
python = "^3.12" | ||
click = "^8.1.7" | ||
requests = "^2.32.3" | ||
toml = "^0.10.2" | ||
gitpython = "^3.1.43" | ||
|
||
[tool.poetry.scripts] | ||
kci-dev = 'kci-dev.kci-dev:run' | ||
|
||
[tool.poetry.urls] | ||
"Issue Tracker" = "https://github.com/kernelci/kci-dev/issues" | ||
|
||
[tool.poetry.group.ci.dependencies] | ||
black = "^24.8.0" | ||
|
||
[build-system] | ||
requires = ["poetry-core"] | ||
build-backend = "poetry.core.masonry.api" |