-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(nipa-update): Add to pipeline new kind of executor for NIPA
To handle NIPA update, after test completion we need to execute nipa-update script. Signed-off-by: Denys Fedoryshchenko <[email protected]>
- Loading branch information
1 parent
78cfcd7
commit 63521d2
Showing
2 changed files
with
91 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
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,68 @@ | ||
{# -*- mode: Python -*- -#} | ||
{# SPDX-License-Identifier: LGPL-2.1-or-later -#} | ||
|
||
{%- extends 'base/python.jinja2' %} | ||
|
||
{%- block python_imports %} | ||
{{ super() }} | ||
import json | ||
import subprocess | ||
{%- endblock %} | ||
|
||
{%- block python_local_imports %} | ||
{{ super() }} | ||
import kernelci.api.helper | ||
import kernelci.runtime | ||
{%- endblock %} | ||
|
||
{%- block python_globals %} | ||
{{ super() }} | ||
REVISION = {{ node.data.kernel_revision }} | ||
NODEID = "{{ node.id }}" | ||
API_NAME = "{{ api_config.name }}" | ||
{% endblock %} | ||
|
||
{% block python_job_constr -%} | ||
REVISION, NODEID, API_NAME, {{ super() }} | ||
{%- endblock %} | ||
|
||
{% block python_job -%} | ||
class Job(BaseJob): | ||
|
||
def __init__(self, revision, nodeid, api_name, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
self._revision = revision | ||
self._nodeid = nodeid | ||
self._api_name = api_name | ||
|
||
def _run(self, src_path): | ||
print(f"Executing nipa-update for node {self._nodeid}") | ||
api_helper = kernelci.api.helper.APIHelper(self._api) | ||
# TODO: Implement nipa-update | ||
jobnode =self._api.node.get(self._nodeid) | ||
# retrieve parent job to feed the nipa-update | ||
parent_job = jobnode.get('parent') | ||
if not parent_job: | ||
raise Exception(f"No parent job found for node {self._nodeid}") | ||
# temporary we get kernelci-nipa from git | ||
# TODO: Embed it into pipeline as a submodule | ||
nipa_path = "/tmp/kernelci-nipa" | ||
# if the path does not exist, clone the repository | ||
if not os.path.exists(nipa_path): | ||
subprocess.run(["git", "clone", "https://github.com/nuclearcat/kernelci-nipa.git", nipa_path]) | ||
# branch various-improvements | ||
subprocess.run(["git", "checkout", "various-improvements"], cwd=nipa_path) | ||
else: | ||
subprocess.run(["git", "pull"], cwd=nipa_path) | ||
# run the nipa-update | ||
args = ["/tmp/kernelci-nipa/nipa-results", "--id", parent_job] | ||
# if api_name is not production, add --staging | ||
if self._api_name != "production": | ||
args.append("--staging") | ||
r = subprocess.run(args, cwd=nipa_path) | ||
if r.returncode != 0: | ||
raise Exception(f"Failed to run nipa-update for node {self._nodeid}: {r.stderr}") | ||
# Upload results to the storage TODO | ||
|
||
return 'pass' | ||
{% endblock %} |