Skip to content

Commit

Permalink
Merge branch 'master' into appengine_ktor
Browse files Browse the repository at this point in the history
  • Loading branch information
bshaffer committed Mar 15, 2021
2 parents ddf85b9 + 1eaf6ee commit 7ffcd20
Show file tree
Hide file tree
Showing 16 changed files with 130 additions and 136 deletions.
1 change: 1 addition & 0 deletions .github/snippet-bot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

81 changes: 81 additions & 0 deletions .github/tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/bin/bash
# Copyright 2021 Google Inc.
#
# Licensed 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

TMP_REPORT_DIR=$(mktemp -d)
SUCCEEDED_FILE=${TMP_REPORT_DIR}/succeeded
FAILED_FILE=${TMP_REPORT_DIR}/failed

# Set flags for skipping tests if we are not authenticated
if [ ! -s "$GOOGLE_APPLICATION_CREDENTIALS" ]; then
MAVEN_FLAGS="-Dmaven.test.skip=true"
GRADLE_FLAGS="-x test"
BUILD_ONLY="(build only) "
fi

build_samples()
{
if [ "$2" == "maven" ]; then
BUILD_COMMAND="./mvnw -q install ${MAVEN_FLAGS}"
else
BUILD_COMMAND="./gradlew -q build ${GRADLE_FLAGS}"
fi
echo $BUILD_COMMAND
# Temporarily allow error
set +e
$BUILD_COMMAND < /dev/null
if [ $? == 0 ]; then
echo "$1 ($2): ok" >> "${SUCCEEDED_FILE}"
else
if [[ " ${FLAKES[@]} " =~ " ${DIR} " ]]; then
echo "$1 ($2): failed" >> "${FAILED_FLAKY_FILE}"
else
echo "$1 ($2): failed" >> "${FAILED_FILE}"
fi
fi
set -e
}

# Loop through all directories containing "gradlew" and run the test suites.
find * \( -name 'gradlew' -o -name 'mvnw' \) -exec dirname {} \; | while read DIR
do
pushd ${DIR}
if [ -f "gradlew" ]; then
build_samples $DIR "gradle"
fi
if [ -f "mvnw" ]; then
build_samples $DIR "maven"
fi
popd
done

set +x
if [ -f "${SUCCEEDED_FILE}" ]; then
echo "--------- Succeeded ${BUILD_ONLY}-----------"
cat "${SUCCEEDED_FILE}"
echo "-------------------------------------"
fi

if [ -f "${FAILED_FILE}" ]; then
echo "--------- Failed ${BUILD_ONLY}--------------"
cat "${FAILED_FILE}"
echo "-------------------------------------"
fi

# Finally report failure if any buildsfailed
if [ -f "${FAILED_FILE}" ]; then
exit 1
fi
116 changes: 9 additions & 107 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,111 +20,13 @@ jobs:
- uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}
- name: Set Application Default Credentials
- name: Set Application Default Credentials Environment Variable
run: echo "GOOGLE_APPLICATION_CREDENTIALS=${HOME}/credentials.json" >> $GITHUB_ENV
- run: echo ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS_B64 }} | base64 --decode >> $GOOGLE_APPLICATION_CREDENTIALS

