How to deploy code/Adding a new submodule

From Wikitech
Jump to: navigation, search
You already deployed your new extension to the beta cluster (read instructions) and tested it for weeks, right? Otherwise, STOP and talk to experts.

Normally, submodules by created by the release tool, but that requires some planning ahead, and does not work for submodules which use a non-standard setup such as non-conventionally named deployment branches. When adding such an extension/skin/library for the first time (ie. it was never deployed before), you need to add a submodule to the core deployment branches:

$ cd mediawiki/core            # Go to your checkout of core

# Set up a local wmf/1.27.0-wmf.1 branch that tracks the remote
# You only need to do this once for each branch; if you've already got a wmf/1.27.0-wmf.1 branch, you can skip this step
# If you get an error, try 'git remote update' or 'git fetch' first
$ git checkout --track origin/wmf/1.27.0-wmf.1
Branch wmf/1.27.0-wmf.1 set up to track remote branch wmf/1.27.0-wmf.1 from origin.

# Make sure you have an up-to-date copy of the deployment branch. The submodule update might take a while.
$ git pull
$ git submodule update --init --recursive

# Add a submodule for your extension (this will check out the extension's master branch if the directory did not exist, otherwise will just use what's there)
$ git submodule add extensions/MyCoolExtension
Cloning into extensions/MyCoolExtension...
# Check the diff. Make sure the .gitmodules entry is in line with the others (you might need to edit it and set the branch),
# and that the subproject commit hash points to the version you want deployed (which is usually the head of master)
$ git diff --cached
diff --git a/.gitmodules b/.gitmodules
index 3ab3d48..9a4cc66 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -346,3 +346,6 @@
 [submodule "extensions/PrefSwitch"]
        path = extensions/PrefSwitch
        url =
+[submodule "extensions/MyCoolExtension"]
+       path = extensions/MyCoolExtension
+       url =
diff --git a/extensions/MyCoolExtension b/extensions/MyCoolExtension
new file mode 160000
index 0000000..46727ad
--- /dev/null
+++ b/extensions/MyCoolExtension
@@ -0,0 +1 @@
+Subproject commit 46727ad74adda33621323deb2bebdc2527cb4917

# Commit the submodule addition and submit it for review
$ git commit -a -m "Add MyCoolExtension submodule"
$ git review
# If you don't want or need this to be reviewed, you can +2 your own commit if you are in the wmf-deployment group

NOTE: When adding a new extension to one branch, you also need to add the extension to any other branches in use on the cluster (typically the wmf.{N-1} branch), even if the extension will not be enabled on any wikis running that branch. Otherwise the localization cache builder will fail. It is best to add to the N-1 branch even if when is not used on the cluster anymore, to avoid catastrophic error in case of an unexpected train rollback.

When adding (and removing) an extension (skin etc.), you need to update the files wmf-config/extension-list and config.json, see How to deploy code#Add new extension to extension-list and release tool