Skip to content

Commit

Permalink
Add validateProjectList task
Browse files Browse the repository at this point in the history
  • Loading branch information
Lipen committed Jan 16, 2025
1 parent d3fb216 commit a228a8c
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ jobs:
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- name: Validate Project List
run: ./gradlew validateProjectList

- name: Run Detekt
run: ./gradlew detektMain detektTest

Expand Down
35 changes: 35 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,38 @@
plugins {
id("usvm.kotlin-conventions")
}

tasks.register("validateProjectList") {
group = "verification"
description = "Checks that the list of subprojects is exactly the expected."

doLast {
// Define the expected subprojects here.
val expectedProjects = setOf(
project(":usvm-core"),
project(":usvm-util"),
project(":usvm-dataflow"),
project(":usvm-sample-language"),
project(":usvm-jvm"),
project(":usvm-jvm-dataflow"),
project(":usvm-jvm-instrumentation"),
project(":usvm-python"),
project(":usvm-ts"),
project(":usvm-ts-dataflow"),
)

// Gather the actual subprojects from the current root project.
// Note: 'project.subprojects' is recursive!
val actualProjects = project.subprojects - project(":usvm-python").subprojects

// Compare and throw an error if something is missing or unexpected.
val missingProjects = expectedProjects - actualProjects
if (missingProjects.isNotEmpty()) {
throw GradleException("Missing subprojects (${missingProjects.size}): $missingProjects")
}
val unexpectedProjects = actualProjects - expectedProjects
if (unexpectedProjects.isNotEmpty()) {
throw GradleException("Unexpected subprojects (${unexpectedProjects.size}): $unexpectedProjects")
}
}
}

0 comments on commit a228a8c

Please sign in to comment.