- if: github.event.pull_request.head.repo.full_name != github.repository
run: |
echo "MAVEN_FLAGS=-Dmaven.test.skip=true" >> $GITHUB_ENV
echo "GRADLE_FLAGS=-x test" >> $GITHUB_ENV
- name: App Engine (Ktor) - Gradle
run: |
cd ${GITHUB_WORKSPACE}/appengine/ktor
./gradlew build $GRADLE_FLAGS
- name: App Engine (Springboot) - Maven
run: |
cd ${GITHUB_WORKSPACE}/appengine/springboot
./mvnw install -q $MAVEN_FLAGS
- name: Firestore - Gradle
run: |
cd ${GITHUB_WORKSPACE}/firestore
./gradlew build $GRADLE_FLAGS
- name: Functions - Gradle
run: |
cd ${GITHUB_WORKSPACE}/functions
./gradlew build --console=plain --info $GRADLE_FLAGS
- if: github.event.pull_request.head.repo.full_name == github.repository
name: Getting Started Android (frontend) - Gradle
run: |
cd ${GITHUB_WORKSPACE}/getting-started/android-with-appengine/frontend
echo ${{ secrets.GOOGLE_SERVICES_B64 }} | base64 --decode >> emojify/google-services.json
./gradlew build --console=plain --info $GRADLE_FLAGS
- if: github.event.pull_request.head.repo.full_name == github.repository
name: Getting Started Android (backend) - Maven
run: |
cd ${GITHUB_WORKSPACE}/getting-started/android-with-appengine/backend
echo "storage.bucket.name = $GOOGLE_CLOUD_PROJECT.appspot.com" >> src/main/resources/application.properties
./mvnw install -q
- name: Pubsub - Gradle
run: |
cd ${GITHUB_WORKSPACE}/pubsub
./gradlew build --console=plain --info $GRADLE_FLAGS
- name: Cloud Run (gRPC) - Gradle
run: |
cd ${GITHUB_WORKSPACE}/run/grpc-hello-world-gradle
./gradlew build --console=plain --info $GRADLE_FLAGS
- name: Cloud Run (gRPC) - Maven
run: |
cd ${GITHUB_WORKSPACE}/run/grpc-hello-world-mvn
./mvnw install -q $MAVEN_FLAGS
- name: Cloud Run (gRPC streaming) - Gradle
run: |
cd ${GITHUB_WORKSPACE}/run/grpc-hello-world-streaming
./gradlew build --console=plain --info $GRADLE_FLAGS
- name: Cloud Run (gRPC bidi-streaming) - Gradle
run: |
cd ${GITHUB_WORKSPACE}/run/grpc-hello-world-bidi-streaming
./gradlew build --console=plain --info $GRADLE_FLAGS
- name: Cloud Run (Ktor) - Gradle
run: |
cd ${GITHUB_WORKSPACE}/run/ktor-hello-world
./gradlew build --console=plain --info $GRADLE_FLAGS
- name: Cloud Run (Micronaut) - Gradle
run: |
cd ${GITHUB_WORKSPACE}/run/micronaut-hello-world
./gradlew build --console=plain --info $GRADLE_FLAGS
- name: Cloud Run (Quarkus) - Maven
run: |
cd ${GITHUB_WORKSPACE}/run/quarkus-hello-world
./mvnw install -q $MAVEN_FLAGS
- name: Cloud Run (Spring Boot) - Gradle
run: |
cd ${GITHUB_WORKSPACE}/run/springboot-hello-world
./gradlew build --console=plain --info $GRADLE_FLAGS
- name: Cloud Run (Http4k) - Gradle
run: |
cd ${GITHUB_WORKSPACE}/run/http4k-hello-world
./gradlew build --console=plain --info $GRADLE_FLAGS
- name: Cloud Run (Plain) - Maven
run: |
cd ${GITHUB_WORKSPACE}/run/plain-hello-world
./mvnw install -q $MAVEN_FLAGS
- name: Storage - Gradle
run: |
cd ${GITHUB_WORKSPACE}/storage
./gradlew build --console=plain --info $GRADLE_FLAGS
- name: Vision - Gradle
run: |
cd ${GITHUB_WORKSPACE}/vision
./gradlew build --console=plain --info $GRADLE_FLAGS
- name: Set Application Default Credentials File
run: echo ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS_B64 }} | base64 --decode >> $GOOGLE_APPLICATION_CREDENTIALS
- name: Set config files
run : |
echo ${{ secrets.GOOGLE_SERVICES_B64 }} | base64 --decode >> ${GITHUB_WORKSPACE}/getting-started/android-with-appengine/frontend/emojify/google-services.json
echo "storage.bucket.name = $GOOGLE_CLOUD_PROJECT.appspot.com" >> ${GITHUB_WORKSPACE}/getting-started/android-with-appengine/backend/src/main/resources/application.properties
- name: Build all samples
run: ./.github/tests.sh
2 changes: 1 addition & 1 deletion appengine/ktor/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ require (JavaVersion.current() <= JavaVersion.VERSION_11) {
}

