unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Ricardo Wurmus <rekado@elephly.net>
To: Sahithi <sahi@swecha.net>
Cc: guix-devel <guix-devel@gnu.org>
Subject: Next steps
Date: Fri, 15 Jun 2018 23:47:59 +0200	[thread overview]
Message-ID: <87r2l767sg.fsf@elephly.net> (raw)
In-Reply-To: <564233bd-9511-7f84-3350-6a3a905534a8@swecha.net>


Hi Sahithi,

> I have fixed the errors mentioned bellow, Please do check and notify me
> for further modifications.

Excellent, this looks better.  Unfortunately, your patch includes a
couple of unrelated indentation changes.  Please remove those.

Let’s talk about the next steps.


1) Enabling colours only *optionally*.

We modified “guix/scripts/build.scm” to test the changes, but this
really should be optional, because not everybody wants colours.

For example, when the environment variable “NO_COLOR” is set to any
value we should not use colours.  Likewise, when the environment
variable “INSIDE_EMACS” has a value (meaning that this is a shell in
Emacs where people should rather use “guix-build-log-minor-mode”) we
should not print colours.  You can read the values of environment
variables with the “getenv” procedure (it is explained in the manual).

This check could be in “guix/scripts/build.scm” and
“guix/scripts/package.scm” to either use “colorful-build-output-port” or
“(current-error-port)”.

Another option is to do this in the definition of
“colorful-build-output-port” itself, which would either be defined with
“handle-string” or “handle-plain-string” (which uses no colours)
dependent on these environment variables.

This option would be better, because we want to extend the soft port to
also filter lines optionally (when “guix package” is used).  Instead of
swapping out the full port we could configure it with various options
like “color?” and “filter?”.

Time estimate: This should take no longer than 3 days.


2) Fixing the other soft port procedures

Currently we have this:

> +   (vector
> +    (lambda (c) (write c (current-error-port)))
> +    ;; procedure accepting one character for output
> +    handle-string
> +    ;; procedure accepting a string for handle-string procedure
> +    (lambda () (display " " (current-error-port)))
> +    (lambda () (char-upcase (read-char)))
> +    (lambda () (display "@" (current-error-port))))

Please move the comments *above* the procedures they describe.  Note
that the third procedure is still wrong – according to the manual it
should force or flush the output, not print a space.  Please use
“(lambda () (force-output (current-error-port)))” instead.

The fourth procedure reads a character.  Currently it also turns the
read character to an uppercase character.  We don’t need that, because
we don’t read from the port at all.  You can use “(const #t)” instead.

Time estimate: This should take less than 10 minutes to fix.


3) Filtering all lines between “starting phase” and “phase
succeeded/failed”.

Currently, the port applies colours and passes all other lines through
unmodified.  When using “guix package” it may be good to *hide* other
lines and replace them with a progress indicator.  The first step to
test this would be to replace *any* other line with “.”.  You would then
only see the lines that announce phases, but not the build output.

(Later we would change the dots for a cute little “spinner” animation.)

Can you think of a way to *only* filter lines when “guix package” is
used but not when “guix build” is used?  Maybe we need another variation
of the port…?

Time estimate: You should have some results and an idea how to finish
this after no more than a day of work.


4) Making the colorization prettier.

We repeat “colorize-string” a lot!  Can we do better?  How about using
“match:count” and a list of colours to be applied in order?

Start playing with something like this in the REPL:

--8<---------------cut here---------------start------------->8---


(use-modules (ice-9 match)   ; need this for “match-lambda”
             (srfi srfi-1))  ; need this for “any”

(define str "phase foo failed after 100 seconds")


;; Each list item in “patterns” is a regular expression followed by a
;; number of colours.
(let ((patterns '(("^(starting phase )(.*)"
                   BLUE GREEN)
                  ("^(phase)(.*)(succeeded after)(.*)(seconds)"
                   GREEN BLUE GREEN BLUE GREEN)
                  ("^(phase)(.*)(failed after)(.*)(seconds)"
                   RED BLUE RED BLUE RED))))

   ;; See if “any” of the patterns matches, i.e. returns a string and
   ;; not just #f.  We use “match-lambda” to bind the pattern to the
   ;; variable “pattern” and the list of colours to the variable
   ;; “colors”.

   (or (any (match-lambda
             ((pattern . colors)
              ;; TODO: use string-match, match:count, match:substring,
              ;; colorize-string, and=>, etc to see if a pattern matches
              ;; and to transform the string according to “colors”.

              ;; If the pattern does not match return #f to
              ;; automatically try the next, thanks to “any”.
              #f
             ))
             patterns)
       ;; Nothing matched, so return the string without changes.
       str))
--8<---------------cut here---------------end--------------->8---

