Skip to content

Commit

Permalink
Merge pull request #4 from nuclearcat/many-changes
Browse files Browse the repository at this point in the history
feat(all): Add global parameters
  • Loading branch information
aliceinwire authored Sep 11, 2024
2 parents c5f3f32 + ee9e7be commit 3e74d19
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 22 deletions.
8 changes: 6 additions & 2 deletions kci-dev/kci-dev.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import click
from libs.common import *
from subcommands import commit, 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():
@click.option("--settings", default=".kci-dev.toml", help="path of toml setting file")
@click.pass_context
def cli(ctx, settings):
ctx.obj = {"CFG": load_toml(settings)}
pass


Expand Down
Empty file added kci-dev/libs/__init__.py
Empty file.
10 changes: 10 additions & 0 deletions kci-dev/libs/common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import toml


def load_toml(settings):
with open(settings) as fp:
config = toml.load(fp)
return config
14 changes: 4 additions & 10 deletions kci-dev/subcommands/commit.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import json
Expand Down Expand Up @@ -41,12 +41,6 @@ def send_build(url, patch, branch, treeurl, token):
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",
Expand All @@ -65,9 +59,9 @@ def load_toml(settings):
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)
@click.pass_context
def commit(ctx, repository, branch, private, path):
config = ctx.obj.get("CFG")
url = api_connection(config["connection"]["host"])
diff = find_diff(path, branch, repository)
send_build(url, diff, branch, repository, config["connection"]["token"])
Expand Down
14 changes: 4 additions & 10 deletions kci-dev/subcommands/patch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import json
Expand Down Expand Up @@ -31,12 +31,6 @@ def send_build(url, patch, branch, treeurl, token):
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",
Expand All @@ -51,9 +45,9 @@ def load_toml(settings):
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)
@click.pass_context
def patch(ctx, repository, branch, private, patch):
config = ctx.obj.get("CFG")
url = api_connection(config["connection"]["host"])
patch = open(patch, "rb")
send_build(url, patch, branch, repository, config["connection"]["token"])
Expand Down

0 comments on commit 3e74d19

Please sign in to comment.