Skip to content

Commit

Permalink
feat: support for MPS 2024.1 and 2024.3
Browse files Browse the repository at this point in the history
  • Loading branch information
slisson committed Feb 10, 2025
1 parent 0f5ef5d commit 1d2c80f
Show file tree
Hide file tree
Showing 33 changed files with 429 additions and 392 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Binary Compatibility
name: Build

on:
push:
Expand All @@ -9,20 +9,30 @@ on:
workflow_dispatch:

jobs:
checkBinaryCompatibility:

build-mps-components:
runs-on: ubuntu-latest

timeout-minutes: 60
steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
java-version: '21'
- name: Set up Gradle
uses: gradle/gradle-build-action@v3
- name: Build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./check-binary-compatibility.sh
run: >-
./gradlew --build-cache
build
-PciBuild=true
- name: Archive test report
uses: actions/upload-artifact@v4
if: always()
with:
name: test-report
path: |
*/build/test-results
*/build/reports
54 changes: 0 additions & 54 deletions .github/workflows/mps-compatibility.yaml

This file was deleted.

3 changes: 1 addition & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
java-version: '21'
- name: Set up Gradle
uses: gradle/gradle-build-action@v3
- name: Use tag as version
Expand All @@ -40,4 +40,3 @@ jobs:
-Pgpr.user=${{ github.actor }}
-Pgpr.key=${{ secrets.GITHUB_TOKEN }}
-Pgpr.universalkey=${{ secrets.GHP_UNIVERSAL_PUBLISH_TOKEN }}
-Pmps.version=2023.2
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ subprojects {

allprojects {
repositories {
mavenLocal()
maven { url = uri("https://artifacts.itemis.cloud/repository/maven-mps/") }
mavenCentral()
maven { url = uri("https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven") }
mavenLocal()
}

publishing {
Expand Down
2 changes: 0 additions & 2 deletions buildSrc/src/main/kotlin/org/modelix/CopyMps.kt
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ val Project.mpsPlatformVersion: Int get() {
return mpsVersion.replace(Regex("""20(\d\d)\.(\d+).*"""), "$1$2").toInt()
}

val Project.mpsJavaVersion: Int get() = if (mpsPlatformVersion >= 223) 17 else 11

val Project.mpsHomeDir: Provider<Directory> get() {
if (project != rootProject) return rootProject.mpsHomeDir
return project.layout.buildDirectory.dir("mps-$mpsVersion")
Expand Down
19 changes: 0 additions & 19 deletions check-binary-compatibility.sh

This file was deleted.

1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ modelix-modelql-untyped = { group = "org.modelix", name = "modelql-untyped", ver
modelix-modelql-html = { group = "org.modelix", name = "modelql-html", version.ref = "modelixCore" }
modelix-model-datastructure = { group = "org.modelix", name = "model-datastructure", version.ref = "modelixCore" }
modelix-mps-model-adapters = { group = "org.modelix.mps", name = "model-adapters", version.ref = "modelixCore" }
modelix-mpsApi = { group = "org.modelix.mps", name = "stable-api", version = "1.1.1" }

kotlin-logging = { group = "io.github.oshai", name = "kotlin-logging", version = "7.0.3" }
kotlin-logging-microutils = { group = "io.github.microutils", name = "kotlin-logging", version = "3.0.5" }
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
20 changes: 10 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
27 changes: 27 additions & 0 deletions mps-diff-plugin-test/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import org.zeroturnaround.zip.ZipUtil

buildscript {
dependencies {
classpath("org.modelix.mps:build-tools-lib:1.8.1")
}
}

plugins {
id("org.jetbrains.kotlin.jvm")
}

dependencies {
implementation(coreLibs.kotlin.coroutines.test)
implementation(coreLibs.ktor.client.cio)
implementation(coreLibs.testcontainers)
}

tasks {
val unzipTestProject by registering {
ZipUtil.unpack(layout.projectDirectory.file("diff-test-project.zip").asFile, layout.buildDirectory.dir("diff-test-project").get().asFile)
}
test {
dependsOn(":mps-diff-plugin:prepareSandbox")
dependsOn(unzipTestProject)
}
}
File renamed without changes.
96 changes: 96 additions & 0 deletions mps-diff-plugin-test/src/test/kotlin/DiffPluginTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
package org.modelix.mps.generator.web

import io.ktor.client.HttpClient
import io.ktor.client.engine.cio.CIO
import io.ktor.client.request.get
import io.ktor.client.statement.bodyAsBytes
import io.ktor.client.statement.bodyAsText
import junit.framework.TestCase.assertEquals
import kotlinx.coroutines.test.runTest
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
import org.testcontainers.containers.GenericContainer
import org.testcontainers.containers.wait.strategy.Wait
import org.testcontainers.utility.MountableFile
import java.io.File
import kotlin.time.Duration.Companion.minutes
import kotlin.time.toJavaDuration

@RunWith(Parameterized::class)
class DiffPluginTest(val mpsVersion: String) {

companion object {
val timeout = 5.minutes

@Parameterized.Parameters(name = "{0}")
@JvmStatic
fun mpsVersions() = listOf(
"2024.3",
"2024.1",
"2023.3",
"2023.2",
// "2022.3",
// "2022.2",
// "2021.3",
// "2021.2",
// "2021.1",
// "2020.3",
)
}

private fun runWithMPS(body: suspend (port: Int) -> Unit) = runTest(timeout = timeout) {
println("MPS version: $mpsVersion")

val mps: GenericContainer<*> = GenericContainer("docker.io/modelix/mps-vnc-baseimage:0.9.4-mps$mpsVersion")
.withExposedPorts(33334)
.withCopy(
"../mps-diff-plugin/build/idea-sandbox/plugins/mps-diff-plugin",
"/mps/plugins/mps-diff-plugin",
)
.withCopy(
"build/diff-test-project",
"/mps-projects/diff-test-project",
)
// .withCreateContainerCmdModifier {
// it.withPlatform("linux/amd64")
// }
.waitingFor(Wait.forListeningPort().withStartupTimeout(timeout.toJavaDuration()))
.withLogConsumer {
println(it.utf8StringWithoutLineEnding)
}

mps.start()
try {
body(mps.firstMappedPort)
} finally {
mps.stop()
}
}

@Test
fun `diff images page`() = runWithMPS { port ->
val client = HttpClient(CIO)
val baseUrl = "http://localhost:$port"
val diffUrl = "$baseUrl/54ff8ce1442ac24e065d0ba99ae96b752a4427cf/38fd1c4668b8bb600a4193def54ae4281045c790/"
val diffPageHtml = client.get(diffUrl).bodyAsText()
println(diffPageHtml)
val folder = File("build/diff-images/$mpsVersion/")
folder.mkdirs()
folder.resolve("index.html").writeText(diffPageHtml)

val imageNames = Regex("""src="([^\"]+\.png)"""").findAll(diffPageHtml).map { it.groupValues[1] }.toList()
println(imageNames)
assertEquals(3, imageNames.size)

for (imageName in imageNames) {
val data = client.get("$diffUrl/$imageName").bodyAsBytes()
folder.resolve(imageName).writeBytes(data)
}
}
}

private fun <T : GenericContainer<T>> T.withCopy(from: String, to: String): T {
require(File(from).exists()) { "Doesn't exist: $from" }
return withCopyFileToContainer(MountableFile.forHostPath(from), to)
}
Loading

0 comments on commit 1d2c80f

Please sign in to comment.