Skip to content

Commit d13be15

Browse files
authored
build: migrate maven plugin integration tests to a composite build (ExpediaGroup#1662)
### 📝 Description Migrate Maven plugin integration tests to a composite build to speed up the overall build and simplify main build logic. ### 🔗 Related Issues
1 parent 1fbbd48 commit d13be15

File tree

74 files changed

+741
-465
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+741
-465
lines changed

.github/workflows/plugin-it.yml

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Gradle Plugin Integration Tests
1+
name: Plugin Integration Tests
22

33
on:
44
workflow_call:
@@ -24,8 +24,15 @@ jobs:
2424
uses: gradle/gradle-build-action@v2
2525
- name: Android Test
2626
run: ./gradlew build
27+
- name: Archive failures
28+
uses: actions/upload-artifact@v3
29+
if: failure()
30+
with:
31+
name: gradle-plugin-android-build-reports
32+
path: integration/gradle-plugin-android-test/**/build/reports
33+
retention-days: 7
2734

28-
integration-tests:
35+
gradle-integration-tests:
2936
timeout-minutes: 30
3037
runs-on: ubuntu-latest
3138
defaults:
@@ -45,3 +52,41 @@ jobs:
4552
uses: gradle/gradle-build-action@v2
4653
- name: Integration Tests
4754
run: ./gradlew build
55+
- name: Archive failures
56+
uses: actions/upload-artifact@v3
57+
if: failure()
58+
with:
59+
name: gradle-plugin-build-reports
60+
path: integration/gradle-plugin-integration-tests/**/build/reports
61+
retention-days: 7
62+
63+
maven-integration-tests:
64+
timeout-minutes: 30
65+
runs-on: ubuntu-latest
66+
defaults:
67+
run:
68+
working-directory: integration/maven-plugin-integration-tests
69+
70+
steps:
71+
- uses: actions/checkout@v3
72+
- name: Validate Gradle wrapper
73+
uses: gradle/wrapper-validation-action@v1
74+
- name: Set up Java 17
75+
uses: actions/setup-java@v3
76+
with:
77+
java-version: 17
78+
distribution: 'zulu'
79+
cache: 'maven'
80+
- name: Set up Gradle cache
81+
uses: gradle/gradle-build-action@v2
82+
- name: Integration Tests
83+
run: ./gradlew build
84+
- name: Archive failures
85+
uses: actions/upload-artifact@v3
86+
if: failure()
87+
with:
88+
name: maven-plugin-build-reports
89+
path: |
90+
integration/maven-plugin-integration-tests/build/integration/**/build.log
91+
integration/maven-plugin-integration-tests/build/integration/**/target/surefire-reports
92+
retention-days: 7

.github/workflows/release-code.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,4 @@ jobs:
4444
name: build-reports
4545
path: |
4646
./**/build/reports
47-
plugins/graphql-kotlin-maven-plugin/build/integration/**/build.log
48-
plugins/graphql-kotlin-maven-plugin/build/integration/**/target/surefire-reports
4947
retention-days: 7
Binary file not shown.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip
18+
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
import com.github.tomakehurst.wiremock.standalone.WireMockServerRunner
2+
import java.time.Duration
3+
import java.util.Properties
4+
5+
description = "GraphQL Kotlin Maven Plugin that can generate type-safe GraphQL Kotlin client and GraphQL schema in SDL format using reflections"
6+
7+
buildscript {
8+
dependencies {
9+
classpath(libs.wiremock.standalone)
10+
}
11+
}
12+
13+
@Suppress("DSL_SCOPE_VIOLATION") // TODO: remove once KTIJ-19369 / Gradle#22797 is fixed
14+
plugins {
15+
alias(libs.plugins.kotlin.jvm)
16+
}
17+
18+
repositories {
19+
mavenCentral()
20+
mavenLocal {
21+
content {
22+
includeGroup("com.expediagroup")
23+
}
24+
}
25+
}
26+
27+
val properties = Properties()
28+
properties.load(File(rootDir.parentFile.parent, "gradle.properties").inputStream())
29+
for ((key, value) in properties) {
30+
project.ext[key.toString()] = value
31+
}
32+
33+
tasks {
34+
val kotlinJvmVersion: String by project
35+
/*
36+
Integration tests are run through maven-invoker-plugin which will execute tests under src/integration/<scenario>
37+
*/
38+
val mavenEnvironmentVariables = mapOf(
39+
"graphqlKotlinVersion" to project.ext["version"],
40+
"graphqlJavaVersion" to libs.versions.graphql.java.get(),
41+
"kotlinJvmTarget" to kotlinJvmVersion,
42+
"kotlinVersion" to libs.versions.kotlin.get(),
43+
"kotlinxCoroutinesVersion" to libs.versions.kotlinx.coroutines.get(),
44+
"kotlinPoetVersion" to libs.versions.poet.get(),
45+
"kotlinxSerializationVersion" to libs.versions.kotlinx.serialization.get(),
46+
"ktorVersion" to libs.versions.ktor.get(),
47+
"reactorVersion" to libs.versions.reactor.core.get(),
48+
"junitVersion" to libs.versions.junit.get()
49+
)
50+
var wireMockServer: WireMockServerRunner? = null
51+
var wireMockServerPort: Int? = null
52+
val startWireMock by register("startWireMock") {
53+
dependsOn(gradle.includedBuild("graphql-kotlin").task(":resolveIntegrationTestDependencies"))
54+
finalizedBy("stopWireMock")
55+
56+
doLast {
57+
val wireMockConfig = arrayOf(
58+
"--root-dir=${project.projectDir}/integration/wiremock",
59+
"--port=0"
60+
)
61+
wireMockServer = WireMockServerRunner()
62+
wireMockServer?.run(*wireMockConfig)
63+
wireMockServerPort = wireMockServer?.port()
64+
logger.info("wiremock started at port $wireMockServerPort")
65+
}
66+
}
67+
val stopWireMock by register("stopWireMock") {
68+
mustRunAfter("startWireMock")
69+
70+
doLast {
71+
val server = wireMockServer
72+
if (server?.isRunning == true) {
73+
logger.info("attempting to stop wiremock server")
74+
server.stop()
75+
logger.info("wiremock server stopped")
76+
}
77+
}
78+
}
79+
val integrationTest by register("integrationTest") {
80+
dependsOn(startWireMock.path)
81+
finalizedBy(stopWireMock.path)
82+
timeout.set(Duration.ofSeconds(500))
83+
doLast {
84+
exec {
85+
environment(mavenEnvironmentVariables)
86+
environment("graphqlEndpoint", "http://localhost:$wireMockServerPort")
87+
commandLine("${project.projectDir}/mvnw", "dependency:go-offline", "invoker:install", "invoker:run", "--no-transfer-progress")
88+
}
89+
}
90+
}
91+
check {
92+
dependsOn(integrationTest.path)
93+
}
94+
}
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
4+
networkTimeout=10000
5+
zipStoreBase=GRADLE_USER_HOME
6+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)