Open blackyale opened 6 years ago
Hi @AlejandroMoran! Thank you for reporting this issue ;)
I've checked the code and discovered that the error was caused by wrong assumption that console window is larger than 5 characters.
I've disabled displaying progress bar in those situations - you can check out commit here 2124172cce71454d4c0bba944307d8fd5b5522a3.
I'm leaving this issue open since we will be introducing new output formats (for example JSON) for all of our tools. I think that creating safe output format for CI systems would be a good idea (without fancy progress bars etc.)
Let me know if that fix helps you!
@witcher112 thanks, I'll check it asap! Anyway, are you planning to release some REST API for your platform in order to get rid of this ruby tool?
For instance: I've been using your API calls (extracted from your ruby tool) in order to get the list of versions (https://panel.patchkit.net/1/apps/TOKEN/versions) but I would like to have some other endpoints like applications list in order to automate most of my deploying process. Thanks for your help!
@witcher112 Apart from that, I see that your commit is directly into the progressbar library code, this is not supposed to work this way right? or yes? I suppose this third-party libraries were installed with "bundler install" as depicted in the tool documentation, am I wrong? Thanks in advance.
@witcher112 Apart from that, I see that your commit is directly into the progressbar library code, this is not supposed to work this way right? or yes? I suppose this third-party libraries were installed with "bundler install" as depicted in the tool documentation, am I wrong? Thanks in advance.
Progress bar is our own implementation shipped inside the tools - it's not a third-party library. So you don't need to worry about it ;)
Anyway, are you planning to release some REST API for your platform in order to get rid of this ruby tool?
Official release of REST API is going to happen in some near future - we've got this on our internal road map. If you want to be notified about this, you can sign up to our mail updates in your profile settings - https://panel.patchkit.net/users/profile
By the way - did the change I made solve your problems :)?
Hello guys, I've tested this after several time without patchkit and it seems you still have problems with the window size in GitLab.
Error during file upload: undefined method
winsize' for nil:NilClass`
@blackyale By GitLab do you mean running it on GitLab CI?
@blackyale By GitLab do you mean running it on GitLab CI?
Yes, sorry that I didn't add too much information, I was in hurry. I was using GitLab CI and after a few tries I have it working but I needed to comment code in app/upload_version.rb, the commented code looks as this:
def execute
check_if_option_exists("secret")
check_if_option_exists("api_key")
check_if_option_exists("version")
check_if_valid_option_value("mode", UPLOAD_MODES)
check_if_option_file_exists_and_readable("file")
check_if_option_file_exists_and_readable("diff_summary") if @mode == "diff"
# Check if the version is draft
puts "Checking version..."
app = App.find_by_secret!(@secret)
version = Version.find_by_id!(app, @version)
raise "Version must be a draft" unless version.draft?
puts "Uploading #{@mode}..."
file_size = File.size(@file)
# progress_bar = ProgressBar.new(file_size)
speed_calculator = SpeedCalculator.new
uploader = S3Uploader.new(@api_key)
#uploader.on(:progress) do |bytes_sent, bytes_total|
#speed_calculator.submit(bytes_sent)
#text = if speed_calculator.ready?
#format("Uploading %.2f MB out of %.2f MB (%.2f MB/s)",
#bytes_sent / 1024.0**2,
#bytes_total / 1024.0**2,
#speed_calculator.speed_per_second / 1024.0**2)
#else
#format("Uploading %.2f MB out of %.2f MB",
#bytes_sent / 1024.0**2,
#bytes_total / 1024.0**2)
#end
#progress_bar.print(bytes_sent, text)
#end
loop do
begin
3.times { puts }
uploader.upload_file(@file)
break
rescue => e
puts
puts "Error during file upload: #{e}"
@retry_count -= 1
if @retry_count < 0
if @ask_to_try_again
if ask_yes_or_no("Try again?", 'y')
next
else
raise CommandLineError, "Couldn't upload the file"
end
else
raise CommandLineError, "Couldn't upload the file"
end
end
end
end
upload_id = uploader.upload_id
#progress_bar.print(file_size, "Upload done", force: true)
result = case @mode
when 'content'
version.upload_content!(upload_id: upload_id)
when 'diff'
version.upload_diff!(upload_id: upload_id,
diff_summary: File.read(@diff_summary))
else
raise "unknown mode: #{@mode}"
end
@processing_job_guid = result[:job_guid]
# Optionally wait for finish of version processing job
if @wait_for_job
puts "Waiting for finish of version processing job..."
# Display job progress bar
PatchKitAPI.display_job_progress(@processing_job_guid)
end
end
@genail It's basically a comment on the progress bar since it was not able to get columns or rows of GitLab CI. Maybe it worth adding a --no-progress flag.
I used v3.1.1 version of patchkit-tools in a 'ubuntu' docker image.
When executing this command in a Travis CI instance:
./patchkit-tools make-version -s SECRET -a KEY -l "label" -f ../gametest -c "this is the changelog"
I get this error:
patchkit-tools-1.3.0/src/lib/progress_bar.rb:29:in
*': negative argument (ArgumentError) from /home/travis/build/AlejandroMoran/GameTest/patchkit-tools-1.3.0/src/lib/progress_bar.rb:29:inprint' from /home/travis/build/AlejandroMoran/GameTest/patchkit-tools-1.3.0/src/download_version_signatures.rb:71:in
block (2 levels) in execute' from /home/travis/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/net/protocol.rb:429:incall_block' from /home/travis/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/net/protocol.rb:420:in
<<' from /home/travis/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/net/protocol.rb:126:inread' from /home/travis/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/net/http/response.rb:293:in
block in read_body_0' from /home/travis/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/net/http/response.rb:278:ininflater' from /home/travis/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/net/http/response.rb:283:in
read_body_0' from /home/travis/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/net/http/response.rb:204:inread_body' from /home/travis/build/AlejandroMoran/GameTest/patchkit-tools-1.3.0/src/download_version_signatures.rb:67:in
block in execute' from /home/travis/build/AlejandroMoran/GameTest/patchkit-tools-1.3.0/src/lib/patchkit_api.rb:42:inblock (2 levels) in get_response' from /home/travis/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/net/http.rb:1455:in
block in transport_request' from /home/travis/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/net/http/response.rb:165:inreading_body' from /home/travis/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/net/http.rb:1454:in
transport_request' from /home/travis/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/net/http.rb:1416:inrequest' from /home/travis/build/AlejandroMoran/GameTest/patchkit-tools-1.3.0/src/lib/patchkit_api.rb:40:in
block in get_response' from /home/travis/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/net/http.rb:877:instart' from /home/travis/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/net/http.rb:608:in
start' from /home/travis/build/AlejandroMoran/GameTest/patchkit-tools-1.3.0/src/lib/patchkit_api.rb:39:inget_response' from /home/travis/build/AlejandroMoran/GameTest/patchkit-tools-1.3.0/src/download_version_signatures.rb:60:in
execute' from /home/travis/build/AlejandroMoran/GameTest/patchkit-tools-1.3.0/src/make_version.rb:147:inupload_version_diff' from /home/travis/build/AlejandroMoran/GameTest/patchkit-tools-1.3.0/src/make_version.rb:217:in
execute' from /home/travis/build/AlejandroMoran/GameTest/patchkit-tools-1.3.0/src/lib/patchkit_tools.rb:14:inexecute_tool' from /home/travis/build/AlejandroMoran/GameTest/patchkit-tools-1.3.0/src/lib/tools.rb:85:in
execute' from ./src/lib/bootstrap.rb:38:in<main>'
I needed to comment out some lines inside progressbar library to make this work. This is working fine locally on MacOS. Any idea?