Skip to content
This repository has been archived by the owner on Sep 29, 2021. It is now read-only.

Commit

Permalink
updating readme
Browse files Browse the repository at this point in the history
  • Loading branch information
mpmunasinghe authored and rabbah committed Jul 23, 2018
1 parent 921f846 commit 026e16b
Show file tree
Hide file tree
Showing 37 changed files with 1,932 additions and 1 deletion.
13 changes: 13 additions & 0 deletions .gitignore
@@ -0,0 +1,13 @@
.vscode
.idea
.iml
.balx
.ballerina

ballerina-action/Ballerina.toml
ballerina-action/ballerina-action.iml
ballerina-internal.log

.gradle/
ballerina/proxy/build/
tests/build
9 changes: 9 additions & 0 deletions .scalafmt.conf
@@ -0,0 +1,9 @@
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements; and to You under the Apache License, Version 2.0.

style = intellij
danglingParentheses = false
maxColumn = 120
docstrings = JavaDoc
rewrite.rules = [SortImports]
project.git = true
40 changes: 40 additions & 0 deletions .travis.yml
@@ -0,0 +1,40 @@
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements; and to You under the Apache License, Version 2.0.

sudo: required
group: deprecated-2017Q3
language: scala
scala:
- 2.11.11
services:
- docker

notifications:
email: false
webhooks:
urls:
# travis2slack webhook to enable DMs on openwhisk-team.slack.com to PR authors with TravisCI results
secure: "@@@@@@@kjsdhfksadfsnddaVN8+Shkaty+WDhjTuCbVkliH4H2yJ3GMK2cf8pxhQz1Po0qJNxuyO9jDjQRbDG95b0PueBLcK0gMZZkjoe47lg
/ZqYMyEFjhKP0J4C0+thokVnM4MoT8xKktWjPyIRK2EfYEdR1UXPtmofNgkZmpwx/GARuuDhAiSo3myMZ2xWQx0ASVsWbkODBePUnnMVv4Hcm0zn9ActFBZW9aJaGjg8Qo+sertESCemWYhreErdXtXV4prlWJo2LytpUuXIAWLFnutYu6TJw2I7gBaRkbLN+4N7qSgddcfVUdBf8j6NqWwUz6BqLqDSZ031lKCIlTNpS/Yu/+9qgI/aBZ9a0l+Nv4o0V0nWTZ0aAkw3/HtZ3muDHHs7ninMq9IFgGRUR4jX4OgUV8Pu8OKEHYcUF0S0XiXbTfLIxI3OirBBlxweunMKtjyOUOLdWcmT2XQLYJGU7cdiG3SE+ONo7kR+BugUtqSzgCnRRxE4m4wkZHqOfyRI2b3RVCtEQHfewevZnDCbxYxZn+v1mMjE4zuenhu+hbtsvQbbX+x1MeDaL8RYrwjXXf+TrILhnj1xkuHTWAgKQhh6pP+ZaNqNLmmSLOqaI/v8Ysi4rSbkR2Pa3k0/ze/tPdjqoD8vFZMPrSLYOWTqZYQCFF5FA72DECFP04tnb0hz5c4joxGJpRlKs1MW8="
enabled: false

