From 2aadc18105df3c7e667d98eb8194bd5fdd8d8ff0 Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Wed, 7 Mar 2018 15:43:25 +0100 Subject: [PATCH] build: npm/rake entry point for screenshots upload We have a Jenkins job to take screenshots of VisualEditor and upload the result to commons.wikimedia.org. That roughly does: npm install node_modules/.bin/grunt screenshots-all bundle install bundle exec upload However on CI, the Docker container only accepts 'npm run-script XXX' or 'bundle exec rake YYY'. Add a npm script 'screenshots-all' invoking 'grunt screenshots-all'. Add a rake task 'commons_upload'. I have added a basic check to make sure environment variables are properly set before invoking the upload script. Thus on CI the usage will become: npm install npm run-script screenshots-all bundle install bundle exec rake commons_upload Which match the CI convention. Bug: T189122 Change-Id: I221ed8d6178dd036eac287f0f811834a6d4ffd22 --- Rakefile | 13 +++++++++++++ package.json | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index 13fce2f843..adc66d2fdb 100644 --- a/Rakefile +++ b/Rakefile @@ -13,3 +13,16 @@ task :default => [:test] desc 'Run all build/tests commands (CI entry point)' task :test => [:rubocop] + +desc 'Upload screenshots to commons.wikimedia.org' +task :commons_upload do + require 'commons_upload' + required_envs = %w[ + MEDIAWIKI_API_UPLOAD_URL + MEDIAWIKI_USER + MEDIAWIKI_PASSWORD + ] + has_all_envs = required_envs.all? { |env| ENV.key?(env) } + fail "Requires env variables:\n#{required_envs}" unless has_all_envs + CommonsUpload.images +end diff --git a/package.json b/package.json index 55abb61623..5aa9f443e0 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,8 @@ "scripts": { "test": "grunt test", "doc": "jsduck", - "postdoc": "grunt copy:jsduck" + "postdoc": "grunt copy:jsduck", + "screenshots-all": "grunt screenshots-all" }, "devDependencies": { "babel-polyfill": "6.9.1",