You are viewing a plain text version of this content. The canonical link for it is here.
Posted to submarine-dev@hadoop.apache.org by zt...@apache.org on 2019/09/23 07:14:43 UTC

[hadoop-submarine] branch master updated: SUBMARINE-194. Provide Dockerfile to ease the script usage

This is an automated email from the ASF dual-hosted git repository.

ztang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hadoop-submarine.git


The following commit(s) were added to refs/heads/master by this push:
     new e161000  SUBMARINE-194. Provide Dockerfile to ease the script usage
e161000 is described below

commit e161000310763fc61bbfddaa52b46a54872cc0fd
Author: Zhankun Tang <zt...@apache.org>
AuthorDate: Mon Sep 23 14:49:31 2019 +0800

    SUBMARINE-194. Provide Dockerfile to ease the script usage
    
    ### What is this PR for?
    Provide Dockerfile to ease the usage of the cicd scripts.
    
    ### What type of PR is it?
    Feature
    
    ### What is the Jira issue?
    https://issues.apache.org/jira/browse/SUBMARINE-194
    
    ### How should this be tested?
    1. build the image
    2. run the image and do tasks like merge PR
    
    ### Questions:
    * Does the licenses files need update? No
    * Is there breaking changes for older versions? No
    * Does this needs documentation? Yes
    
    Author: Zhankun Tang <zt...@apache.org>
    
    Closes #6 from tangzhankun/submarine-194 and squashes the following commits:
    
    3ee3e12 [Zhankun Tang] SUBMARINE-194. Provide Dockerfile to ease the script usage like merge_submarine_pr.py.
---
 dev-support/cicd/Dockerfile | 30 ++++++++++++++++++
 dev-support/cicd/README.md  | 28 +++++++++--------
 dev-support/cicd/entry.sh   | 77 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 122 insertions(+), 13 deletions(-)

diff --git a/dev-support/cicd/Dockerfile b/dev-support/cicd/Dockerfile
new file mode 100644
index 0000000..e2475d0
--- /dev/null
+++ b/dev-support/cicd/Dockerfile
@@ -0,0 +1,30 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+FROM ubuntu:16.04
+RUN \
+  apt-get update && \
+  apt-get install -y vim python git python-pip && \
+  pip install jira
+RUN \
+  git clone https://gitbox.apache.org/repos/asf/hadoop-submarine.git && \
+  cd hadoop-submarine && \
+  git remote rename origin apache && \
+  git remote add apache-github https://github.com/apache/hadoop-submarine.git
+ADD \
+  entry.sh /entry.sh
+ENV \
+  SUBMARINE_HOME=/hadoop-submarine
+CMD /entry.sh
diff --git a/dev-support/cicd/README.md b/dev-support/cicd/README.md
index 68a0678..b144007 100644
--- a/dev-support/cicd/README.md
+++ b/dev-support/cicd/README.md
@@ -13,18 +13,20 @@
 -->
 # Introduction
 This cicd directory contains several scripts to ease code and release management.
+To use them more easily, we provide a Docker image to help committer to handle tasks like committing code and release build.
 
-## Merge PRs From Github
-The "merge_submarine_pr.py" script is usd for merge PRs without access the github web portal. It can also automatically merge activities from github to apache Jira.
+```
+cd <path-to-submarine-home>/dev-support/cicd
+docker build -t submarine-cicd .
+docker run -it --rm submarine-cicd
+```
 
-As a committer, you should create a dedicated directory to do below steps instead of using existing development repo. Doing below steps in a Docker container with python2 and jira (pip install jira) is preferred:
-
-1. git clone https://gitbox.apache.org/repos/asf/hadoop-submarine.git
-2. cd hadoop-submarine
-3. git remote rename origin apache
-4. git remote add apache-github https://github.com/apache/hadoop-submarine.git
-5. git config --local --add user.name {name}
-6. git config --local --add user.email {username}@apache.org
-7. echo -e "JIRA_USERNAME={jira_username}\nJIRA_PASSWORD={jira_password}" >> ~/.bashrc
-8. source ~/.bashrc
-9. dev-support/cicd/merge_submarine_pr.py
+And you'll see output like below and then you can decide what to accomplish.
+```
+$ docker run -it --rm submarine-cicd
+Menu:
+	1. Merge PR
+Enter Menu ID:1
+==== Merge PR Begin ====
+Enter Your Apache JIRA User name:
+```
diff --git a/dev-support/cicd/entry.sh b/dev-support/cicd/entry.sh
new file mode 100755
index 0000000..958947b
--- /dev/null
+++ b/dev-support/cicd/entry.sh
@@ -0,0 +1,77 @@
+#!/bin/bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+set -e
+
+function start_menu(){
+  printf "Menu:\n"
+  printf "\t1. Merge PR\n"
+  read -p "Enter Menu ID:" menu_id
+  case $menu_id in
+    "1")
+      merge_pr
+    ;;
+    "*")
+      printf "unknown. Exiting."
+    ;;
+  esac
+}
+
+function merge_pr(){
+  printf "==== Merge PR Begin ====\n"
+  jira_name="n"
+  jira_pwd="p"
+  apache_id="id"
+  apache_name="name"
+
+  if [ -z "$JIRA_USERNAME" ]; then
+    read -p "Enter Your Apache JIRA User name: "  jira_name
+  else
+    jira_name=$JIRA_USERNAME
+  fi
+  echo "Got JIRA name: ${jira_name}"
+
+  if [ -z "$JIRA_PASSWORD" ]; then
+    read -s -p "Enter Your Apache JIRA User passwd: "  jira_pwd
+  else
+    jira_pwd=$JIRA_PASSWORD
+  fi
+
+  if [ -z "$APACHE_ID" ]; then
+    printf "\n"
+    read -p "Enter Your Apache committer ID: "  apache_id
+  else
+    apache_id=$APACHE_ID
+  fi
+  echo "Got Apache ID: ${apache_id}"
+
+  if [ -z "$APACHE_NAME" ]; then
+    read -p "Enter Your Apache committer name: "  apache_name
+  else
+    apache_name=$APACHE_NAME
+  fi
+  echo "Got Apache name: ${apache_name}"
+
+  cd $SUBMARINE_HOME
+  git pull
+  git config user.name "${apache_name}"
+  git config user.email "${apache_id}@apache.org"
+  export JIRA_USERNAME=${jira_name}
+  export JIRA_PASSWORD=${jira_pwd}
+  python dev-support/cicd/merge_submarine_pr.py
+  printf "==== Merge PR END ====\n"
+}
+
+start_menu