Take your time to understand this one.  Play around with this in the
REPL and ask questions on IRC (both #guile and #guix) if the manual does
not answer your questions.  Once you understand it, it should take no
longer than 3 days to implement this.

All together, these steps should take no longer than two weeks to
implement.  What do you think?

Remember to play in the REPL, use “pk” to confirm that variables have
the values you expect, and to ask others if you get stuck.

--
Ricardo

  reply	other threads:[~2018-06-15 22:04 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <8ea5d026-fab9-7b12-198e-610ad7743cb2@swecha.net>
     [not found] ` <871sfxev9w.fsf@elephly.net>
     [not found]   ` <7626275c-3eee-bb05-ab9d-4c88ec6f0329@swecha.net>
     [not found]     ` <87r2nvjte6.fsf@elephly.net>
     [not found]       ` <5ab51417-b635-9725-9f48-3bc3f9b61fdf@swecha.net>
     [not found]         ` <87tvsko2wd.fsf@elephly.net>
     [not found]           ` <7290013c-990d-3f7d-d8db-38e090ed766a@swecha.net>
     [not found]             ` <87zi28kt82.fsf@elephly.net>
     [not found]               ` <8573e97d-d107-cde6-cd17-35f4ef6d2de3@swecha.net>
     [not found]                 ` <87k1takumm.fsf@elephly.net>
     [not found]                   ` <87o9hycwl6.fsf@elephly.net>
2018-05-11 21:16                     ` Status of Submitted Patches Sahithi Yarlagadda
2018-05-11 22:21                       ` Ricardo Wurmus
2018-05-12  7:50                         ` Ricardo Wurmus
2018-05-15 17:41                         ` Sahitihi
2018-05-20  9:40                           ` Ricardo Wurmus
2018-05-20 10:47                             ` Gábor Boskovits
2018-05-20 13:46                               ` Ricardo Wurmus
2018-05-23  7:53                             ` Sahitihi
2018-05-23  8:21                               ` Ricardo Wurmus
2018-05-24 17:16                                 ` Sahitihi
2018-05-24 20:00                                   ` Ricardo Wurmus
2018-05-25  3:43                                 ` Sahitihi
2018-05-25  5:18                                   ` Ricardo Wurmus
2018-05-25 17:59                                     ` Patch file for colorize module Sahitihi
2018-05-26  6:06                                       ` Sahitihi
2018-05-26  9:35                                         ` Ricardo Wurmus
2018-05-26 12:06                                           ` Sahitihi
2018-05-26 14:16                                             ` Ricardo Wurmus
2018-05-26 18:22                                               ` Sahitihi
2018-05-26 18:38                                                 ` Sahitihi
2018-05-26 21:20                                                   ` Ricardo Wurmus
2018-05-27 15:49                                                     ` Gábor Boskovits
2018-05-31  6:26                                               ` Fwd: " Ricardo Wurmus
2018-05-31 18:25                                                 ` Sahitihi
2018-05-31 19:28                                                   ` Ricardo Wurmus
2018-06-02 15:01                                                     ` Ricardo Wurmus
2018-06-03 14:18                                                     ` Sahitihi
2018-06-03 19:30                                                       ` Ricardo Wurmus
2018-06-04  7:48                                                         ` Sahitihi
2018-06-04 10:03                                                           ` Ricardo Wurmus
2018-06-04 18:51                                                             ` Sahitihi
2018-06-05 19:44                                                               ` Ricardo Wurmus
2018-06-06 19:49                                                                 ` Sahitihi
2018-06-06 20:06                                                                   ` Ricardo Wurmus
2018-06-06 21:20                                                                     ` Sahitihi
2018-06-06 21:28                                                                       ` Ricardo Wurmus
2018-06-07  3:29                                                                         ` Sahitihi
2018-06-07  5:22                                                                           ` Ricardo Wurmus
2018-06-07  7:47                                                                             ` Sahitihi
2018-06-07  8:25                                                                               ` Ricardo Wurmus
2018-06-08 17:01                                                                                 ` Sahitihi
2018-06-09  0:57                                                                                   ` Ricardo Wurmus
2018-06-09 18:08                                                                                     ` Sahitihi
2018-06-09 20:57                                                                                       ` Ricardo Wurmus
2018-06-11 12:14                                                                                         ` Sahitihi
2018-06-11 12:28                                                                                           ` Gábor Boskovits
2018-06-11 16:21                                                                                             ` Sahitihi
2018-06-12 14:12                                                                                               ` Ricardo Wurmus
2018-06-12 21:06                                                                                                 ` Sahitihi
2018-06-12 22:12                                                                                                   ` Ricardo Wurmus
2018-06-13 16:08                                                                                                     ` Sahithi Yarlagadda
2018-06-13 19:15                                                                                                       ` Ricardo Wurmus
2018-06-15 20:16                                                                                                         ` Sahitihi
2018-06-15 21:47                                                                                                           ` Ricardo Wurmus [this message]
2018-06-16 14:55                                                                                                             ` Next steps Sahitihi
2018-06-21 11:05                                                                                                               ` Ricardo Wurmus
2018-06-21 16:54                                                                                                                 ` Sahithi Yarlagadda
2018-06-25 20:13                                                                                                                   ` Sahithi Yarlagadda
2018-06-25 20:28                                                                                                                     ` Ricardo Wurmus
2018-06-26 20:01                                                                                                                       ` Gábor Boskovits
2018-06-29 22:51                                                                                                                       ` Sahithi Yarlagadda
2018-07-03  2:29                                                                                                                         ` Sahithi Yarlagadda
2018-06-24 18:25                                                                                                             ` Sahithi Yarlagadda
2018-06-24 20:22                                                                                                               ` Ricardo Wurmus
2018-06-24 20:33                                                                                                                 ` Sahithi Yarlagadda
2018-06-11 12:37                                                                                           ` Fwd: Re: Patch file for colorize module Ricardo Wurmus
2018-06-11 16:31                                                                                             ` Sahitihi
2018-06-04 11:41                                                         ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r2l767sg.fsf@elephly.net \
    --to=rekado@elephly.net \
    --cc=guix-devel@gnu.org \
    --cc=sahi@swecha.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).