Repository: learningequality/kolibri

Issue:
Isolate the Kolibri integration testing spreadsheet build inside the docker environment
### Observed behavior
I have this [PR](https://github.com/learningequality/kolibri/pull/4544) that's using a virtualenv to run the scripts and generate the Integration testing spreadsheet at the BuildKite.

@indirectlylit [comment](https://github.com/learningequality/kolibri/pull/4544#discussion_r254383845) to that PR to isolate the build inside the docker environment.

### Expected behavior

>* the build would be isolated in a docker environment, so a python virtualenv would not be needed
>* the dependencies for this pipeline step would be defined in a pip `requirements.txt` file or a Pipenv `Pipfile`
>* the individual steps (install dependencies, run `create_integration_testing_worksheet.py`, upload artifacts) are specified as multiple commands in the 'Create integration testing' block of the `pipeline.yml` file 



Discussion:

Resolving patch:
diff --git a/kolibri/__init__.py b/kolibri/__init__.py
--- a/kolibri/__init__.py
+++ b/kolibri/__init__.py
@@ -15,7 +15,7 @@
 
 #: This may not be the exact version as it's subject to modification with
 #: get_version() - use ``kolibri.__version__`` for the exact version string.
-VERSION = (0, 12, 4, "beta", 0)
+VERSION = (0, 13, 0, "alpha", 0)
 
 __author__ = "Learning Equality"
 __email__ = "info@learningequality.org"


Test patch:
diff --git a/.buildkite/create_integration_testing_worksheet.py b/.buildkite/create_integration_testing_worksheet.py
--- a/.buildkite/create_integration_testing_worksheet.py
+++ b/.buildkite/create_integration_testing_worksheet.py
@@ -35,9 +35,9 @@
     SHEET_PARENT_CONTAINER_ID = "10bMsasxKvpi_9U1NU9rq7YBnFBiCkYrc"
 
 if SHEET_TAG == "" or SHEET_TAG is None:
-    buildkite_branch = os.getenv("BUILDKITE_PULL_REQUEST_BASE_BRANCH")
-    if buildkite_branch != "" or buildkite_branch is not None:
-        SHEET_TAG = buildkite_branch
+    buildkite_base_branch = os.getenv("BUILDKITE_PULL_REQUEST_BASE_BRANCH")
+    if buildkite_base_branch != "" or buildkite_base_branch is not None:
+        SHEET_TAG = buildkite_base_branch
     else:
         SHEET_TAG = "develop"
 
@@ -106,6 +106,7 @@ def create_artifact(str_arg):
     file = open(txt_path, "w")
     file.write(str_arg)
     file.close()
+    os.chmod(txt_path, 0o666)
 
 
 def fetch_feature_files():
@@ -159,7 +160,7 @@ def fetch_feature_files():
 def sheet_insert_rows(sheet, wrk_sheet, start_index=0, end_index=0):
     """
         REF: https://github.com/burnash/gspread
-        I reuse the gspread function to make this API request.
+        I reuse and modify the gspread function to make this API request.
     """
     body = {
         "requests": [
@@ -181,7 +182,7 @@ def sheet_insert_rows(sheet, wrk_sheet, start_index=0, end_index=0):
 def rename_worksheet(sheet, wrk_sheet, sheet_name):
     """
         REF: https://github.com/burnash/gspread
-        I reuse the gspread function to make this API request.
+        I reuse and modify the gspread function to make this API request.
     """
     body = {
         "requests": [
@@ -199,7 +200,7 @@ def rename_worksheet(sheet, wrk_sheet, sheet_name):
 def search_file_name(file_name):
     """
         REF: https://github.com/burnash/gspread
-        I reuse the gspread function to make this API request.
+        I reuse  and modify the gspread function to make this API request.
     """
     self = G_ACCESS
     files = []
@@ -241,7 +242,7 @@ def create_sheet_container(file_id, dir_name):
 def sheet_copy(file_id, dist_id, title=None, copy_permissions=False):
     """
         REF: https://github.com/burnash/gspread
-        I reuse the gspread function to make this request.
+        I reuse and modify the gspread function to make this request.
     """
     self = G_ACCESS
 
diff --git a/docker/build_testing_sheet.dockerfile b/docker/build_testing_sheet.dockerfile
new file mode 100644
--- /dev/null
+++ b/docker/build_testing_sheet.dockerfile
@@ -0,0 +1,22 @@
+FROM ubuntu:xenial
+
+# Build an unsigned package
+
+RUN apt-get -y update && \
+    DEBIAN_FRONTEND=noninteractive apt-get install -y \
+        python3 build-essential \
+        libssl-dev libffi-dev \
+        python3-pip tzdata && dpkg-reconfigure tzdata
+
+COPY ./integration_testing /kolibri/integration_testing
+COPY ./requirements /kolibri/requirements
+COPY ./.buildkite /kolibri/.buildkite
+
+RUN pip3 install -r ./kolibri/requirements/testing_sheet.txt
+
+CMD export BUILDKITE_PULL_REQUEST_BASE_BRANCH=$BUILDKITE_PULL_REQUEST_BASE_BRANCH && \
+    export BUILDKITE_BRANCH=$BUILDKITE_BRANCH && \
+    export BUILDKITE_TAG=$BUILDKITE_TAG && \
+    python3 ./kolibri/.buildkite/create_integration_testing_worksheet.py && \
+    cd /kolibri/.buildkite && \
+    cp *.txt /dist/
diff --git a/requirements/testing_sheet.txt b/requirements/testing_sheet.txt
new file mode 100644
--- /dev/null
+++ b/requirements/testing_sheet.txt
@@ -0,0 +1,8 @@
+
+# These are the requirements to create an Integration testing Spreadsheet
+
+oauth2client==4.1.3
+pyOpenSSL==18.0.0
+gspread==3.1.0
+requests==2.15.1
+idna==2.7