Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CI for examples/instrumentation-quickstart #290

Merged
merged 1 commit into from
Feb 8, 2024
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
36 changes: 28 additions & 8 deletions .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,54 @@ on:
- main
jobs:
test:
name: Test
strategy:
matrix:
include:
- build-root: .
name: root
java-version: 11
- build-root: examples/instrumentation-quickstart
java-version: 17
name: Test (${{matrix.name || matrix.build-root}})
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- id: setup-java-11
name: Setup Java 11
- id: setup-java
name: Setup Java ${{matrix.java-version}}
uses: actions/setup-java@v1
with:
java-version: 11
java-version: ${{matrix.java-version}}
- uses: burrunan/gradle-cache-action@v1.6
with:
job-id: java-${{matrix.java-version}}
remote-build-cache-proxy-enabled: false
build-root-directory: ${{matrix.build-root}}
arguments: test
style:
name: Stylecheck
name: Stylecheck (${{matrix.name || matrix.build-root}})
runs-on: ubuntu-latest
strategy:
matrix:
include:
- build-root: .
name: root
java-version: 11
- build-root: examples/instrumentation-quickstart
java-version: 17
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- id: setup-java-11
name: Setup Java 11
- id: setup-java
name: Setup Java ${{matrix.java-version}}
uses: actions/setup-java@v1
with:
java-version: 11
java-version: ${{matrix.java-version}}
- uses: burrunan/gradle-cache-action@v1.6
with:
job-id: java-${{matrix.java-version}}
remote-build-cache-proxy-enabled: false
build-root-directory: ${{matrix.build-root}}
arguments: spotlessCheck
1 change: 1 addition & 0 deletions examples/instrumentation-quickstart/.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ bin/
Dockerfile
docker-compose*.yaml
otel-collector-config.yaml
cloudbuild-integration.yaml
25 changes: 21 additions & 4 deletions examples/instrumentation-quickstart/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ plugins {
id 'java'
id 'org.springframework.boot' version '2.7.18'
id 'io.spring.dependency-management' version '1.1.4'
id 'com.diffplug.spotless' version '6.25.0'
}

group = 'com.example'
Expand All @@ -28,6 +29,16 @@ repositories {
mavenCentral()
}

spotless {
java {
googleJavaFormat("1.10.0")
}
groovyGradle {
target '*.gradle' // default target of groovyGradle
greclipse()
}
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-webflux'

Expand All @@ -44,12 +55,18 @@ dependencies {
tasks.named('test') {
useJUnitPlatform {
// Individual integration tests are annotated with @Tag('integrationTest')
excludeTags 'integrationTest'
}
excludeTags 'integrationTest'
}
}

tasks.register("integrationTest", Test) {
useJUnitPlatform {
useJUnitPlatform {
includeTags 'integrationTest'
}
}

// Passing -DcomposeOverrideFile=foo.yaml will merge docker-compose.yaml with foo.yaml.
// This is used to set overrides for Cloud Build.
if (System.getProperty('composeOverrideFile')) {
systemProperty 'composeOverrideFile', System.getProperty('composeOverrideFile')
}
}
21 changes: 21 additions & 0 deletions examples/instrumentation-quickstart/cloudbuild-integration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2023 Google LLC
#
# 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.

steps:
- name: eclipse-temurin:17-jdk-alpine
id: integration-test
dir: examples/instrumentation-quickstart
script: ./gradlew integrationTest -i -DcomposeOverrideFile=docker-compose.test.yaml

logsBucket: gs://opentelemetry-ops-e2e-cloud-build-logs
24 changes: 24 additions & 0 deletions examples/instrumentation-quickstart/docker-compose.test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2023 Google LLC
#
# 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.

# This compose file is only used for integration tests in Cloud Build

version: "3"

networks:
# Make containers use default Cloud Build network for ADC
# https://cloud.google.com/build/docs/build-config-file-schema#network
default:
name: cloudbuild
external: true
4 changes: 2 additions & 2 deletions examples/instrumentation-quickstart/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ services:
- OTEL_EXPORTER_OTLP_ENDPOINT=http://otelcol:4317
- OTEL_SERVICE_NAME=otel-quickstart-spring-boot
- OTEL_METRIC_EXPORT_INTERVAL=5000
- GOOGLE_CLOUD_PROJECT=${GOOGLE_CLOUD_PROJECT?}
- GOOGLE_CLOUD_PROJECT
volumes:
- logs:/var/log:rw
depends_on:
Expand All @@ -32,7 +32,7 @@ services:
- ./otel-collector-config.yaml:/etc/otelcol-contrib/config.yaml:ro
- logs:/var/log:ro
environment:
- GOOGLE_CLOUD_PROJECT=${GOOGLE_CLOUD_PROJECT?}
- GOOGLE_CLOUD_PROJECT
loadgen:
image: golang:1.21
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@
public class DockerComposeTestsIT {
@Container
public static ComposeContainer environment =
new ComposeContainer(new File("docker-compose.yaml"), new File("docker-compose.creds.yaml"))
new ComposeContainer(
new File("docker-compose.yaml"),
new File(System.getProperty("composeOverrideFile", "docker-compose.creds.yaml")))
.withEnv("USERID", System.getenv("USERID"))
.withEnv("GOOGLE_CLOUD_PROJECT", getenvNotNull("GOOGLE_CLOUD_PROJECT"))
.withEnv("GOOGLE_CLOUD_PROJECT", System.getenv("GOOGLE_CLOUD_PROJECT"))
.withEnv(
"GOOGLE_APPLICATION_CREDENTIALS", getenvNotNull("GOOGLE_APPLICATION_CREDENTIALS"))
"GOOGLE_APPLICATION_CREDENTIALS", System.getenv("GOOGLE_APPLICATION_CREDENTIALS"))
.withExposedService("app", 8080)
.withExposedService("otelcol", 8888)
.waitingFor("app", Wait.forHttp("/multi"))
Expand Down Expand Up @@ -82,13 +84,4 @@ public void testApp() throws InterruptedException, IOException, URISyntaxExcepti
assertThat(promText).containsMatch(re);
}
}

private static String getenvNotNull(String key) {
String val = System.getenv(key);
if (val == null) {
throw new IllegalArgumentException(
"Environment variable " + key + " is required but was not set");
}
return val;
}
}
Loading