jenkins-bot has submitted this change and it was merged.

Change subject: [BrowserTest] Move the screenshot uploading to a gem
......................................................................


[BrowserTest] Move the screenshot uploading to a gem

* The methods from upload.rb are moved to a newly created gem:
  https://rubygems.org/gems/commons_upload
* upload.rb is changed to simply call the method from the Gem.
* Gemfile is updated accordingly.

Bug: T89718
Change-Id: I229fbcd1b8c3cb03885947509aef27f0ae583a1c
---
M Gemfile
M Gemfile.lock
M modules/ve-mw/tests/browser/upload.rb
3 files changed, 6 insertions(+), 41 deletions(-)

Approvals:
  Zfilipin: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/Gemfile b/Gemfile
index 42d6a77..f53b8e6 100644
--- a/Gemfile
+++ b/Gemfile
@@ -3,6 +3,7 @@
 
 source 'https://rubygems.org'
 
+gem 'commons_upload', '~> 0.0.1'
 gem 'mediawiki_api'
 gem 'mediawiki_selenium', '~> 0.4.1'
 gem 'rubocop', require: false
diff --git a/Gemfile.lock b/Gemfile.lock
index 439bee1..083ccd5 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -8,6 +8,8 @@
     childprocess (0.5.5)
       ffi (~> 1.0, >= 1.0.11)
     chunky_png (1.3.4)
+    commons_upload (0.0.1)
+      mediawiki_api (~> 0.3.0)
     cucumber (1.3.19)
       builder (>= 2.1.2)
       diff-lcs (>= 1.1.3)
@@ -95,6 +97,7 @@
   ruby
 
 DEPENDENCIES
+  commons_upload (~> 0.0.1)
   mediawiki_api
   mediawiki_selenium (~> 0.4.1)
   rubocop
diff --git a/modules/ve-mw/tests/browser/upload.rb 
b/modules/ve-mw/tests/browser/upload.rb
index 390bc10..3f2c332 100644
--- a/modules/ve-mw/tests/browser/upload.rb
+++ b/modules/ve-mw/tests/browser/upload.rb
@@ -1,42 +1,3 @@
-def license(language_code, file_name)
-  require 'date'
-  date = Date.today.to_s
-  "=={{int:filedesc}}==
-{{Information
-|description={{en|1=#{file_name}}}
-|date=#{date}
-|source=[[User:LanguageScreenshotBot|Automatically created by 
LanguageScreenshotBot]]
-|author=[[User:LanguageScreenshotBot|Automatically created by 
LanguageScreenshotBot]]
-|permission=
-|other_versions=
-|other_fields=
-}}
+require 'commons_upload'
 
-=={{int:license-header}}==
-{{Wikipedia-screenshot}}
-
-[[Category:VisualEditor automatic screenshots/#{language_code}]]"
-end
-
-def upload_image(file_path, client)
-  language_code = ENV['LANGUAGE_SCREENSHOT_CODE']
-  file_name = File.basename(file_path, '')
-  file_license = license(language_code, file_name)
-
-  client.upload_image(file_name, file_path, file_license, true)
-  sleep 5 # Restriction in bot speed: 
https://commons.wikimedia.org/wiki/Commons:Bots#Bot_speed
-end
-
-def upload_images
-  screenshot_directory = ENV['LANGUAGE_SCREENSHOT_PATH'] || './screenshots'
-  require 'mediawiki_api'
-  client = MediawikiApi::Client.new ENV['MEDIAWIKI_API_UPLOAD_URL']
-  client.log_in ENV['MEDIAWIKI_USER'], ENV['MEDIAWIKI_PASSWORD']
-  Dir["#{screenshot_directory}/*.png"].each do |file_path|
-    puts "Uploading #{file_path}"
-    upload_image file_path, client
-  end
-end
-
-ENV['MEDIAWIKI_PASSWORD'] = ENV[ENV['MEDIAWIKI_PASSWORD_VARIABLE']] if 
ENV['MEDIAWIKI_PASSWORD_VARIABLE']
-upload_images
+CommonsUpload.images

-- 
To view, visit https://gerrit.wikimedia.org/r/191563
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I229fbcd1b8c3cb03885947509aef27f0ae583a1c
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Amire80 <[email protected]>
Gerrit-Reviewer: Cmcmahon <[email protected]>
Gerrit-Reviewer: Dduvall <[email protected]>
Gerrit-Reviewer: Zfilipin <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to