Open Bug 1467511 Opened 7 years ago Updated 2 years ago

[ci-admin] add support for pagination of output, controlling color output

Categories

(Firefox Build System :: Task Configuration, task)

task

Tracking

(Not tracked)

People

(Reporter: dustin, Unassigned, Mentored)

Details

(Keywords: good-first-bug, Whiteboard: [lang=py])

https://hg.mozilla.org/build/ci-admin provides a neat little Python tool, ci-admin. It produces colored output, and lots of it. It would be great if that could act like git does, with options to control pagination of output (with `less`) and options to force use of color or no color.
Hopefully this will save you several hours. You'll want to use e.g. `LESS=FRSXQ less` as the pager. This gives nice properties that the pager exits automatically if there is less than 1 screen of output. --- signal.signal(signal.SIGPIPE, <some function that raises KeyboardInterrupt>) pager = subprocess.Popen(ags, bufsize=-1, stdin=subprocess.PIPE) orig_stdout = os.dup(sys.stdout.fileno()) orig_stderr = os.dup(sys.stderr.fileno()) os.dup2(pager.stdin.fileno(), sys.stdout.fileno()) if os.isatty(sys.stderr): os.dup2(pager.stdin.fileno(), sys.stderr.fileno()) def exithandler(): signal.signal(subprocess.SIGINT, subprocess.SIG_IGN) os.dup2(orig_stdout, sys.stdout.fileno()) os.dup2(orig_stderr, sys.stderr.fileno()) pager.stdin.close() pager.wait() atexit.register(exithandler)
Whiteboard: [lang=py]

Is it still up for grab?

Flags: needinfo?(dustin)

Hi vikrant1 It is, but give me a day or so -- we just finished a big refactor of ci-admin and you'll want to work on top of those changes.

Oh okay. I am new here and looking for my first successful contribution :)

OK, the code is now at https://github.com/taskcluster/tc-admin. As a first step, get it checked out and set up and make sure the tests run.

Then, see if based on the README you can write a simple app using this library that just generates one resource, say Role=project:relman:libmozevent/admins, which you can see at
https://tools.taskcluster.net/auth/roles/project%3Arelman%3Alibmozevent%2Fadmins

and then try running TASKCLUSTER_ROOT_URL=https://taskcluster.net tc-admin diff and see what the output looks like. That's the output we'll want to paginate.

Flags: needinfo?(dustin)

(In reply to Dustin J. Mitchell [:dustin] (he/him) from comment #5)

OK, the code is now at https://github.com/taskcluster/tc-admin. As a first step, get it checked out and set up and make sure the tests run.

Then, see if based on the README you can write a simple app using this library that just generates one resource, say Role=project:relman:libmozevent/admins, which you can see at
https://tools.taskcluster.net/auth/roles/project%3Arelman%3Alibmozevent%2Fadmins

and then try running TASKCLUSTER_ROOT_URL=https://taskcluster.net tc-admin diff and see what the output looks like. That's the output we'll want to paginate.

Hi Dustin,
I want to start contributing to Open Source. Has the issue been assigned to anyone?

(In reply to Dustin J. Mitchell [:dustin] (he/him) from comment #5)

OK, the code is now at https://github.com/taskcluster/tc-admin. As a first step, get it checked out and set up and make sure the tests run.

Then, see if based on the README you can write a simple app using this library that just generates one resource, say Role=project:relman:libmozevent/admins, which you can see at
https://tools.taskcluster.net/auth/roles/project%3Arelman%3Alibmozevent%2Fadmins

and then try running TASKCLUSTER_ROOT_URL=https://taskcluster.net tc-admin diff and see what the output looks like. That's the output we'll want to paginate.

Sorry for the late reply. I am looking into this now. Thanks Dustin.
Sorry Aditya. Can you please let me work on this. I have already spent some time on studying this bug.

(In reply to vikrantcode from comment #7)

(In reply to Dustin J. Mitchell [:dustin] (he/him) from comment #5)

OK, the code is now at https://github.com/taskcluster/tc-admin. As a first step, get it checked out and set up and make sure the tests run.

Then, see if based on the README you can write a simple app using this library that just generates one resource, say Role=project:relman:libmozevent/admins, which you can see at
https://tools.taskcluster.net/auth/roles/project%3Arelman%3Alibmozevent%2Fadmins

and then try running TASKCLUSTER_ROOT_URL=https://taskcluster.net tc-admin diff and see what the output looks like. That's the output we'll want to paginate.

Sorry for the late reply. I am looking into this now. Thanks Dustin.
Sorry Aditya. Can you please let me work on this. I have already spent some time on studying this bug.

No Problem!

I am trying to understand how tcadmin works. My tc-admin.py is :

from tcadmin.appconfig import AppConfig
from tcadmin.resources import Resources
from tcadmin.resources import Role

appconfig = AppConfig()

resources = Resources([])
resources.manage('Role=project:relman:libmozevent/admins')

hook = Role("project:relman:libmozevent/admins", "Created in bug 1467511", [
    "auth:create-role:repo:github.com/mozilla/libmozevent:*",
    "auth:delete-role:repo:github.com/mozilla/libmozevent:*",
    "auth:update-role:repo:github.com/mozilla/libmozevent:*",
])

resources.add(hook)

But the TASKCLUSTER_ROOT_URL=https://taskcluster.net tc-admin generate --json gives blank arrays. DId I forgot any step?

Flags: needinfo?(dustin)

Close! You'll need to add that resource in a function registered for resource generation:

appconfig = AppConfig()

@appconfig.generators.register
async def update_resources(resources):
    resources.manage('Role=project:relman:libmozevent/admins')                                                           

    hook = Role("project:relman:libmozevent/admins", "Created in bug 1467511", [
        "auth:create-role:repo:github.com/mozilla/libmozevent:*",
        "auth:delete-role:repo:github.com/mozilla/libmozevent:*",
        "auth:update-role:repo:github.com/mozilla/libmozevent:*",
    ])

    resources.add(hook)
Flags: needinfo?(dustin)

Thanks Dustin, It worked. Now what kind of pagination I should implement? Like man pages or more of a command like tc-admin diff --page 4? I think result piped to less or info will be better.

Yes, much more like man pages than --page. Comment 1 has some useful ideas.

(In reply to Dustin J. Mitchell [:dustin] (he/him) from comment #12)

Yes, much more like man pages than --page. Comment 1 has some useful ideas.

Oh I am really really sorry for abandoning this. I got lost in my career and the COVID pandemic. Completely forgot that I was assigned this task. Recently logged in and found this again. Now that it is 3 years old, is it still open? Should I work on this?

Hi Vikrant -- I know how it goes :) I actually am not working at Mozilla anymore, so I'm not sure if this is still a useful thing to be working on. Unless you have a partially finished branch that you can just polish up, it might be best to find something more current..

Ah... okay, maybe I will checkout the latest code and see if it is required to work on.

Severity: normal → S3

hey my name is judith an outreachy applicant can I please work on this with help?

You need to log in before you can comment on or make changes to this bug.