0

I built a progress bar for a python application I developed. It is expected to look something like below:

 [██████████████      ] 70%

This works fine when run in local terminal and in docker containers built from my machine. It however, doesn't display as expected when run in gitlab shared runner. Instead of getting a single line that shows progress so far, it displays multiple lines. Something like below

 [█████████████       ] 68%
 [█████████████       ] 68%
 [█████████████       ] 68%
 [█████████████       ] 68%
 [█████████████       ] 69%
 [█████████████       ] 69%
 [█████████████       ] 69%
 [█████████████       ] 69%
 [█████████████       ] 69%
 [██████████████      ] 70%
 [██████████████      ] 70%

In order to understand the possible reasons, I tried to find out terminal properties of shared runner containers. So I executed below commands, all of which returned errors. So need help fixing the problem.

$ stty size
stty: 'standard input': Inappropriate ioctl for device

$ tput cols
tput: No value for $TERM and no -T specified

My gitlab-ci.yml file looks like below

 run-project:
   image: python:3.6
   script:
     - stty size
     - python3 Test.py

Below is sample code I am using to show progress bar:

 import sys

 i = 1
 sys.stdout.write('Start')
 for k in range(100000):
         i += 1
         sys.stdout.write('\r')
         j = (i/100000)
         sys.stdout.write("[%-20s] %d%%" % ('█'*int(20*j), int(100*j)))

What I want is to see a single line that displays progress of task instead of terminal displaying hundreds of line each displaying progress so far (Which is my intent for using carriage return operator)

JMD
  • 337
  • 4
  • 16
  • https://stackoverflow.com/questions/3173320/text-progress-bar-in-the-console The problem looks like it's not clearing the console between growing the bar. `\r` acts differently on different systems. So it's possible that gitlab treats `\r` differently than the computer from your first test. – 9716278 Aug 04 '19 at 10:56
  • Just realized that this has been reported in Gitlab couple of years ago and is yet to be prioritized. Issue: https://gitlab.com/gitlab-org/gitlab-runner/issues/2154 – JMD Sep 10 '19 at 19:16

1 Answers1

0

This is now resolved in gitlab and carriage return operator works!

Task status:
[████████████████████] 100%

JMD
  • 337
  • 4
  • 16