You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2018/01/22 21:49:28 UTC

[GitHub] mrutkows closed pull request #1: Create the basic Travis environment

mrutkows closed pull request #1: Create the basic Travis environment
URL: https://github.com/apache/incubator-openwhisk-release/pull/1
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..2cd1331
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,24 @@
+sudo: required
+
+group: deprecated-2017Q3
+
+language: scala
+
+scala:
+   - 2.11.8
+
+services:
+  - docker
+
+jobs:
+  include:
+    - stage: verify source code
+      script: ./tools/travis/verify_source_code.sh
+    - stage: deploy
+      script: ./tools/travis/setup.sh
+    - stage: package
+      script: ./tools/travis/package_source_code.sh
+
+after_failure:
+  - echo "failed build"
+  - ./tools/travis/cleanup.sh
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..2679754
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,2 @@
+FROM ubuntu
+RUN echo "Hello, Docker setup!" > hello.txt
\ No newline at end of file
diff --git a/tools/travis/cleanup.sh b/tools/travis/cleanup.sh
new file mode 100755
index 0000000..460e995
--- /dev/null
+++ b/tools/travis/cleanup.sh
@@ -0,0 +1,8 @@
+#!/usr/bin/env bash
+SUFFIX="$TRAVIS_BUILD_NUMBER"
+PR_NUM="$TRAVIS_PULL_REQUEST"
+
+mkdir -p ~/docker
+cd ~/docker
+ls
+rm *.tar
diff --git a/tools/travis/config.json b/tools/travis/config.json
new file mode 100644
index 0000000..5226aa9
--- /dev/null
+++ b/tools/travis/config.json
@@ -0,0 +1,24 @@
+{
+  "RepoList": [
+    "incubator-openwhisk",
+    "incubator-openwhisk-catalog",
+    "incubator-openwhisk-runtime-nodejs",
+    "incubator-openwhisk-cli",
+    "incubator-openwhisk-wskdeploy"
+  ],
+  "incubator_openwhisk": {
+    "hash": "fc98e9a"
+  },
+  "incubator_openwhisk_catalog": {
+    "hash": "ad24d4c"
+  },
+  "incubator_openwhisk_runtime_nodejs": {
+    "hash": "1c6c5db"
+  },
+  "incubator_openwhisk_cli": {
+    "hash": "7b78091"
+  },
+  "incubator_openwhisk_wskdeploy": {
+    "hash": "9840db4"
+  }
+}
diff --git a/tools/travis/download_source_code.sh b/tools/travis/download_source_code.sh
new file mode 100755
index 0000000..8a2cdf1
--- /dev/null
+++ b/tools/travis/download_source_code.sh
@@ -0,0 +1,36 @@
+#!/usr/bin/env bash
+
+set -e
+
+sudo apt-get install jq
+
+HOMEDIR="$(dirname "$TRAVIS_BUILD_DIR")"
+OPENWHISKDIR="$HOMEDIR/openwhisk"
+source "$TRAVIS_BUILD_DIR/tools/travis/util.sh"
+
+clone_depth=${1:-"10"}
+
+function git_clone_repo() {
+    PROJECT_NAME=$1
+    HASH=$2
+    git clone --depth $clone_depth https://github.com/apache/$PROJECT_NAME.git $OPENWHISKDIR/$PROJECT_NAME
+    cd $OPENWHISKDIR/$PROJECT_NAME
+    git reset --hard $HASH
+    rm -rf .git
+}
+
+rm -rf $OPENWHISKDIR/*
+
+CONFIG=$(read_file $TRAVIS_BUILD_DIR/tools/travis/config.json)
+repos=$(echo $(json_by_key "$CONFIG" "RepoList") | sed 's/[][]//g')
+
+for repo in $(echo $repos | sed "s/,/ /g")
+do
+    repo_name=$(echo "$repo" | sed -e 's/^"//' -e 's/"$//')
+    HASH_KEY=${repo_name//-/_}.hash
+    HASH=$(json_by_key "$CONFIG" $HASH_KEY)
+    if [ "$HASH" != "null" ]; then
+        echo "The hash for $repo_name is $HASH"
+        git_clone_repo $repo_name $HASH
+    fi
+done
diff --git a/tools/travis/package_source_code.sh b/tools/travis/package_source_code.sh
new file mode 100755
index 0000000..62df67e
--- /dev/null
+++ b/tools/travis/package_source_code.sh
@@ -0,0 +1,11 @@
+#!/usr/bin/env bash
+
+set -e
+
+cd $TRAVIS_BUILD_DIR
+./tools/travis/download_source_code.sh
+
+# TODO: add release note and license file if necessary
+echo "add release note and license file if necessary"
+
+# TODO: package all the source code and upload them into the designated directory
diff --git a/tools/travis/setup.sh b/tools/travis/setup.sh
new file mode 100755
index 0000000..d79c58c
--- /dev/null
+++ b/tools/travis/setup.sh
@@ -0,0 +1,45 @@
+#!/usr/bin/env bash
+
+set -e
+
+echo "hello openwhisk release"
+
+# Define the parent directory of TRAVIS_BUILD_DIR(the directory of the current repository) as HOMEDIR
+HOMEDIR="$(dirname "$TRAVIS_BUILD_DIR")"
+OPENWHISKDIR="$HOMEDIR/openwhisk"
+SUFFIX="$TRAVIS_BUILD_NUMBER"
+PR_NUM="$TRAVIS_PULL_REQUEST"
+PREFIX="build_testing"
+
+export OPENWHISK_HOME="$OPENWHISKDIR/incubator-openwhisk";
+
+mkdir -p $OPENWHISKDIR
+cd $OPENWHISKDIR
+
+echo "list images in setup before build"
+docker images
+
+cd $TRAVIS_BUILD_DIR
+./tools/travis/download_source_code.sh
+
+cd $OPENWHISKDIR/incubator-openwhisk
+./tools/travis/setup.sh
+TERM=dumb ./gradlew core:controller:distDocker core:invoker:distDocker -PdockerImagePrefix=$PREFIX
+
+cd ansible
+ANSIBLE_CMD="ansible-playbook -i environments/local -e docker_image_prefix=$PREFIX"
+$ANSIBLE_CMD setup.yml
+$ANSIBLE_CMD prereq.yml
+$ANSIBLE_CMD couchdb.yml
+$ANSIBLE_CMD initdb.yml
+$ANSIBLE_CMD apigateway.yml
+$ANSIBLE_CMD wipe.yml
+$ANSIBLE_CMD openwhisk.yml
+
+# Build the binaries for CLI
+cd $OPENWHISKDIR/incubator-openwhisk-cli
+./gradlew buildBinaries -PcrossCompileCLI=true
+
+# Build the binaries for wskdeploy
+cd $OPENWHISKDIR/incubator-openwhisk-wskdeploy
+./gradlew distDocker -PcrossCompileWSKDEPLOY=true
diff --git a/tools/travis/util.sh b/tools/travis/util.sh
new file mode 100755
index 0000000..7654c40
--- /dev/null
+++ b/tools/travis/util.sh
@@ -0,0 +1,11 @@
+#!/usr/bin/env bash
+
+function read_file() {
+    cat $1
+}
+
+function json_by_key() {
+    input=$1
+    key=$2
+    echo $input | jq ''.$key'' | sed -e 's/^"//' -e 's/"$//'
+}
diff --git a/tools/travis/verify_source_code.sh b/tools/travis/verify_source_code.sh
new file mode 100755
index 0000000..ef1e1a6
--- /dev/null
+++ b/tools/travis/verify_source_code.sh
@@ -0,0 +1,9 @@
+#!/usr/bin/env bash
+
+set -e
+
+cd $TRAVIS_BUILD_DIR
+./tools/travis/download_source_code.sh
+
+# TODO: verify the source code headers
+echo "TODO: verify the source code headers"


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services