Skip to content
Closed
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
19 changes: 19 additions & 0 deletions .github/workflows/sbt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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() {
}

Expand Down Expand Up @@ -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) {
Expand All @@ -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
Expand All @@ -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();
}
Expand Down
45 changes: 45 additions & 0 deletions project/CelebornBuild.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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}"
Expand Down