diff --git a/docs/source/writingtasks.rst b/docs/source/writingtasks.rst --- a/docs/source/writingtasks.rst +++ b/docs/source/writingtasks.rst @@ -10,19 +10,6 @@ To learn more about what can be done with taskotron, see :ref:`what-can-i-do-with-taskotron`. -.. warning:: - - Taskotron is still **very** young. At the moment, this document is both the - direction that we want to take in the near future and features that currently - exist in libtaskotron. - - If you follow this tutorial, be aware that things will be changing. Do not - expect libtaskotron to have a stable API yet and be aware that the interfaces - may change drastically with little notice. - - Once the interfaces stabilize a bit more, this warning will be edited or - removed. - In order to write tasks, you must :ref:`install-libtaskotron` on your local machine if you aren't running from git. @@ -132,7 +119,7 @@ - name: download bodhi update bodhi: action: download - bodhi_id: ${bodhi_id} + update_id: ${bodhi_id} arch: ${arch} export: bodhi_downloads @@ -159,27 +146,30 @@ We can execute this new task using:: -$ python runtask.py -i foo-1.2-3.fc99 -t bodhi_id -a x86_64 ../task-mytask/mytask.yml +$ python runtask.py -i FEDORA-2016-8760e32d9b -t bodhi_id -a x86_64 ../task-mytask/mytask.yml The output from this task should end with:: - Running mytask on foo-1.2-3.fc99.x86_64.rpm - - [libtaskotron:logger.py:34] 2014-05-14 21:30:30 CRITICAL Traceback (most recent call last): - File "runtask.py", line 4, in - runner.main() - File "/home/tflink/code/taskotron/libtaskotron/libtaskotron/runner.py", line 192, in main - task_runner.run() - File "/home/tflink/code/taskotron/libtaskotron/libtaskotron/runner.py", line 31, in run - self.do_actions() - File "/home/tflink/code/taskotron/libtaskotron/libtaskotron/runner.py", line 105, in do_actions - self.do_single_action(action) - File "/home/tflink/code/taskotron/libtaskotron/libtaskotron/runner.py", line 94, in do_single_action - self.envdata) - File "/home/tflink/code/taskotron/libtaskotron/libtaskotron/directives/resultsdb_directive.py", line 136, in process + Running mytask on FEDORA-2016-8760e32d9b + [libtaskotron] 15:00:40 CRITICAL Traceback (most recent call last): + File "runtask.py", line 10, in + main.main() + File "/home/mkrizek/devel/libtaskotron/libtaskotron/main.py", line 151, in main + overlord.start() + File "/home/mkrizek/devel/libtaskotron/libtaskotron/overlord.py", line 95, in start + runner.execute() + File "/home/mkrizek/devel/libtaskotron/libtaskotron/executor.py", line 56, in execute + self._run() + File "/home/mkrizek/devel/libtaskotron/libtaskotron/executor.py", line 93, in _run + self._do_actions() + File "/home/mkrizek/devel/libtaskotron/libtaskotron/executor.py", line 131, in _do_actions + self._do_single_action(action) + File "/home/mkrizek/devel/libtaskotron/libtaskotron/executor.py", line 152, in _do_single_action + self.arg_data) + File "/home/mkrizek/devel/libtaskotron/libtaskotron/directives/resultsdb_directive.py", line 196, in process raise TaskotronDirectiveError("Failed to load 'results': %s" % e.message) - TaskotronDirectiveError: Failed to load 'results': Failed to parse YAML contents: Missing plan in the YAML source + TaskotronDirectiveError: Failed to load 'results': Failed to parse YAML contents: empty input We're not actually passing result-YAML output from our task, so let's get that fixed. @@ -189,8 +179,8 @@ The Python code for ``mytask.py`` above doesn't really do anything at all, so let's make it do something: - * Change the task to create a result from the input bodhi update id and list - all of the rpms contained in that update as details. +* Change the task to create a result from the input bodhi update id and list + all of the rpms contained in that update as details. Generating result-YAML from python tasks in Taskotron isn't very difficult. @@ -222,26 +212,22 @@ print "Running mytask on %s" % bodhi_id - details = [] result = 'PASSED' note = 'from testing-pending to testing' - detail = check.CheckDetail(bodhi_id, check.ReportType.BODHI_UPDATE, - result, note) + detail = check.CheckDetail(bodhi_id, check.ReportType.BODHI_UPDATE, result, note) for rpmfile in rpmfiles['downloaded_rpms']: detail.store(rpmfile, printout=False) return check.export_YAML(detail) Now if we run the task we get output that ends with:: - [libtaskotron:resultsdb_directive.py:123] 2014-05-15 09:17:44 INFO Reporting to ResultsDB is disabled. - INFO:libtaskotron:Reporting to ResultsDB is disabled. - [libtaskotron:runner.py:198] 2014-05-15 09:17:44 INFO + [libtaskotron] 10:01:03 INFO Reporting to ResultsDB is disabled. Once enabled, the following would get reported: results: - - item: foo-1.2-3.fc99 - type: bodhi_update - outcome: PASSED - note: from testing-pending to testing + - item: FEDORA-2016-8760e32d9b + note: from testing-pending to testing + outcome: PASSED + type: bodhi_update Working with CheckDetail Objects -------------------------------- @@ -271,8 +257,7 @@ return random.choice(['PASSED', 'FAILED', 'ABORTED']) def run_mytask(rpmfiles, bodhi_id): - """run through all passed in rpmfiles and emit result-YAML. randomly report - failure or pass""" + """run through all passed in rpmfiles and emit result-YAML. randomly report failure or pass""" print "Running mytask on %s" % bodhi_id