Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 87 additions & 1 deletion .github/workflows/android_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ jobs:
java-package: jdk
architecture: x64
- name: 'Install dependencies'
run: ./ci/mac_ci_setup.sh --android
run: ./ci/mac_ci_setup.sh
- name: 'Download aar'
uses: actions/cache@v2
id: check-cache
Expand Down Expand Up @@ -128,3 +128,89 @@ jobs:
adb shell am start -n io.envoyproxy.envoymobile.helloenvoykotlin/.MainActivity
- name: 'Check connectivity'
run: adb logcat -e "received headers with status 200" -m 1
kotlinbaselineapp:
name: kotlin_baseline_app
needs: androidbuild
runs-on: macos-11
timeout-minutes: 25
steps:
- uses: actions/checkout@v1
with:
submodules: true
- uses: actions/setup-java@v1
with:
java-version: '8'
java-package: jdk
architecture: x64
- name: 'Install dependencies'
run: ./ci/mac_ci_setup.sh --android
- name: 'Download aar'
uses: actions/cache@v2
id: check-cache
with:
key: aar-${{ github.sha }}
path: dist/envoy.aar
- name: 'Short-circuit'
if: steps.check-cache.outputs.cache-hit != 'true'
run: exit 1
- name: 'Start simulator'
run: ./ci/mac_start_emulator.sh
# Return to using:
# ./bazelw mobile-install --fat_apk_cpu=x86 --start_app //examples/kotlin/hello_world:hello_envoy_kt
# When https://github.com/envoyproxy/envoy-mobile/issues/853 is fixed.
- name: 'Start kotlin app'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
./bazelw build \
--config=remote-ci-macos \
--remote_header="Authorization=Bearer $GITHUB_TOKEN" \
--fat_apk_cpu=x86 \
//test/kotlin/apps/baseline:hello_envoy_kt
adb install -r --no-incremental bazel-bin/test/kotlin/apps/baseline/hello_envoy_kt.apk
adb shell am start -n io.envoyproxy.envoymobile.helloenvoykotlin/.MainActivity
- name: 'Check connectivity'
run: adb logcat -e "received headers with status 200" -m 1
kotlinexperimentalapp:
name: kotlin_experimental_app
needs: androidbuild
runs-on: macos-11
timeout-minutes: 25
steps:
- uses: actions/checkout@v1
with:
submodules: true
- uses: actions/setup-java@v1
with:
java-version: '8'
java-package: jdk
architecture: x64
- name: 'Install dependencies'
run: ./ci/mac_ci_setup.sh
- name: 'Download aar'
uses: actions/cache@v2
id: check-cache
with:
key: aar-${{ github.sha }}
path: dist/envoy.aar
- name: 'Short-circuit'
if: steps.check-cache.outputs.cache-hit != 'true'
run: exit 1
- name: 'Start simulator'
run: ./ci/mac_start_emulator.sh
# Return to using:
# ./bazelw mobile-install --fat_apk_cpu=x86 --start_app //examples/kotlin/hello_world:hello_envoy_kt
# When https://github.com/envoyproxy/envoy-mobile/issues/853 is fixed.
- name: 'Start kotlin app'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
./bazelw build \
--config=remote-ci-macos \
--remote_header="Authorization=Bearer $GITHUB_TOKEN" \
--fat_apk_cpu=x86 \
//test/kotlin/apps/experimental:hello_envoy_kt
adb install -r --no-incremental bazel-bin/test/kotlin/apps/experimental/hello_envoy_kt.apk
adb shell am start -n io.envoyproxy.envoymobile.helloenvoykotlin/.MainActivity
- name: 'Check connectivity'
run: adb logcat -e "received headers with status 200" -m 1
68 changes: 68 additions & 0 deletions .github/workflows/ios_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,74 @@ jobs:
- run: cat /tmp/envoy.log
if: ${{ failure() || cancelled() }}
name: 'Log app run'
swiftbaselineapp:
name: swift_baseline_app
needs: iosbuild
runs-on: macos-11
timeout-minutes: 25
steps:
- uses: actions/checkout@v1
with:
submodules: true
- run: ./ci/mac_ci_setup.sh
name: 'Install dependencies'
- uses: actions/cache@v2
id: check-cache
with:
key: framework-${{ github.sha }}
path: dist/Envoy.framework
name: 'Download framework'
- run: exit 1
if: steps.check-cache.outputs.cache-hit != 'true'
name: 'Short-circuit'
- env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./bazelw build --config=ios --config=remote-ci-macos --remote_header="Authorization=Bearer $GITHUB_TOKEN" //test/swift/apps/baseline:app
name: 'Build swift app'
# Run the app in the background and redirect logs.
- env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./bazelw run --config=ios --config=remote-ci-macos --remote_header="Authorization=Bearer $GITHUB_TOKEN" //test/swift/apps/baseline:app &> /tmp/envoy.log &
name: 'Run swift app'
- run: sed '/received headers with status 200/q' <(touch /tmp/envoy.log && tail -F /tmp/envoy.log)
name: 'Check connectivity'
- run: cat /tmp/envoy.log
if: ${{ failure() || cancelled() }}
name: 'Log app run'
swiftexperimentalapp:
name: swift_experimental_app
needs: iosbuild
runs-on: macos-11
timeout-minutes: 25
steps:
- uses: actions/checkout@v1
with:
submodules: true
- run: ./ci/mac_ci_setup.sh
name: 'Install dependencies'
- uses: actions/cache@v2
id: check-cache
with:
key: framework-${{ github.sha }}
path: dist/Envoy.framework
name: 'Download framework'
- run: exit 1
if: steps.check-cache.outputs.cache-hit != 'true'
name: 'Short-circuit'
- env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./bazelw build --config=ios --config=remote-ci-macos --remote_header="Authorization=Bearer $GITHUB_TOKEN" //test/swift/apps/experimental:app
name: 'Build swift app'
# Run the app in the background and redirect logs.
- env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./bazelw run --config=ios --config=remote-ci-macos --remote_header="Authorization=Bearer $GITHUB_TOKEN" //test/swift/apps/experimental:app &> /tmp/envoy.log &
name: 'Run swift app'
- run: sed '/received headers with status 200/q' <(touch /tmp/envoy.log && tail -F /tmp/envoy.log)
name: 'Check connectivity'
- run: cat /tmp/envoy.log
if: ${{ failure() || cancelled() }}
name: 'Log app run'
swiftasyncawait:
name: swift_async_await
needs: iosbuild
Expand Down
22 changes: 22 additions & 0 deletions test/kotlin/apps/baseline/.bazelproject
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
workspace_type: android

