Skip to content

Commit

Permalink
build: migrate maven plugin integration tests to a composite build (#…
Browse files Browse the repository at this point in the history
…1662)

### 📝 Description

Migrate Maven plugin integration tests to a composite build to speed up the overall build and simplify main build logic.

### 🔗 Related Issues
  • Loading branch information
dariuszkuc authored Jan 30, 2023
1 parent 1fbbd48 commit d13be15
Show file tree
Hide file tree
Showing 74 changed files with 741 additions and 465 deletions.
49 changes: 47 additions & 2 deletions .github/workflows/plugin-it.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Gradle Plugin Integration Tests
name: Plugin Integration Tests

on:
workflow_call:
Expand All @@ -24,8 +24,15 @@ jobs:
uses: gradle/gradle-build-action@v2
- name: Android Test
run: ./gradlew build
- name: Archive failures
uses: actions/upload-artifact@v3
if: failure()
with:
name: gradle-plugin-android-build-reports
path: integration/gradle-plugin-android-test/**/build/reports
retention-days: 7

integration-tests:
gradle-integration-tests:
timeout-minutes: 30
runs-on: ubuntu-latest
defaults:
Expand All @@ -45,3 +52,41 @@ jobs:
uses: gradle/gradle-build-action@v2
- name: Integration Tests
run: ./gradlew build
- name: Archive failures
uses: actions/upload-artifact@v3
if: failure()
with:
name: gradle-plugin-build-reports
path: integration/gradle-plugin-integration-tests/**/build/reports
retention-days: 7

maven-integration-tests:
timeout-minutes: 30
runs-on: ubuntu-latest
defaults:
run:
working-directory: integration/maven-plugin-integration-tests

steps:
- uses: actions/checkout@v3
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: Set up Java 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'zulu'
cache: 'maven'
- name: Set up Gradle cache
uses: gradle/gradle-build-action@v2
- name: Integration Tests
run: ./gradlew build
- name: Archive failures
uses: actions/upload-artifact@v3
if: failure()
with:
name: maven-plugin-build-reports
path: |
integration/maven-plugin-integration-tests/build/integration/**/build.log
integration/maven-plugin-integration-tests/build/integration/**/target/surefire-reports
retention-days: 7
2 changes: 0 additions & 2 deletions .github/workflows/release-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,4 @@ jobs:
name: build-reports
path: |
./**/build/reports
plugins/graphql-kotlin-maven-plugin/build/integration/**/build.log
plugins/graphql-kotlin-maven-plugin/build/integration/**/target/surefire-reports
retention-days: 7
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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
#
# https://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.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar
94 changes: 94 additions & 0 deletions integration/maven-plugin-integration-tests/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import com.github.tomakehurst.wiremock.standalone.WireMockServerRunner
import java.time.Duration
import java.util.Properties

description = "GraphQL Kotlin Maven Plugin that can generate type-safe GraphQL Kotlin client and GraphQL schema in SDL format using reflections"

buildscript {
dependencies {
classpath(libs.wiremock.standalone)
}
}

@Suppress("DSL_SCOPE_VIOLATION") // TODO: remove once KTIJ-19369 / Gradle#22797 is fixed
plugins {
alias(libs.plugins.kotlin.jvm)
}

repositories {
mavenCentral()
mavenLocal {
content {
includeGroup("com.expediagroup")
}
}
}

val properties = Properties()
properties.load(File(rootDir.parentFile.parent, "gradle.properties").inputStream())
for ((key, value) in properties) {
project.ext[key.toString()] = value
}

tasks {
val kotlinJvmVersion: String by project
/*
Integration tests are run through maven-invoker-plugin which will execute tests under src/integration/<scenario>
*/
val mavenEnvironmentVariables = mapOf(
"graphqlKotlinVersion" to project.ext["version"],
"graphqlJavaVersion" to libs.versions.graphql.java.get(),
"kotlinJvmTarget" to kotlinJvmVersion,
"kotlinVersion" to libs.versions.kotlin.get(),
"kotlinxCoroutinesVersion" to libs.versions.kotlinx.coroutines.get(),
"kotlinPoetVersion" to libs.versions.poet.get(),
"kotlinxSerializationVersion" to libs.versions.kotlinx.serialization.get(),
"ktorVersion" to libs.versions.ktor.get(),
"reactorVersion" to libs.versions.reactor.core.get(),
"junitVersion" to libs.versions.junit.get()
)
var wireMockServer: WireMockServerRunner? = null
var wireMockServerPort: Int? = null
val startWireMock by register("startWireMock") {
dependsOn(gradle.includedBuild("graphql-kotlin").task(":resolveIntegrationTestDependencies"))
finalizedBy("stopWireMock")

doLast {
val wireMockConfig = arrayOf(
"--root-dir=${project.projectDir}/integration/wiremock",
"--port=0"
)
wireMockServer = WireMockServerRunner()
wireMockServer?.run(*wireMockConfig)
wireMockServerPort = wireMockServer?.port()
logger.info("wiremock started at port $wireMockServerPort")
}
}
val stopWireMock by register("stopWireMock") {
mustRunAfter("startWireMock")

doLast {
val server = wireMockServer
if (server?.isRunning == true) {
logger.info("attempting to stop wiremock server")
server.stop()
logger.info("wiremock server stopped")
}
}
}
val integrationTest by register("integrationTest") {
dependsOn(startWireMock.path)
finalizedBy(stopWireMock.path)
timeout.set(Duration.ofSeconds(500))
doLast {
exec {
environment(mavenEnvironmentVariables)
environment("graphqlEndpoint", "http://localhost:$wireMockServerPort")
commandLine("${project.projectDir}/mvnw", "dependency:go-offline", "invoker:install", "invoker:run", "--no-transfer-progress")
}
}
}
check {
dependsOn(integrationTest.path)
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit d13be15

Please sign in to comment.