Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redefines the Gradle build strategy #175

Merged
merged 26 commits into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
7c2e66f
Redefines the Gradle build strategy
juanpedromoreno Jun 7, 2023
06d331a
Runs-on based on matrix. It also
juanpedromoreno Jun 8, 2023
c62f6fe
gradlew VW gradelw.bat
juanpedromoreno Jun 8, 2023
4deb864
Fixes build.yml file
juanpedromoreno Jun 8, 2023
dda2747
Changes gradlew.bat permissions
juanpedromoreno Jun 8, 2023
11efcdc
cmd.exe /c
juanpedromoreno Jun 8, 2023
ef3395d
+ task aliases
juanpedromoreno Jun 8, 2023
62b0030
Windows gradlecommand just gradle.bat
juanpedromoreno Jun 8, 2023
0fb26b1
quoting windows command
juanpedromoreno Jun 8, 2023
e91a340
Merge branch 'main' into build-platform-matrix
juanpedromoreno Jun 8, 2023
3458b92
Further optimizations
juanpedromoreno Jun 8, 2023
e5c40b7
Fixes a bug
juanpedromoreno Jun 8, 2023
037233a
Fixes a bug trying to fix another bug
juanpedromoreno Jun 8, 2023
b8713fd
Singlep only for jvm
juanpedromoreno Jun 8, 2023
e4d8983
Merge branch 'main' into build-platform-matrix
juanpedromoreno Jun 13, 2023
4b0e930
Merge branch 'main' into build-platform-matrix
raulraja Jun 16, 2023
9e7afdb
Merge branch 'main' into build-platform-matrix
diesalbla Jun 22, 2023
a9726bb
Merge branch 'main' into build-platform-matrix
diesalbla Jun 23, 2023
fc6942c
Merge branch 'main' into build-platform-matrix
diesalbla Jun 27, 2023
d9fd2c1
Merge branch 'main' into build-platform-matrix
raulraja Jun 28, 2023
3e0d444
Merge branch 'main' into build-platform-matrix
raulraja Jun 29, 2023
b68280f
Merge branch 'main' into build-platform-matrix
raulraja Jun 30, 2023
15c813f
Merge branch 'main' into build-platform-matrix
raulraja Jul 6, 2023
18b6ae2
Getting list of subprojects dynamically
Yawolf Jul 6, 2023
fe049c8
Merge branch 'build-platform-matrix' of github.com:xebia-functional/x…
Yawolf Jul 6, 2023
692fb70
Filtering multiplatform
Yawolf Jul 6, 2023
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
26 changes: 23 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,23 @@ concurrency:

jobs:
check:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
timeout-minutes: 15

strategy:
matrix:
include:
- platform: jvm
os: ubuntu-latest
- platform: js
os: ubuntu-latest
- platform: linuxX64
os: ubuntu-latest
- platform: macosX64
os: macos-latest
- platform: mingwX64
os: windows-latest

steps:
- uses: actions/checkout@v3
with:
Expand All @@ -23,10 +37,16 @@ jobs:
distribution: 'zulu'
java-version: 19

- name: build
- name: Build and Test (multip)
uses: gradle/gradle-build-action@v2
with:
arguments: buildAndTestMultip -Pplatform=${{ matrix.platform }}

- name: Build and Test (singlep)
uses: gradle/gradle-build-action@v2
with:
arguments: build --full-stacktrace
arguments: buildAndTestSinglep -Pplatform=${{ matrix.platform }}
if: ${{ matrix.platform == 'jvm' }}

- name: Upload reports
if: failure()
Expand Down
63 changes: 63 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,66 @@ plugins {
allprojects {
group = property("project.group").toString()
}

fun isMultiplatformModule(project: Project): Boolean {
val kotlinPluginId = "libs.plugins.kotlin.multiplatform"
return project.buildFile.readText().contains(kotlinPluginId)
}

val multiPlatformModules = project.subprojects.filter { isMultiplatformModule(it) }.map { it.name }

enum class ModuleType {
MULTIPLATFORM,
SINGLEPLATFORM
}

fun Project.configureBuildAndTestTask(
taskName: String,
moduleType: ModuleType,
multiPlatformModules: List<String>
) {
val platform: String by extra

tasks.register(taskName) {
doLast {
project.exec {
val gradleCommand = getGradleCommand(platform)
commandLine(gradleCommand, "spotlessCheck")
when (moduleType) {
ModuleType.MULTIPLATFORM -> {
multiPlatformModules.forEach { module ->
commandLine(gradleCommand, ":$module:${platform}Test")
}
}
ModuleType.SINGLEPLATFORM -> {
commandLine(gradleCommand, "build", *buildExcludeOptions(multiPlatformModules))
}
}
}
}
}
}

fun Project.buildExcludeOptions(modules: List<String>): Array<String> {
return modules.flatMap { listOf("-x", ":$it:build") }.toTypedArray()
}

fun getGradleCommand(platform: String): String {
return if (platform == "mingwX64") {
"gradlew.bat"
} else {
"./gradlew"
}
}

configureBuildAndTestTask(
"buildAndTestMultip",
ModuleType.MULTIPLATFORM,
multiPlatformModules
)

configureBuildAndTestTask(
"buildAndTestSinglep",
ModuleType.SINGLEPLATFORM,
multiPlatformModules
)
Empty file modified gradlew.bat
100644 → 100755
Empty file.