csantanapr closed pull request #22: switch to go 1.10 URL: https://github.com/apache/incubator-openwhisk-runtime-go/pull/22
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/.gitattributes b/.gitattributes index b19d1c0..0df2192 100644 --- a/.gitattributes +++ b/.gitattributes @@ -19,13 +19,6 @@ *.jar binary *.png binary -# python files not having the .py extension -tools/cli/wsk text eol=lf -tools/cli/wskadmin text eol=lf # bash files not having the .sh extension -tools/vagrant/simple/wsk text eol=lf gradlew text eol=lf -core/javaAction/proxy/gradlew text eol=lf -tools/vagrant/hello text eol=lf -sdk/docker/client/action text eol=lf diff --git a/.gitignore b/.gitignore index b81c91e..a35ea03 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,12 @@ +# Mac +.DS_Store + .gradle/ .gogradle/ *.log vendor/ -core/proxy -core/actionloop-golang/proxy -core/actionloop-golang/gobuild -core/actionloop/proxy +actionProxyLoop/proxy +golang1.10/proxy openwhisk/_test/exec openwhisk/_test/hi openwhisk/_test/hello_greeting diff --git a/.travis.yml b/.travis.yml index 8b29734..1d716d0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,18 +16,29 @@ sudo: required language: go -go: - - "1.9" +go: +- 1.10.1 services: - docker - notifications: email: true - before_install: - "./tools/travis/setup.sh" install: true script: - "./tools/travis/build.sh && ./tools/travis/test.sh" -after_failure: "cat /home/travis/gopath/src/github.com/apache/incubator-openwhisk-runtime-go/.gogradle/reports/test/index.html" - +after_failure: cat .gogradle/reports/test/index.html +deploy: +- provider: script + script: "./tools/travis/publish.sh openwhisk ${TRAVIS_TAG%@*} ${TRAVIS_TAG##*@}" + on: + tags: true + all_branches: true +- provider: script + script: "./tools/travis/publish.sh openwhisk 1.10 master" + on: + branch: master +env: + global: + - secure: GNKMZjEW1BKBb8NSiFB/Bogh0V5co5TefLLaj9oYJrKCP8rheFY4mWwINR74dYwSFIV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H9Rj6d6tVLfSG35gRXAuwoouh6iXgXDiPu5dLNWzwazyEiIw2Pr10QWdZGJ7EwqJiPdw640wevfk8WQiwkCyduyII6OYMdZUwAjEDP4sehHoP61WPz2k8ollfiUIoTjzRrF9eO0Ni0qnz0/lBUw9zSpMZbD46KG5v/29dRLrvj9NYNAUx2KU57O080gZxIBgp1eI3WOX/Imia1phsZkP4Q7wtID03UOsiPs= diff --git a/README.md b/README.md index 7afddd4..e74f7df 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,8 @@ --> # Apache OpenWhisk Runtime for Go (and Generic executables) +:warning: Work in progress :warning: + This is an OpenWhisk runtime for Golang and Generic executables. - [Building it](#building) @@ -30,17 +32,33 @@ This is an OpenWhisk runtime for Golang and Generic executables. You need a linux environment, with Java and Docker installed to build the sources. -To build and run the test suite, use: +Prerequisites for running build and tests: +- docker +- jdk +- go 1.10.1 +- bc (sudo apt-get install bc) -`./gradlew distDocker` +To compile go proxy +``` +./gradlew build +``` +To build the docker images after compiling go proxy +``` +./gradlew distDocker +``` This will build the images: -* `actionloop-golang-v1.9`: an image supporting Go sources +* `actionloop-golang-v1.10`: an image supporting Go sources * `actionloop`: the base image, supporting generic executables The `actionloop` image is used as a basis also for the `actionloop-swift` image. It can be used for supporting other compiled programming languages as long as they implement a `compile` script and the *action loop* protocol described below. +To run tests +``` +./gradlew test --info +``` + <a name="gosources"/> # Using it with Go Sources @@ -95,7 +113,7 @@ If you have docker, you can do it this way: - place your sources under `src` folder in current directory - create an `out` folder to receive the binary -- run: `docker run -v $PWD/src:/src -v $PWD/out openwhisk/actionloop-golang-v1.9 compile` +- run: `docker run -v $PWD/src:/src -v $PWD/out openwhisk/actionloop-golang-v1.10 compile` - you can now use `wsk` to publish the `out/main` executable If you have a function named in a different way, for example `Hello`, specify `compile hello`. It will produce a binary named `out/hello` diff --git a/actionProxyLoop/Dockerfile b/actionProxyLoop/Dockerfile new file mode 100644 index 0000000..d7f65fa --- /dev/null +++ b/actionProxyLoop/Dockerfile @@ -0,0 +1,9 @@ +FROM golang:1.10.1 +RUN apt-get update && apt-get install -y \ + curl \ + jq \ + && rm -rf /var/lib/apt/lists/* +RUN mkdir /action +WORKDIR /action +ADD proxy /proxy +CMD /proxy diff --git a/actionProxyLoop/build.gradle b/actionProxyLoop/build.gradle new file mode 100644 index 0000000..b69ec48 --- /dev/null +++ b/actionProxyLoop/build.gradle @@ -0,0 +1,2 @@ +ext.dockerImageName = 'actionloop' +apply from: '../gradle/docker.gradle' diff --git a/build.gradle b/build.gradle index 8e261f0..0f7bfec 100644 --- a/build.gradle +++ b/build.gradle @@ -21,11 +21,9 @@ golang { } -build.dependsOn check - build.dependsOn vendor build { targetPlatform = ['linux-amd64'] - go 'build -o core/proxy main/proxy.go' + go 'build -o actionProxyLoop/proxy main/proxy.go' } diff --git a/core/gobuild b/common/gobuild.sh similarity index 100% rename from core/gobuild rename to common/gobuild.sh diff --git a/core/.gitkeep b/core/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/core/actionloop-golang/Dockerfile b/core/actionloop-golang/Dockerfile deleted file mode 100644 index c419a7a..0000000 --- a/core/actionloop-golang/Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -FROM ibmcom/ubuntu:14.04 -RUN apt-get -y update && apt-get -y upgrade && apt-get -y install curl jq git -RUN mkdir /action /home/go -WORKDIR /action -ADD proxy /proxy -ADD gobuild /bin/compile -RUN curl https://dl.google.com/go/go1.9.4.linux-amd64.tar.gz | tar xzvf - -C /usr/local -ENV GOROOT /usr/local/go -ENV GOPATH /home/go -ENV COMPILER /bin/compile -ENV PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/go/bin:/home/go/bin -RUN go get github.com/apache/incubator-openwhisk-client-go/whisk -CMD /proxy diff --git a/core/actionloop-golang/build.gradle b/core/actionloop-golang/build.gradle deleted file mode 100644 index e2935bd..0000000 --- a/core/actionloop-golang/build.gradle +++ /dev/null @@ -1,17 +0,0 @@ -ext.dockerImageName = 'actionloop-golang-v1.9' -apply from: '../../gradle/docker.gradle' - -distDocker.dependsOn ':build' -distDocker.dependsOn 'copyProxy' -distDocker.dependsOn 'copyCompiler' - - -task copyProxy(type: Copy) { - from '../proxy' - into '.' -} - -task copyCompiler(type: Copy) { - from '../gobuild' - into '.' -} diff --git a/core/actionloop/Dockerfile b/core/actionloop/Dockerfile deleted file mode 100644 index ee0f1bd..0000000 --- a/core/actionloop/Dockerfile +++ /dev/null @@ -1,6 +0,0 @@ -FROM ibmcom/ubuntu:14.04 -RUN apt-get -y update && apt-get -y upgrade && apt-get -y install curl jq -RUN mkdir /action -WORKDIR /action -ADD proxy /proxy -CMD /proxy diff --git a/core/actionloop/build.gradle b/core/actionloop/build.gradle deleted file mode 100644 index da826b0..0000000 --- a/core/actionloop/build.gradle +++ /dev/null @@ -1,10 +0,0 @@ -ext.dockerImageName = 'actionloop' -apply from: '../../gradle/docker.gradle' - -distDocker.dependsOn ':build' -distDocker.dependsOn 'copyProxy' - -task copyProxy(type: Copy) { - from '../proxy' - into '.' -} diff --git a/golang1.10/Dockerfile b/golang1.10/Dockerfile new file mode 100644 index 0000000..03be150 --- /dev/null +++ b/golang1.10/Dockerfile @@ -0,0 +1,13 @@ +FROM golang:1.10.1 +RUN apt-get update && apt-get install -y \ + curl \ + jq \ + git \ + && rm -rf /var/lib/apt/lists/* +RUN mkdir /action /home/go +WORKDIR /action +ADD proxy /proxy +ADD gobuild.sh /bin/compile +ENV COMPILER /bin/compile +RUN go get github.com/apache/incubator-openwhisk-client-go/whisk +CMD /proxy diff --git a/golang1.10/build.gradle b/golang1.10/build.gradle new file mode 100644 index 0000000..3244c03 --- /dev/null +++ b/golang1.10/build.gradle @@ -0,0 +1,22 @@ +ext.dockerImageName = 'actionloop-golang-v1.10' +apply from: '../gradle/docker.gradle' + +distDocker.dependsOn 'copyProxy' +distDocker.dependsOn 'copyCompiler' +distDocker.finalizedBy('cleanup') + + +task copyProxy(type: Copy) { + from '../actionProxyLoop/proxy' + into '.' +} + +task copyCompiler(type: Copy) { + from '../common/gobuild.sh' + into '.' +} + +task cleanup(type: Delete) { + delete 'proxy' + delete 'gobuild.sh' +} diff --git a/openwhisk/compiler_test.go b/openwhisk/compiler_test.go index 4d2b5b7..d6a0f7a 100644 --- a/openwhisk/compiler_test.go +++ b/openwhisk/compiler_test.go @@ -26,7 +26,7 @@ import ( func Example_compileAction_wrong() { sys("_test/precompile.sh", "hello.sh", "0") log, _ := ioutil.TempFile("", "log") - ap := NewActionProxy("./action/0", "../core/gobuild", log) + ap := NewActionProxy("./action/0", "../common/gobuild.sh", log) fmt.Println(ap.CompileAction("_test/compile/0/exec", "exec", "")) // Output: // exit status 1 @@ -40,7 +40,7 @@ func Example_isCompiled() { fmt.Println(isCompiled(dir, "exec")) log, _ := ioutil.TempFile("", "log") - ap := NewActionProxy("./action/c", "../core/gobuild", log) + ap := NewActionProxy("./action/c", "../common/gobuild.sh", log) ap.CompileAction("main", abs("_test/compile/c/exec"), "") fmt.Println(isCompiled(file, "main")) @@ -61,7 +61,7 @@ func Example_isCompiled() { func Example_compileAction_singlefile_main() { sys("_test/precompile.sh", "hello.src", "1") log, _ := ioutil.TempFile("", "log") - ap := NewActionProxy("./action/1", "../core/gobuild", log) + ap := NewActionProxy("./action/1", "../common/gobuild.sh", log) fmt.Println(ap.CompileAction("main", abs("_test/compile/1/exec"), "")) sys("_test/postcompile.sh", "_test/compile/1/exec") // Output: @@ -74,7 +74,7 @@ func Example_compileAction_singlefile_main() { func Example_compileAction_singlefile_main_out() { sys("_test/precompile.sh", "hello.src", "1a") log, _ := ioutil.TempFile("", "log") - ap := NewActionProxy("./action/1a", "../core/gobuild", log) + ap := NewActionProxy("./action/1a", "../common/gobuild.sh", log) fmt.Println(ap.CompileAction("main", abs("_test/compile/1a/exec"), abs("_test/output/1a"))) sys("_test/postcompile.sh", "_test/output/1a/main") // Output: @@ -87,7 +87,7 @@ func Example_compileAction_singlefile_main_out() { func Example_compileAction_singlefile_hello() { sys("_test/precompile.sh", "hello1.src", "2") log, _ := ioutil.TempFile("", "log") - ap := NewActionProxy("./action/2", "../core/gobuild", log) + ap := NewActionProxy("./action/2", "../common/gobuild.sh", log) fmt.Println(ap.CompileAction("hello", "_test/compile/2/exec", "")) sys("_test/postcompile.sh", "_test/compile/2/exec") // Output: @@ -100,7 +100,7 @@ func Example_compileAction_singlefile_hello() { func Example_compileAction_singlefile_hello_out() { sys("_test/precompile.sh", "hello1.src", "2a") log, _ := ioutil.TempFile("", "log") - ap := NewActionProxy("./action/2a", "../core/gobuild", log) + ap := NewActionProxy("./action/2a", "../common/gobuild.sh", log) fmt.Println(ap.CompileAction("hello", "_test/compile/2a/exec", abs("_test/output/2a"))) sys("_test/postcompile.sh", "_test/output/2a/hello") // Output: @@ -113,7 +113,7 @@ func Example_compileAction_singlefile_hello_out() { func Example_compileAction_multifile_main() { sys("_test/precompile.sh", "action", "3") log, _ := ioutil.TempFile("", "log") - ap := NewActionProxy("./action/3", "../core/gobuild", log) + ap := NewActionProxy("./action/3", "../common/gobuild.sh", log) fmt.Println(ap.CompileAction("main", "_test/compile/3/", "")) sys("_test/postcompile.sh", "_test/compile/3/main") // Output: @@ -127,7 +127,7 @@ func Example_compileAction_multifile_main() { func Example_compileAction_multifile_main_out() { sys("_test/precompile.sh", "action", "3a") log, _ := ioutil.TempFile("", "log") - ap := NewActionProxy("./action/3a", "../core/gobuild", log) + ap := NewActionProxy("./action/3a", "../common/gobuild.sh", log) fmt.Println(ap.CompileAction("main", "_test/compile/3a/", abs("_test/output/3a"))) sys("_test/postcompile.sh", "_test/output/3a/main") // Output: @@ -141,7 +141,7 @@ func Example_compileAction_multifile_main_out() { func Example_compileAction_multifile_hello() { sys("_test/precompile.sh", "action", "4") log, _ := ioutil.TempFile("", "log") - ap := NewActionProxy("./action/4", "../core/gobuild", log) + ap := NewActionProxy("./action/4", "../common/gobuild.sh", log) fmt.Println(ap.CompileAction("hello", "_test/compile/4/", "")) sys("_test/postcompile.sh", "_test/compile/4/hello") // Output: @@ -154,7 +154,7 @@ func Example_compileAction_multifile_hello() { func Example_compileAction_multifile_hello_out() { sys("_test/precompile.sh", "action", "4a") log, _ := ioutil.TempFile("", "log") - ap := NewActionProxy("./action/4a", "../core/gobuild", log) + ap := NewActionProxy("./action/4a", "../common/gobuild.sh", log) fmt.Println(ap.CompileAction("hello", "_test/compile/4/", abs("_test/output/4a"))) sys("_test/postcompile.sh", "_test/output/4a/hello") // Output: diff --git a/openwhisk/initHandler_test.go b/openwhisk/initHandler_test.go index aa76f77..0634dd4 100644 --- a/openwhisk/initHandler_test.go +++ b/openwhisk/initHandler_test.go @@ -158,7 +158,7 @@ func Example_main_zipinit_nocompiler() { } func Example_compile_simple() { - comp, _ := filepath.Abs("../core/gobuild") + comp, _ := filepath.Abs("../common/gobuild.sh") ts, cur, log := startTestServer(comp) sys("_test/build.sh") doRun(ts, "") @@ -175,7 +175,7 @@ func Example_compile_simple() { } func Example_compile_withMain() { - comp, _ := filepath.Abs("../core/gobuild") + comp, _ := filepath.Abs("../common/gobuild.sh") ts, cur, log := startTestServer(comp) sys("_test/build.sh") doRun(ts, "") @@ -195,7 +195,7 @@ func Example_compile_withMain() { func Example_compile_withZipSrc() { sys("_test/zips.sh") - comp, _ := filepath.Abs("../core/gobuild") + comp, _ := filepath.Abs("../common/gobuild.sh") ts, cur, log := startTestServer(comp) doRun(ts, "") doInit(ts, initBinary("_test/action.zip", "")) @@ -221,7 +221,7 @@ func Example_compile_withZipSrc() { /* func Example_compile_withZipSrcDefault() { sys("_test/zips.sh") - comp, _ := filepath.Abs("../core/gobuild") + comp, _ := filepath.Abs("../common/gobuild.sh") ts, cur := startTestServer(comp) doRun(ts, "") doInit(ts, initBinary("_test/action.zip", "")) diff --git a/settings.gradle b/settings.gradle index 4972eb7..b7aff17 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,5 +1,5 @@ -include 'core:actionloop' -include 'core:actionloop-golang' +include 'actionProxyLoop' +include 'golang1.10' rootProject.name = 'runtime-golang' diff --git a/test/NOTES.md b/test/NOTES.md index 1546b09..462b814 100644 --- a/test/NOTES.md +++ b/test/NOTES.md @@ -27,10 +27,10 @@ TO use it: - you can run them with `cram test_actionloop.t` - and `cram test_actionloop-golang` -also you can start directy the binary without the images with +also you can start directly the binary without the images with - `./start.sh` -- or `COMPILER=../core/goproxy ./start.sh` +- or `COMPILER=../common/gobuild.sh ./start.sh` If you start them, images won't be started by the test. diff --git a/test/test_actionloop-golang.t b/test/test_actionloop-golang.t index 91d8eef..e82b49f 100644 --- a/test/test_actionloop-golang.t +++ b/test/test_actionloop-golang.t @@ -16,7 +16,7 @@ # $ export T=$TESTDIR - $ $T/start.sh actionloop-golang-v1.9 2>$T/err.log >$T/out.log + $ $T/start.sh actionloop-golang-v1.10 2>$T/err.log >$T/out.log $ $T/bin/run.sh {"error":"no action defined yet"} diff --git a/tools/travis/build.sh b/tools/travis/build.sh index d6a0f0e..037256d 100755 --- a/tools/travis/build.sh +++ b/tools/travis/build.sh @@ -33,8 +33,10 @@ IMAGE_PREFIX="testing" cd $UTILDIR scancode/scanCode.py --config scancode/ASF-Release.cfg $ROOTDIR -# Build runtime cd $ROOTDIR -TERM=dumb ./gradlew \ -distDocker \ --PdockerImagePrefix=${IMAGE_PREFIX} + +# Build/Compile go +TERM=dumb ./gradlew build + +# Build runtime image +TERM=dumb ./gradlew distDocker -PdockerImagePrefix=${IMAGE_PREFIX} diff --git a/tools/travis/publish.sh b/tools/travis/publish.sh new file mode 100755 index 0000000..3bc31e3 --- /dev/null +++ b/tools/travis/publish.sh @@ -0,0 +1,43 @@ +#!/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 -eux + +# Build script for Travis-CI. + +IMAGE_PREFIX=$1 +RUNTIME_VERSION=$2 +IMAGE_TAG=$3 + +if [ ${RUNTIME_VERSION} == "1.10" ]; then + RUNTIME="golang1.10" +elif [ ${RUNTIME_VERSION} == "1.11" ]; then + RUNTIME="golang1.11" +fi + +if [[ ! -z ${DOCKER_USER} ]] && [[ ! -z ${DOCKER_PASSWORD} ]]; then +docker login -u "${DOCKER_USER}" -p "${DOCKER_PASSWORD}" +fi + +if [[ ! -z ${RUNTIME} ]]; then +TERM=dumb ./gradlew \ +:${RUNTIME}:distDocker \ +-PdockerRegistry=docker.io \ +-PdockerImagePrefix=${IMAGE_PREFIX} \ +-PdockerImageTag=${IMAGE_TAG} +fi diff --git a/tools/travis/test.sh b/tools/travis/test.sh index 5ff94f1..81ab042 100755 --- a/tools/travis/test.sh +++ b/tools/travis/test.sh @@ -22,12 +22,9 @@ set -ex SCRIPTDIR=$(cd $(dirname "$0") && pwd) ROOTDIR="$SCRIPTDIR/../.." -WHISKDIR="$ROOTDIR/../openwhisk" - -export OPENWHISK_HOME=$WHISKDIR cd ${ROOTDIR} -TERM=dumb ./gradlew test +TERM=dumb ./gradlew test --info ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services