Fix CLI to work with the trigger rules
ClosedPublic

Authored by mkrizek on Jan 13 2017, 3:08 PM.

Details

Summary

This fixes the CLI to work with the new trigger rules, a few notes:

  1. It is not possible to replay jobs from a file (jobs.csv) since the file no longer provides all the values that are neccesary to trigger the jobs according to the trigger rules. Some code is still there, will be removed if we agree not to support it anymore, reworked otherwise.
  1. Koji tag jobs are not replayed from the CLI. It does not make much sense to run depcheck since the state of the repo was changed since the fedmsg was emitted.
  1. Topics and triggers are hardcoded in the CLI for now. I guess I can write some code that would discover what triggers should be run on what topics but not sure it's worth the effort now.

The patch also fixes a couple of other small issues that I run into, sorry about that.

Test Plan

Run both modes of the trigger:

$ fedmsg-hub

and

$ python cli.py -d --start `date --date="2017-01-09 07:00" +%s` --end `date --date="2017-01-09 10:00" +%s`

Diff Detail

Repository
rTRGR taskotron-trigger
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
mkrizek retitled this revision from to WIP: Fix CLI to work with the trigger rules.Jan 13 2017, 3:08 PM
mkrizek updated this object.
mkrizek edited the test plan for this revision. (Show Details)
mkrizek added reviewers: tflink, jskladan, ralph.
mkrizek updated this revision to Diff 2749.Jan 13 2017, 3:16 PM

Fix some lint errors

mkrizek edited the test plan for this revision. (Show Details)Jan 13 2017, 3:17 PM

I'll read the code a bit later, but regarding:

It is not possible to replay jobs from a file (jobs.csv) since the file no longer provides all the values that are neccesary to trigger the jobs according to the trigger rules. Some code is still there, will be removed if we agree not to support it anymore, reworked otherwise.

I'd rather have this supported, than removed. It honestly was the 99% usecase for me, so I'm not sure what are the other things to be done via the CLI, but this one I'd love to keep.

I don't see any conceptual issues with the code. If you've tested it locally and it works, I'd say go for it once the lint issues and test failures are taken care of

ralph added a comment.Jan 18 2017, 4:47 PM

No blockers from me.

mkrizek updated this revision to Diff 2770.Jan 18 2017, 7:48 PM

Fixing unittests and most of the lint errors

I'll read the code a bit later, but regarding:

It is not possible to replay jobs from a file (jobs.csv) since the file no longer provides all the values that are neccesary to trigger the jobs according to the trigger rules. Some code is still there, will be removed if we agree not to support it anymore, reworked otherwise.

I'd rather have this supported, than removed. It honestly was the 99% usecase for me, so I'm not sure what are the other things to be done via the CLI, but this one I'd love to keep.

That makes sense to me. Can we agree on creating a phab task for reworking the file support and deal with that in other review?

mkrizek retitled this revision from WIP: Fix CLI to work with the trigger rules to Fix CLI to work with the trigger rules.Jan 18 2017, 7:51 PM
mkrizek edited the test plan for this revision. (Show Details)
mkrizek updated this revision to Diff 2771.Jan 18 2017, 7:56 PM

Rebase to develop

ralph accepted this revision.Jan 18 2017, 8:07 PM

Looks good to me (pending whether or not @jskladan approves create an issue to restore the old functionality).

This revision is now accepted and ready to land.Jan 18 2017, 8:07 PM
kparal added a subscriber: kparal.Jan 19 2017, 12:39 PM

Excuse: Any suggestions what to do with those?

Sure, here comes the lint guru :)

jobtriggers/dist_git_commit_msg.py
3

First try whether this line can be removed and the test suite still runs. config is not used anywhere, so I'm not sure why the test suite would need it (I haven't looked). If it is needed, add an exception since it's necessary in this case:

from . import config  # This gets mocked by the test suite.   # noqa: F401
setup.py
32–33

This seems to be the correct solution:

entry_points={
    'console_scripts': ['jobrunner=jobtriggers.jobrunner:main'],
    'moksha.consumer': (
        'kojibuildcompletedjobconsumer = '
        'jobtriggers.koji_build_msg:KojiBuildCompletedJobConsumer',
        'kojitagchangedjobconsumer = jobtriggers.koji_tag_msg:KojiTagChangedJobConsumer',
        'composecompletedjobconsumer = '
        'jobtriggers.compose_complete_msg:ComposeCompletedJobConsumer',
        'distgitcommitjobconsumer = jobtriggers.dist_git_commit_msg:DistGitCommitJobConsumer',
    ),
},

but it's hard to read. What about this?

moksha_consumer = (
    'kojibuildcompletedjobconsumer = jobtriggers.koji_build_msg:KojiBuildCompletedJobConsumer',
    'kojitagchangedjobconsumer = jobtriggers.koji_tag_msg:KojiTagChangedJobConsumer',
    'composecompletedjobconsumer = jobtriggers.compose_complete_msg:ComposeCompletedJobConsumer',
    'distgitcommitjobconsumer = jobtriggers.dist_git_commit_msg:DistGitCommitJobConsumer',
)

setup(
    name='jobtriggers',
    version='0.4.3',
    description='triggering jobs via fedmsg',
    author='Tim Flink',
    author_email='tflink@fedoraproject.org',
    license='GPLv2+',
    url='https://fedorahosted.org/fedora-qa',
    packages=['jobtriggers'],
    entry_points={
        'console_scripts': ['jobrunner=jobtriggers.jobrunner:main'],
        'moksha.consumer': moksha_consumer,
    },
    include_package_data=True,
    install_requires=[
        'fedmsg',
        'requests',
    ],
    cmdclass={'test': PyTest}
)
testing/test_jobtrigger.py
108

Remove tasks = .

mkrizek updated this revision to Diff 2783.Jan 23 2017, 1:38 PM

minor fix

jskladan accepted this revision.Jan 23 2017, 2:18 PM

Looks good, I'd still want to have the jobsfile functionality, but we can add that later on. /me will spin up a ticket for that.

tflink accepted this revision.Jan 23 2017, 2:21 PM

Lint issues aside, looks good to me. Works when I test locally

Closed by commit rTRGRb77ce99d5ef2: Fix CLI to work with the trigger rules (authored by Martin Krizek <mkrizek@redhat.com>). · Explain WhyJan 23 2017, 2:58 PM
This revision was automatically updated to reflect the committed changes.