before_install:
- "./tools/travis/setup.sh"
install: true
script:
- "./tools/travis/build.sh && ./tools/travis/test.sh"
deploy:
# - provider: script
# script: "./tools/travis/publish.sh openwhisk ${TRAVIS_TAG##*@}"
# on:
# tags: true
# all_branches: true
- provider: script
script: "./tools/travis/publish.sh openwhisk latest"
on:
branch: master
repo: mpmunasinghe/openwhisk-runtime-ballerina
env:
global:
- secure: D4kU9O6bs63Myb4jaEgw1O2Kuy6aTAUKEX1qZ0eYMDouLnPOPnZaFWmpISKTrJyz7hJH7yY8Cj7xl5qwsLB6JZZMtqT6yj5J/jkUJjyLKdQH81PrYy22rH99xS2t5A1dsC0A/Bf39R/qNc5tx1wCMVDF4O2rFsUtn+8vE+rn0nXsiPeWhhZagk/Hrq8YbwzDJHOGHfWe1nZIcU8MORzTriX7J2VAF0AcirPandMxff4FgzNLk432DN2GvgZIlNtZGT1DWLtJV/Sp3unD9abXr5xqNDIW+fHrMq8j/JdHC6+PFtZRFrl0Vr6X8c61PkB/ELGF2MyzNgBTnEaJixl1pianr91WK4y0oLUwpSJCz4yoQGVimAAtqMgNXjEyFMcpLClzS5TjMXKaUfi9mBn9GMCwLi3VAuVtMtH2IRW03PxIPyxkbj1j8Nrd0jh408MuMpuzyECgb+E5ffbd+0YD5XUNlTkYLFi4sEh2xpzvjGrNbrTe99zFrHt3e+dbmoahmaCyDRsxD2CDI8b++HyN78z/jO9A7kFc2TAZbWa6Xygkj1nEpnR1y4TB6eqdDo7Y6W20dLjeSSF8rACw3bM3lJh+K4/nv4Nlo6pfblhvs7T53ftst+tHpxJoQy/gDC0TcuyBThrHTeI1j7k4HkQyN+NqezBdFN2ElufjQ74ds2c=
- secure: KzgDAV8O0ya6JBqSs4J4A7A+2n9Mgs5kRzhwwPdUg7ExuG2xXwWw1gafNPZwagfVOQfdqLzfF4tY8PPbTfloqEomFmYI/9PUHU8nMiMQkhEKkU3Od6HqqV9/WCf9vBrmqZHTPQNRVUvsbcOiYG1xtQr4JPHySJnk9VbgumRCT+f0xWK5mGK3CQqIo43F0TScjMONED/h7yueT+zFIJIfTiOXgtckbZdi7hErrVubbkduyzGSMek1Pfzy+m7Ek6jIaS4iD6duSRfxO9GVDTMee13cD3HuIWWfkZMkNiMlXBLmOPhb67lt/dgryxZ9zKxCzJFDW3Fx8uohoFu+sg8ZcyCeeDqMUfeML8rKAdNk72e2W9Vzedx6lxoTIhLYA3KLj7kL5wTxEq9QnSI/dMPqJUG/IA7Cr5fnJWRAlJ3IroQqBH8vNZ9zuoh/Ap4G2kXL1m4JECPhBlsX8i9RgDrFrab4My2IOHBw+ZA+cJ4h5njQUkuhMtlAhJ26jwQgYhn/sSMLgb4h5IX2iiRprsrg912vFg0ZrgHu1joIH/1XEGdArkQ7O9za4mowEmOuATux0drXTRKGe6z+/xaW35K8tQ52ToJRMN+GZBKlZoNIZd/rQ/y1Ikb6PD5Gfjk0WBnxYT5jV+ted7zCq3LskpWyvXtVTKoOqPOC/cDcY5JBPK8=
118 changes: 117 additions & 1 deletion README.md
@@ -1 +1,117 @@
# incubator-openwhisk-runtime-ballerina
<!--
#
# 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.
#
-->

