diff --git a/.github/workflows/sbt.yml b/.github/workflows/sbt.yml index cacb97793ec..8680de6285f 100644 --- a/.github/workflows/sbt.yml +++ b/.github/workflows/sbt.yml @@ -260,3 +260,22 @@ jobs: **/target/test/ **/target/test-reports/** **/target/unit-tests.log + + openapi-codegen-check: + runs-on: ubuntu-22.04 + strategy: + fail-fast: false + matrix: + java: + - 11 + steps: + - uses: actions/checkout@v4 + - name: Setup JDK ${{ matrix.java }} + uses: actions/setup-java@v4 + with: + distribution: zulu + java-version: ${{ matrix.java }} + check-latest: false + - name: Test with SBT + run: | + build/sbt "clean;celeborn-openapi-client/check" diff --git a/openapi/openapi-client/src/main/java/org/apache/celeborn/rest/v1/model/ThreadStack.java b/openapi/openapi-client/src/main/java/org/apache/celeborn/rest/v1/model/ThreadStack.java index ff133a23c71..f0f9b5b9d89 100644 --- a/openapi/openapi-client/src/main/java/org/apache/celeborn/rest/v1/model/ThreadStack.java +++ b/openapi/openapi-client/src/main/java/org/apache/celeborn/rest/v1/model/ThreadStack.java @@ -47,9 +47,7 @@ ThreadStack.JSON_PROPERTY_LOCK_NAME, ThreadStack.JSON_PROPERTY_LOCK_OWNER_NAME, ThreadStack.JSON_PROPERTY_SUSPENDED, - ThreadStack.JSON_PROPERTY_IN_NATIVE, - ThreadStack.JSON_PROPERTY_IS_DAEMON, - ThreadStack.JSON_PROPERTY_PRIORITY + ThreadStack.JSON_PROPERTY_IN_NATIVE }) @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class ThreadStack { @@ -92,12 +90,6 @@ public class ThreadStack { public static final String JSON_PROPERTY_IN_NATIVE = "inNative"; private Boolean inNative; - public static final String JSON_PROPERTY_IS_DAEMON = "isDaemon"; - private Boolean isDaemon; - - public static final String JSON_PROPERTY_PRIORITY = "priority"; - private Integer priority; - public ThreadStack() { } @@ -458,56 +450,6 @@ public void setInNative(Boolean inNative) { this.inNative = inNative; } - public ThreadStack isDaemon(Boolean isDaemon) { - - this.isDaemon = isDaemon; - return this; - } - - /** - * Whether the thread is a daemon thread. - * @return isDaemon - */ - @javax.annotation.Nullable - @JsonProperty(JSON_PROPERTY_IS_DAEMON) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - - public Boolean getIsDaemon() { - return isDaemon; - } - - - @JsonProperty(JSON_PROPERTY_IS_DAEMON) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setIsDaemon(Boolean isDaemon) { - this.isDaemon = isDaemon; - } - - public ThreadStack priority(Integer priority) { - - this.priority = priority; - return this; - } - - /** - * The priority of the thread. - * @return priority - */ - @javax.annotation.Nullable - @JsonProperty(JSON_PROPERTY_PRIORITY) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - - public Integer getPriority() { - return priority; - } - - - @JsonProperty(JSON_PROPERTY_PRIORITY) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setPriority(Integer priority) { - this.priority = priority; - } - @Override public boolean equals(Object o) { if (this == o) { @@ -529,14 +471,12 @@ public boolean equals(Object o) { Objects.equals(this.lockName, threadStack.lockName) && Objects.equals(this.lockOwnerName, threadStack.lockOwnerName) && Objects.equals(this.suspended, threadStack.suspended) && - Objects.equals(this.inNative, threadStack.inNative) && - Objects.equals(this.isDaemon, threadStack.isDaemon) && - Objects.equals(this.priority, threadStack.priority); + Objects.equals(this.inNative, threadStack.inNative); } @Override public int hashCode() { - return Objects.hash(threadId, threadName, threadState, stackTrace, blockedByThreadId, blockedByLock, holdingLocks, synchronizers, monitors, lockName, lockOwnerName, suspended, inNative, isDaemon, priority); + return Objects.hash(threadId, threadName, threadState, stackTrace, blockedByThreadId, blockedByLock, holdingLocks, synchronizers, monitors, lockName, lockOwnerName, suspended, inNative); } @Override @@ -556,8 +496,6 @@ public String toString() { sb.append(" lockOwnerName: ").append(toIndentedString(lockOwnerName)).append("\n"); sb.append(" suspended: ").append(toIndentedString(suspended)).append("\n"); sb.append(" inNative: ").append(toIndentedString(inNative)).append("\n"); - sb.append(" isDaemon: ").append(toIndentedString(isDaemon)).append("\n"); - sb.append(" priority: ").append(toIndentedString(priority)).append("\n"); sb.append("}"); return sb.toString(); } diff --git a/project/CelebornBuild.scala b/project/CelebornBuild.scala index a28c15d2af8..d1e7bc4c931 100644 --- a/project/CelebornBuild.scala +++ b/project/CelebornBuild.scala @@ -1356,6 +1356,7 @@ object CelebornOpenApi { val openApiClientOutputDir = "openapi/openapi-client/src/main/java" val generate = TaskKey[Unit]("generate", "generate openapi client code") + val check = TaskKey[Unit]("check", "check the openapi spec and generated code") val commonOpenApiClientGenerateSettings = Seq( openApiGeneratorName := "java", @@ -1432,6 +1433,50 @@ object CelebornOpenApi { IO.copyDirectory(workerSrcDir, dstDir) }, + check := { + (openApiClientMasterGenerate / Compile / openApiGenerate).value + (openApiClientWorkerGenerate / Compile / openApiGenerate).value + + val internalMasterSrcDir = file(openApiMasterInternalOutputDir) / "src" / "main" / "java" + val internalWorkerSrcDir = file(openApiWorkerInternalOutputDir) / "src" / "main" / "java" + val openApiSrcDir = file(openApiClientOutputDir) + + def getRelativePaths(dir: File): Set[String] = { + (dir ** "*.java").get.map(_.relativeTo(dir).get.getPath).toSet + } + val internalSrcPaths = getRelativePaths(internalMasterSrcDir) ++ getRelativePaths(internalWorkerSrcDir) + val openApiSrcPaths = getRelativePaths(openApiSrcDir) + val notGeneratedSrcPaths = openApiSrcPaths -- internalSrcPaths + if (notGeneratedSrcPaths.nonEmpty) { + sys.error(s"Files ${notGeneratedSrcPaths.mkString(", ")} not generated by openapi generator anymore, seems outdated.") + } + + def diffDirSrcFiles(srcDir: File, dstDir: File): Unit = { + val srcFiles = (srcDir ** "*.java").get + val dstFiles = (dstDir ** "*.java").get + + srcFiles.foreach { srcFile => + val relativePath = srcFile.relativeTo(srcDir).get.getPath + val dstFile = dstDir / relativePath + + if (!dstFile.exists()) { + sys.error(s"File $relativePath does not exist in the openapi client code directory") + } else { + val srcContent = IO.read(srcFile, UTF_8) + val dstContent = IO.read(dstFile, UTF_8) + + if (srcContent != dstContent) { + sys.error(s"File $relativePath differs, please re-generate the code.") + } + } + } + } + diffDirSrcFiles(internalMasterSrcDir, openApiSrcDir) + diffDirSrcFiles(internalWorkerSrcDir, openApiSrcDir) + + streams.value.log.info("The openapi spec and code are consistent.") + }, + (assembly / test) := { }, (assembly / assemblyJarName) := { s"${moduleName.value}-${version.value}.${artifact.value.extension}"