dependencies {
implementation(platform("io.ktor:ktor-bom:1.5.1"))
implementation(platform("io.ktor:ktor-bom:1.5.2"))
implementation("io.ktor:ktor-server-servlet")
implementation("io.ktor:ktor-html-builder")
implementation("com.google.cloud:google-cloud-logging-logback:0.117.0-alpha")
Expand Down
15 changes: 13 additions & 2 deletions appengine/springboot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.4.RELEASE</version>
<version>2.4.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<kotlin.version>1.4.10</kotlin.version>
<kotlin.version>1.4.31</kotlin.version>
<spring-cloud-gcp.version>1.2.5.RELEASE</spring-cloud-gcp.version>
<spring-cloud.version>Finchley.SR1</spring-cloud.version>
</properties>
Expand Down Expand Up @@ -71,6 +71,17 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

<dependencyManagement>
Expand Down
2 changes: 1 addition & 1 deletion firestore/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion functions/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion functions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<kotlin.version>1.3.21</kotlin.version>
<kotlin.version>1.4.31</kotlin.version>
<kotlin.compiler.incremental>true</kotlin.compiler.incremental>
</properties>

Expand Down
19 changes: 15 additions & 4 deletions getting-started/android-with-appengine/backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ limitations under the License.
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.4.RELEASE</version>
<version>2.4.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<kotlin.version>1.2.61</kotlin.version>
<kotlin.version>1.4.31</kotlin.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -78,14 +78,25 @@ limitations under the License.
<artifactId>kotlin-reflect</artifactId>
</dependency>
<!-- END Spring Boot Kotlin dependencies -->
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-bom</artifactId>
<version>0.56.0-alpha</version>
<version>0.149.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down Expand Up @@ -122,7 +133,7 @@ limitations under the License.
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>1.3.1</version>
<version>1.3.2</version>
<configuration>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,6 @@ class EmojifyApplicationTests {
assertThat(response?.body).isEqualTo(EmojifyResponse(statusCode = HttpStatus.BAD_REQUEST, errorCode = 101, errorMessage = errorMessage[101]))
}

@Test
fun `blob ContentType is not set`() {
val publicImage = URL("https://lh3.googleusercontent.com/2ONX_nVMyhMt62GrKOJj9yf6SHvD6T7QEGidCg4P3YeAh5m4nyKbbg3lUr_TR3GA09PVP5xjF_cfaOwj4mYGgg=w1614").readBytes()
val blob = storage.get(bucketName).create("google-diversity", publicImage)
assertThat(blob).isNotNull

val response = testRestTemplate.getForEntity("/emojify?objectName=google-diversity", EmojifyResponse::class.java)
assertThat(response.statusCode).isEqualTo(HttpStatus.OK)
assertThat(response?.body).isEqualTo(EmojifyResponse(statusCode = HttpStatus.BAD_REQUEST, errorCode = 104, errorMessage = errorMessage[104]))
assertThat(blob.delete()).isTrue()
}

@Test
fun `source image processed and emojified image is public`() {
val publicImage = URL("https://lh3.googleusercontent.com/2ONX_nVMyhMt62GrKOJj9yf6SHvD6T7QEGidCg4P3YeAh5m4nyKbbg3lUr_TR3GA09PVP5xjF_cfaOwj4mYGgg=w1614").readBytes()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-all.zip
2 changes: 1 addition & 1 deletion pubsub/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-all.zip
4 changes: 2 additions & 2 deletions run/grpc-hello-world-mvn/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<properties>
<java.version>1.8</java.version>
<kotlin.version>1.4.31</kotlin.version>
<kotlinx.coroutines.version>1.4.2</kotlinx.coroutines.version>
<kotlinx.coroutines.version>1.4.3-native-mt</kotlinx.coroutines.version>
<grpc.version>1.36.0</grpc.version>
<grpc.kotlin.version>1.0.0</grpc.kotlin.version>
<protobuf.version>3.14.0</protobuf.version>
Expand Down Expand Up @@ -152,7 +152,7 @@
<plugin>
<groupId>com.github.gantsign.maven</groupId>
<artifactId>ktlint-maven-plugin</artifactId>
<version>1.7.0</version>
<version>1.8.0</version>
<executions>
<execution>
<id>format-and-check</id>
Expand Down
2 changes: 1 addition & 1 deletion run/quarkus-hello-world/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<quarkus.version>1.12.1.Final</quarkus.version>
<quarkus.version>1.12.2.Final</quarkus.version>
<kotlin.version>1.4.31</kotlin.version>
</properties>

Expand Down
2 changes: 1 addition & 1 deletion storage/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 7ffcd20

Please sign in to comment.