# Apache OpenWhisk Runtime for Ballerina
[![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0)
[![Build Status](https://travis-ci.com/mpmunasinghe/incubator-openwhisk-runtime-ballerina.svg?branch=master)](https://travis-ci.com/mpmunasinghe/openwhisk-runtime-ballerina)

This repository contains the [Ballerina](https://ballerinalang.org) runtime for the Apache OpenWhisk serverless platform.

### Prerequisites

The following prerequisites are needed to try this out:

- [Ballerina](https://ballerina.io/downloads/) >= 0.975.0

### Creating a Ballerina function

Create a file `hello.bal` for your Ballerina function with the following code:

```ballerina
import ballerina/io;
function main(string... args) {
io:println("started");
}
function run(json jsonInput) returns json {
io:println(jsonInput);
json output = { "response": "hello-world"};
return output;
}
```

The Ballerina file should include:
- `main(string... args)` and
- `run(json jsonInput)`.

The first is necessary to compile the function but does not execute when you
invoke the action.

### Compiling your function

Run the [Ballerina](https://ballerina.io/downloads) compiler to
build your function.
```bash
ballerina build hello.bal
```

This generates an executable `hello.balx`. You will use this binary to create
the OpenWhisk action.

### Creating and invoking your Ballerina action

Use the OpenWhisk [`wsk` CLI](https://github.com/apache/incubator-openwhisk/blob/master/docs/cli.md)
to create your Ballerina action.

```bash
wsk action create hello hello.balx --docker mpmunasinghe/balaction
```

Now you're ready to invoke the action:

```bash
wsk action invoke hello --result
```
```json
{
"response": "hello-world"
}
```

You can learn more about working with OpenWhisk Actions [here](https://github.com/apache/incubator-openwhisk/blob/master/docs/actions.md).

### Developing the Ballerina runtime for OpenWhisk

To build the Ballerina runtime, you need an OpenWhisk snapshot release which
you can install as follows:
```bash
pushd $OPENWHISK_HOME
./gradlew install
podd $OPENWHISK_HOME
```
where `$OPENWHISK_HOME` is an environment variable that points to your
OpenWhisk directory.

The Ballerina runtime is built with the Gradle wrapper `gradlew`.
```bash
./gradlew distDocker
```

You can also use `gradlew` to run all the unit tests.
```bash
./gradlew :tests:test
```

Or to run a specific test.
```bash
./gradlew :tests:test --tests *ActionContainerTests*
```

This project can be imported into [IntelliJ](https://www.jetbrains.com/idea/)
for development and testing. Import the project as a Gradle project, and make
sure your working directory is the root directory for this repository.
41 changes: 41 additions & 0 deletions ballerina/Dockerfile
@@ -0,0 +1,41 @@
#
# 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 adoptopenjdk/openjdk8-openj9:jdk8u162-b12_openj9-0.8.0

RUN rm -rf /var/lib/apt/lists/* && apt-get clean && apt-get update \
&& apt-get install -y --no-install-recommends locales \
&& rm -rf /var/lib/apt/lists/* \
&& locale-gen en_US.UTF-8

ENV LANG="en_US.UTF-8" \
LANGUAGE="en_US:en" \
LC_ALL="en_US.UTF-8" \
VERSION=8 \
UPDATE=162 \
BUILD=12

ADD proxy /home/ballerina

RUN cd /home/ballerina \
&& rm -rf .classpath .gitignore .gradle .project .settings Dockerfile build \
&& ./gradlew shadowJar \
&& rm -rf /home/ballerina/src

EXPOSE 8080

CMD java -Dballerina.home=/home/ballerina/build -Djava.util.logging.manager=org.ballerinalang.logging.BLogManager -jar /home/ballerina/build/libs/ballerina-all.jar --http.port=8080
20 changes: 20 additions & 0 deletions ballerina/build.gradle
@@ -0,0 +1,20 @@
/*
* 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.
*/

ext.dockerImageName = 'balaction'
ext.dockerImagePrefix = "mpmunasinghe"
apply from: '../gradle/docker.gradle'
11 changes: 11 additions & 0 deletions ballerina/hello-function.bal
@@ -0,0 +1,11 @@
import ballerina/io;

function main(string... args) {
io:println("started");
}

function run(json jsonInput) returns json {
io:println(jsonInput);
json output = { "response": "hello-world"};
return output;
}
Binary file added ballerina/hello-function.balx
Binary file not shown.
92 changes: 92 additions & 0 deletions ballerina/proxy/build.gradle
@@ -0,0 +1,92 @@
/*
* 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.
*/

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.3'
}
}

apply plugin: 'maven'
apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'com.github.johnrengelman.shadow'

mainClassName = 'org.ballerinalang.openwhisk.runtime.Application'

repositories {
mavenCentral()
mavenLocal()
maven { url "https://maven.wso2.org/nexus/content/repositories/public/org/ballerinalang" }
maven { url "http://maven.wso2.org/nexus/content/groups/wso2-public" }
}

dependencies {
compile "org.wso2.msf4j:msf4j-service:2.4.2"
compile ("org.wso2.msf4j:msf4j-core:2.4.2") {
force = true
}
compile "org.ballerinalang:ballerina-core:0.975.0"
compile "org.ballerinalang:ballerina-lang:0.975.0"
compile "org.ballerinalang:ballerina-grpc:0.975.0"
compile "org.ballerinalang:protobuf-ballerina:0.975.0"
compile "org.ballerinalang:ballerina-builtin:0.975.0"
compile "org.ballerinalang:ballerina-http:0.975.0"
compile "org.ballerinalang:ballerina-transactions:0.975.0"
compile "org.ballerinalang:ballerina-logging:0.975.0"
compile "org.ballerinalang:ballerina-database:0.975.0"
compile "org.ballerinalang:ballerina-micrometer-extension:0.975.0"
compile "org.slf4j:slf4j-api:1.7.22"
}

configurations.all {
exclude group: 'org.slf4j', module: 'slf4j-simple'
exclude group: 'org.ops4j.pax.logging', module: 'pax-logging-api'
}

task wrapper(type: Wrapper) {
gradleVersion = '4.6' //version required
}

defaultTasks 'shadowJar'

// Configure the shadow jar task
shadowJar {
mergeServiceFiles()
exclude 'META-INF/*.DSA'
exclude 'META-INF/*.RSA'
}
jar {
manifest {
attributes 'Main-Class': mainClassName
}
}

task copyRepoDependencies() {
configurations.compile.resolvedConfiguration.resolvedArtifacts.each { artifact ->
if (artifact.file.name.endsWith("ballerina-binary-repo.zip")) {
copy {
from zipTree( artifact.file )
into ("${buildDir}/lib")
}
}
}
}

Binary file added ballerina/proxy/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
8 changes: 8 additions & 0 deletions ballerina/proxy/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,8 @@
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements; and to You under the Apache License, Version 2.0.

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

0 comments on commit 026e16b

Please sign in to comment.