Bug 1585661 - Update mach geckoview-docs command to upload markdown as well as javadoc. r=agi
☠☠ backed out by 2fe825d522b2 ☠ ☠
authorEmily Toop <etoop@mozilla.com>
Thu, 14 Nov 2019 14:23:46 +0000
changeset 501944 126b374778190a9fe47ba3b6077f89309a15c270
parent 501943 e4d22a4ff32104f707015395dac47c8707fc1c04
child 501945 915910348bceea4cf865693859da04efabb12d22
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersagi
bugs1585661
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1585661 - Update mach geckoview-docs command to upload markdown as well as javadoc. r=agi Slightly reorganize file structure to make copying files over easier. Needs to land in conjunction with https://github.com/mozilla/geckoview/pull/94, which should land first. Differential Revision: https://phabricator.services.mozilla.com/D48564
mobile/android/docs/Gemfile
mobile/android/docs/_config.yml
mobile/android/docs/geckoview/Gemfile
mobile/android/docs/geckoview/README.md
mobile/android/docs/geckoview/_config.yml
mobile/android/mach_commands.py
testing/mozharness/configs/builds/releng_sub_android_configs/64_geckoview_docs.py
rename from mobile/android/docs/geckoview/Gemfile
rename to mobile/android/docs/Gemfile
rename from mobile/android/docs/geckoview/_config.yml
rename to mobile/android/docs/_config.yml
--- a/mobile/android/docs/geckoview/_config.yml
+++ b/mobile/android/docs/_config.yml
@@ -11,8 +11,10 @@ tags: [GeckoView,Gecko,mozilla,android,W
 # Build settings
 markdown: kramdown
 remote_theme: pmarsceill/just-the-docs@aa0d8f1d400b051c090b04b3e530c2848afb585c
 plugins:
   - jekyll-feed
   - jekyll-seo-tag
 
 search_enabled: true
+
+source: ./geckoview
\ No newline at end of file
deleted file mode 100644
--- a/mobile/android/docs/geckoview/README.md
+++ /dev/null
@@ -1,41 +0,0 @@
-This GitHub repository contains the documentation for [GeckoView][8]. If you are looking for the code for GeckoView you can find it at [Mozilla Central][9].
-
-If there is documentation that you feel is missing, or an existing document doesn't cover the aspect that you are looking for, please request it by [raising an issue][10].
-
-If you have a GeckoView bug that you want to raise, please do so on our [Bugzilla][11].
-
-## Get Started with GeckoView
-
-* [GeckoView Quick Start Guide][1]
-* [Interacting with Web content and WebExtension][7]
-
-
-## API Documentation
-
-* [Changelog][2]
-* [API][12]
-
-## Get Started as a Contributor
-
-* [GeckoView Contributor Quick Start Guide][3]
-* [Mozilla Central Quick Start Guide][4]
-* [Mozilla Central Contributor Guide][5]
-* [Guide to Native Debugging in Android Studio][6]
-
-
-## More information
-You can read more about GeckoView on the [wiki](https://wiki.mozilla.org/Mobile/GeckoView).
-
-
-[1]:https://geckoview.dev/consumer/docs/geckoview-quick-start
-[2]:https://geckoview.dev/javadoc/mozilla-central/org/mozilla/geckoview/doc-files/CHANGELOG
-[3]:https://geckoview.dev/contributor/geckoview-quick-start
-[4]:https://geckoview.dev/contributor/mc-quick-start
-[5]:https://geckoview.dev/contributor/contributing-to-mc
-[6]:https://geckoview.dev/contributor/native-debugging
-[7]:https://geckoview.dev/consumer/docs/web-extensions
-[8]:https://geckoview.dev
-[9]:https://searchfox.org/mozilla-central/source/mobile/android/geckoview
-[10]:https://github.com/mozilla/geckoview/issues
-[11]:https://bugzilla.mozilla.org/enter_bug.cgi?product=GeckoView
-[12]:https://geckoview.dev/javadoc/mozilla-central/index.html
--- a/mobile/android/mach_commands.py
+++ b/mobile/android/mach_commands.py
@@ -1,13 +1,14 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from __future__ import absolute_import, print_function, unicode_literals
+from distutils.file_util import copy_file
 
 import argparse
 import logging
 import os
 
 import mozpack.path as mozpath
 
 from mozbuild.base import (
@@ -184,25 +185,28 @@ REMOVED/DEPRECATED: Use 'mach lint --lin
 
         return 0
 
     @SubCommand('android', 'geckoview-docs',
                 """Create GeckoView javadoc and optionally upload to Github""")
     @CommandArgument('--archive', action='store_true',
                      help='Generate a javadoc archive.')
     @CommandArgument('--upload', metavar='USER/REPO',
-                     help='Upload generated javadoc to Github, '
+                     help='Upload geckoview documentation to Github, '
                      'using the specified USER/REPO.')
     @CommandArgument('--upload-branch', metavar='BRANCH[/PATH]',
-                     default='gh-pages/javadoc',
-                     help='Use the specified branch/path for commits.')
+                     default='gh-pages',
+                     help='Use the specified branch/path for documentation commits.')
+    @CommandArgument('--javadoc-path', metavar='/PATH',
+                     default='javadoc',
+                     help='Use the specified path for javadoc commits.')
     @CommandArgument('--upload-message', metavar='MSG',
                      default='GeckoView docs upload',
                      help='Use the specified message for commits.')
-    def android_geckoview_docs(self, archive, upload, upload_branch,
+    def android_geckoview_docs(self, archive, upload, upload_branch, javadoc_path,
                                upload_message):
 
         tasks = (self.substs['GRADLE_ANDROID_GECKOVIEW_DOCS_ARCHIVE_TASKS'] if archive or upload
                  else self.substs['GRADLE_ANDROID_GECKOVIEW_DOCS_TASKS'])
 
         ret = self.gradle(tasks, verbose=True)
         if ret or not upload:
             return ret
@@ -232,43 +236,61 @@ REMOVED/DEPRECATED: Use 'mach lint --lin
                 f.write(req.json()['secret']['content'])
 
             # Turn off strict host key checking so ssh does not complain about
             # unknown github.com host. We're not pushing anything sensitive, so
             # it's okay to not check GitHub's host keys.
             env['GIT_SSH_COMMAND'] = 'ssh -i "%s" -o StrictHostKeyChecking=no' % keyfile
 
         # Clone remote repo.
-        branch, _, branch_path = upload_branch.partition('/')
+        branch = upload_branch.format(**fmt)
         repo_url = 'git@github.com:%s.git' % upload
         repo_path = mozpath.abspath('gv-docs-repo')
-        self.run_process(['git', 'clone', '--branch', branch, '--depth', '1',
+        self.run_process(['git', 'clone', '--branch', upload_branch, '--depth', '1',
                           repo_url, repo_path], append_env=env, pass_thru=True)
         env['GIT_DIR'] = mozpath.join(repo_path, '.git')
         env['GIT_WORK_TREE'] = repo_path
         env['GIT_AUTHOR_NAME'] = env['GIT_COMMITTER_NAME'] = 'GeckoView Docs Bot'
         env['GIT_AUTHOR_EMAIL'] = env['GIT_COMMITTER_EMAIL'] = 'nobody@mozilla.com'
 
+        # Copy over user documentation.
+        import mozfile
+
+        docs_path = mozpath.join(self.topsrcdir, 'mobile', 'android', 'docs')
+
+        # Some files need to be in the GH repo root folder and should be
+        # copied over directly
+        root_docs = ["_config.yml", "Gemfile"]
+        for filename in root_docs:
+            src_filepath = mozpath.join(docs_path, filename)
+            dst_filepath = mozpath.join(repo_path, filename)
+            copy_file(src_filepath, dst_filepath, update=1)
+
+        # Remove existing geckoview docs and replace with the local copy
+        src_path = mozpath.join(docs_path, 'geckoview')
+        docs_path = mozpath.join(repo_path, 'geckoview')
+        mozfile.remove(docs_path)
+        os.system("rsync -aruz {} {}".format(src_path, repo_path))
+
         # Extract new javadoc to specified directory inside repo.
-        import mozfile
         src_tar = mozpath.join(self.topobjdir, 'gradle', 'build', 'mobile', 'android',
                                'geckoview', 'libs', 'geckoview-javadoc.jar')
-        dst_path = mozpath.join(repo_path, branch_path.format(**fmt))
+        dst_path = mozpath.join(docs_path, javadoc_path)
         mozfile.remove(dst_path)
         mozfile.extract_zip(src_tar, dst_path)
 
         # Commit and push.
         self.run_process(['git', 'add', '--all'], append_env=env, pass_thru=True)
         if self.run_process(['git', 'diff', '--cached', '--quiet'],
                             append_env=env, pass_thru=True, ensure_exit_code=False) != 0:
             # We have something to commit.
             self.run_process(['git', 'commit',
                               '--message', upload_message.format(**fmt)],
                              append_env=env, pass_thru=True)
-            self.run_process(['git', 'push', 'origin', 'gh-pages'],
+            self.run_process(['git', 'push', 'origin', branch],
                              append_env=env, pass_thru=True)
 
         mozfile.remove(repo_path)
         if secret:
             mozfile.remove(keyfile)
         return 0
 
     @Command('gradle', category='devenv',
--- a/testing/mozharness/configs/builds/releng_sub_android_configs/64_geckoview_docs.py
+++ b/testing/mozharness/configs/builds/releng_sub_android_configs/64_geckoview_docs.py
@@ -4,14 +4,15 @@ config = {
     'multi_locale_config_platform': 'android',
     # geckoview-docs doesn't produce a package. So don't collect package metrics.
     'disable_package_metrics': True,
     'postflight_build_mach_commands': [
         ['android',
          'geckoview-docs',
          '--archive',
          '--upload', 'mozilla/geckoview',
-         '--upload-branch', 'gh-pages/javadoc/{project}',
-         '--upload-message', 'Update {project} javadoc to rev {revision}',
+         '--upload-branch', 'gh-pages'
+         '--javadoc-path', 'javadoc/{project}',
+         '--upload-message', 'Update {project} documentation to rev {revision}',
         ],
     ],
     'max_build_output_timeout': 0,
 }