Skip to content
Closed
Show file tree
Hide file tree
Changes from 5 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"
7 changes: 7 additions & 0 deletions openapi/openapi-client/src/main/openapi3/master_rest_v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,13 @@ components:
inNative:
type: boolean
description: Whether the thread is executing native code.
isDaemon:
type: boolean
description: Whether the thread is a daemon thread.
priority:
type: integer
format: int32
description: The priority of the thread.
required:
- threadId
- threadName
Expand Down
7 changes: 7 additions & 0 deletions openapi/openapi-client/src/main/openapi3/worker_rest_v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,13 @@ components:
inNative:
type: boolean
description: Whether the thread is executing native code.
isDaemon:
type: boolean
description: Whether the thread is a daemon thread.
priority:
type: integer
format: int32
description: The priority of the thread.
required:
- threadId
- threadName
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