directories:
-bazel-bin
-bazel-instant-android
-bazel-out
-bazel-testlogs
-buck-out
-build
examples/kotlin/hello_world

import_run_configurations:
examples/kotlin/hello_world/tools/android-studio-run-configurations/run_configuration_example_debug_x86.xml

targets:
//examples/kotlin/hello_world:hello_envoy_kt

additional_languages:
kotlin
java
android
c
23 changes: 23 additions & 0 deletions test/kotlin/apps/baseline/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.envoyproxy.envoymobile.helloenvoykotlin"
android:versionCode="1"
android:versionName="0.1">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

<uses-sdk
android:minSdkVersion="21"
android:targetSdkVersion="27"/>

<application
android:label="Hello Envoy">
<activity
android:name=".MainActivity"
android:label="Hello Envoy Kotlin">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
95 changes: 95 additions & 0 deletions test/kotlin/apps/baseline/AsyncDemoFilter.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
package io.envoyproxy.envoymobile.helloenvoykotlin

import io.envoyproxy.envoymobile.AsyncResponseFilter
import io.envoyproxy.envoymobile.EnvoyError
import io.envoyproxy.envoymobile.FilterDataStatus
import io.envoyproxy.envoymobile.FilterHeadersStatus
import io.envoyproxy.envoymobile.FilterResumeStatus
import io.envoyproxy.envoymobile.FilterTrailersStatus
import io.envoyproxy.envoymobile.FinalStreamIntel
import io.envoyproxy.envoymobile.ResponseFilterCallbacks
import io.envoyproxy.envoymobile.ResponseHeaders
import io.envoyproxy.envoymobile.ResponseTrailers
import io.envoyproxy.envoymobile.StreamIntel
import java.nio.ByteBuffer
import java.util.Timer
import kotlin.concurrent.schedule

