git-time-metric / gtm

Simple, seamless, lightweight time tracking for Git
MIT License
973 stars 52 forks source link

Running into gitlab-ci for Autoreporting #76

Closed nthings closed 6 years ago

nthings commented 6 years ago

I am playing around with the project into my Gitlab Pipeline for automating the reports and maybe exporting them. I created a docker image with gtm for running the commands into the pipeline https://hub.docker.com/r/nthingsm/gtm/ and in my .gitlab-ci.yml I have the next stage:

time_report:
    stage: time_report
    image: nthingsm/gtm
    script:
        - gtm init
        - git fetchgtm
        - gtm report -this-month -format timeline-hours

But the gtm report command doesn't output anything. Am I missing something?

nthings commented 6 years ago

FYI managed to get output with this command:

time_report:
    stage: time_report
    image: nthingsm/gtm
    script:
        - gtm init
        - git fetchgtm
        - git log --pretty=%H --since="last month" | gtm report -format timeline-hours -this-month
nthings commented 6 years ago

UPDATE: Running the command in my local gives different times for the report. Local


             00.01.02.03.04.05.06.07.08.09.10.11.12.01.02.03.04.05.06.07.08.09.10.11.
             ------------------------------------------------------------------------
Fri Feb 09 |                            ▁▁▁██████▃▃▃▂▂▂███▁▁▁                         |    3h 27m  0s
             ------------------------------------------------------------------------
Mon Feb 12 |                               ▅▅▅███▃▃▃   ▁▁▁▆▆▆                         |    2h 27m  0s
             ------------------------------------------------------------------------
Tue Feb 13 |                            ▁▁▁   ▂▂▂   ▃▃▃   ▅▅▅▃▃▃                      |    1h 14m  0s
             ------------------------------------------------------------------------
Wed Feb 14 |                            ▃▃▃   ▂▂▂▄▄▄▁▁▁██████▂▂▂                      |    3h 16m  0s
             ------------------------------------------------------------------------
Thu Feb 15 |                            ▁▁▁▃▃▃▆▆▆▂▂▂▄▄▄▁▁▁▃▃▃▁▁▁                      |    2h  8m  0s
             ------------------------------------------------------------------------
Fri Feb 16 |                                              ▂▂▂▁▁▁                      |       16m  0s
             ------------------------------------------------------------------------
Tue Feb 20 |                                     ▁▁▁                                  |        5m  0s
             ------------------------------------------------------------------------
Wed Feb 21 |                               ▅▅▅▄▄▄   ▃▃▃                               |    1h 20m  0s
             ------------------------------------------------------------------------
Thu Feb 22 |                               ▁▁▁▁▁▁▂▂▂▁▁▁▃▃▃                            |       39m  0s
             ------------------------------------------------------------------------
Fri Feb 23 |                                  ▃▃▃▁▁▁                                  |       24m  0s
             ------------------------------------------------------------------------
                                                                                          15h 16m  0s


Gitlab Pipeline:


             00.01.02.03.04.05.06.07.08.09.10.11.12.01.02.03.04.05.06.07.08.09.10.11.
             ------------------------------------------------------------------------
Fri Feb 09 |                                              ▁▁▁██████▃▃▃▂▂▂███▁▁▁       |    3h 27m  0s
             ------------------------------------------------------------------------
Mon Feb 12 |                                                 ▅▅▅███▃▃▃   ▁▁▁▆▆▆       |    2h 27m  0s
             ------------------------------------------------------------------------
Tue Feb 13 |                                              ▁▁▁   ▂▂▂   ▃▃▃   ▅▅▅▃▃▃    |    1h 14m  0s
             ------------------------------------------------------------------------
Wed Feb 14 |                                              ▃▃▃   ▂▂▂▄▄▄▁▁▁██████▂▂▂    |    3h 16m  0s
             ------------------------------------------------------------------------
Thu Feb 15 |                                              ▁▁▁▃▃▃▆▆▆▂▂▂▄▄▄▁▁▁▃▃▃▁▁▁    |    2h  8m  0s
             ------------------------------------------------------------------------
Fri Feb 16 |                                                                ▂▂▂▁▁▁    |       16m  0s
             ------------------------------------------------------------------------
Tue Feb 20 |                                                       ▁▁▁                |        5m  0s
             ------------------------------------------------------------------------
Wed Feb 21 |                                                 ▅▅▅▄▄▄   ▃▃▃             |    1h 20m  0s
             ------------------------------------------------------------------------
Thu Feb 22 |                                                 ▁▁▁▁▁▁▂▂▂▁▁▁▁▁▁          |       24m  0s
             ------------------------------------------------------------------------
                                                                                          14h 37m  0s


This gets the time from the system?

mschenk42 commented 6 years ago

Correct, the difference in time would be the timezone of the system you ran it on.

mschenk42 commented 6 years ago

I tested gtm in your Docker container and it seems to work fine. I assume you are cloning the git repo within the Docker container. I would guess there is a problem with how the pipeline is executing the command. Could also be a timing issue between git fetchgtm and gtm report commands. You could try sleeping for a bit before executing the gtm report command.

nthings commented 6 years ago

I can confirm that the timezone of the Docker container affected the timeline. Seems to be working now. Thanks 👍