/**
* Example of a more complex HTTP filter that pauses processing on the response filter chain,
* buffers until the response is complete, then asynchronously triggers filter chain resumption
* while setting a new header. Also demonstrates safety of re-entrancy in async callbacks.
*/
class AsyncDemoFilter : AsyncResponseFilter {
private lateinit var callbacks: ResponseFilterCallbacks

override fun onResponseHeaders(
headers: ResponseHeaders,
endStream: Boolean,
streamIntel: StreamIntel
): FilterHeadersStatus<ResponseHeaders> {
// If this is the end of the stream, asynchronously resume response processing via callback.
if (endStream) {
Timer("AsyncResume", false).schedule(100) {
callbacks.resumeResponse()
}
}
return FilterHeadersStatus.StopIteration()
}

override fun onResponseData(
body: ByteBuffer,
endStream: Boolean,
streamIntel: StreamIntel
): FilterDataStatus<ResponseHeaders> {
// If this is the end of the stream, asynchronously resume response processing via callback.
if (endStream) {
Timer("AsyncResume", false).schedule(100) {
callbacks.resumeResponse()
}
}
return FilterDataStatus.StopIterationAndBuffer()
}

override fun onResponseTrailers(
trailers: ResponseTrailers,
streamIntel: StreamIntel
): FilterTrailersStatus<ResponseHeaders, ResponseTrailers> {
// Trailers imply end of stream, so asynchronously resume response processing via callbacka
Timer("AsyncResume", false).schedule(100) {
callbacks.resumeResponse()
}
return FilterTrailersStatus.StopIteration()
}

override fun setResponseFilterCallbacks(callbacks: ResponseFilterCallbacks) {
this.callbacks = callbacks
}

override fun onResumeResponse(
headers: ResponseHeaders?,
data: ByteBuffer?,
trailers: ResponseTrailers?,
endStream: Boolean,
streamIntel: StreamIntel
): FilterResumeStatus<ResponseHeaders, ResponseTrailers> {
val builder = headers!!.toResponseHeadersBuilder()
.add("async-filter-demo", "1")
return FilterResumeStatus.ResumeIteration(builder.build(), data, trailers)
}

@Suppress("EmptyFunctionBlock")
override fun onError(
error: EnvoyError,
finalStreamIntel: FinalStreamIntel
) {
}

@Suppress("EmptyFunctionBlock")
override fun onCancel(finalStreamIntel: FinalStreamIntel) {
}

@Suppress("EmptyFunctionBlock")
override fun onComplete(finalStreamIntel: FinalStreamIntel) {
}
}
45 changes: 45 additions & 0 deletions test/kotlin/apps/baseline/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
load("@build_bazel_rules_android//android:rules.bzl", "android_binary")
load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library")
load("@rules_detekt//detekt:defs.bzl", "detekt")
load("@rules_jvm_external//:defs.bzl", "artifact")

licenses(["notice"]) # Apache 2

android_binary(
name = "hello_envoy_kt",
custom_package = "io.envoyproxy.envoymobile.helloenvoykotlin",
manifest = "AndroidManifest.xml",
proguard_specs = ["//library:proguard_rules"],
deps = [
"hello_envoy_kt_lib",
],
)

kt_android_library(
name = "hello_envoy_kt_lib",
srcs = [
"AsyncDemoFilter.kt",
"BufferDemoFilter.kt",
"DemoFilter.kt",
"MainActivity.kt",
],
custom_package = "io.envoyproxy.envoymobile.helloenvoykotlin",
manifest = "AndroidManifest.xml",
resource_files = [
"res/layout/activity_main.xml",
],
deps = [
"//dist:envoy_mobile_android",
"//examples/kotlin/shared:hello_envoy_shared_lib",
artifact("androidx.recyclerview:recyclerview"),
artifact("androidx.annotation:annotation"),
artifact("com.google.code.findbugs:jsr305"),
],
)

detekt(
name = "hello_envoy_kt_lint",
srcs = glob(["*.kt"]),
build_upon_default_config = True,
cfgs = ["//:kotlin_lint_config"],
)
Loading