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

Add Language Server Simulator #4739

Merged
merged 10 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from 7 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
83 changes: 83 additions & 0 deletions .github/workflows/language_server_simulator_fhir.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Language Server Simulator on FHIR

on:
schedule:
- cron: '0 */12 * * *'
workflow_dispatch:

jobs:
run_simulator:
name: Run LS Simulator
runs-on: ubuntu-latest
timeout-minutes: 240
strategy:
fail-fast: false
matrix:
branch: [ "master", "2201.8.x", "2201.7.x" ]
skipGenerators: [ "" ]

steps:
- name: Checkout Repository
uses: actions/checkout@v2
with:
ref: ${{ matrix.branch }}

- name: Set up JDK 11
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '11'

- name: Initialize sub-modules
run: git submodule update --init

- name: Build with Gradle
timeout-minutes: 180
env:
packageUser: ${{ secrets.PACKAGE_USER}}
packagePAT: ${{ secrets.PACKAGE_PAT}}
run: |
export DISPLAY=':99.0'
/usr/bin/Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
./gradlew clean :language-server-simulator:runLSSimulatorOnFHIR -Dls.simulation.skipGenerators=${{ matrix.skipGenerators }}

- name: Check Simulation Failure
run: if test -f dump.hprof; then exit 1; else exit 0; fi

- name: Analyze Heap Dump If Exists
if: failure()
run: |
if test -f dump.hprof; then echo "Heap sump exists. Analyzing..."; else exit 0; fi
wget https://ftp.jaist.ac.jp/pub/eclipse/mat/1.12.0/rcp/MemoryAnalyzer-1.12.0.20210602-linux.gtk.x86_64.zip
unzip MemoryAnalyzer-1.12.0.20210602-linux.gtk.x86_64.zip
./mat/ParseHeapDump.sh ./dump.hprof org.eclipse.mat.api:suspects

- name: Upload Heap Dumps
uses: actions/upload-artifact@v2
if: always()
with:
name: heap_dump-${{ matrix.branch }}.hprof
path: '*.hprof'

- name: Upload Leaks Suspects
uses: actions/upload-artifact@v2
if: failure()
with:
name: Leak_Suspects-${{ matrix.branch }}
path: 'dump_Leak_Suspects.zip'

- name: Notify failure
if: failure()
run: |
curl -X POST \
'https://github.com/gitapi/repos/ballerina-platform/ballerina-release/dispatches' \
-H 'Accept: application/vnd.github.v3+json' \
-H 'Authorization: Bearer ${{ secrets.BALLERINA_BOT_TOKEN }}' \
--data "{
\"event_type\": \"notify-simulator-failure\",
\"client_payload\": {
\"branch\": \"${{ matrix.branch }}\"
}
}"


malinthar marked this conversation as resolved.
Show resolved Hide resolved
83 changes: 83 additions & 0 deletions .github/workflows/language_server_simulator_nballerina.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Language Server Simulator on nBallerina

on:
schedule:
- cron: '0 */12 * * *'
workflow_dispatch:

jobs:
run_simulator:
name: Run LS Simulator
runs-on: ubuntu-latest
timeout-minutes: 240
strategy:
fail-fast: false
matrix:
branch: [ "master", "2201.8.x", "2201.7.x" ]
skipGenerators: [ "" ]
malinthar marked this conversation as resolved.
Show resolved Hide resolved

steps:
- name: Checkout Repository
uses: actions/checkout@v2
with:
ref: ${{ matrix.branch }}

- name: Set up JDK 11
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '11'

- name: Initialize sub-modules
run: git submodule update --init

- name: Build with Gradle
timeout-minutes: 180
env:
packageUser: ${{ secrets.PACKAGE_USER}}
packagePAT: ${{ secrets.PACKAGE_PAT}}
run: |
export DISPLAY=':99.0'
/usr/bin/Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
./gradlew clean :language-server-simulator:runLSSimulatorOnnBallerina -Dls.simulation.skipGenerators=${{ matrix.skipGenerators }}

- name: Check Simulation Failure
run: if test -f dump.hprof; then exit 1; else exit 0; fi

- name: Analyze Heap Dump If Exists
if: failure()
run: |
if test -f dump.hprof; then echo "Heap sump exists. Analyzing..."; else exit 0; fi
wget https://ftp.jaist.ac.jp/pub/eclipse/mat/1.12.0/rcp/MemoryAnalyzer-1.12.0.20210602-linux.gtk.x86_64.zip
unzip MemoryAnalyzer-1.12.0.20210602-linux.gtk.x86_64.zip
./mat/ParseHeapDump.sh ./dump.hprof org.eclipse.mat.api:suspects

- name: Upload Heap Dumps
uses: actions/upload-artifact@v2
if: always()
with:
name: heap_dump-${{ matrix.branch }}.hprof
path: '*.hprof'

- name: Upload Leaks Suspects
uses: actions/upload-artifact@v2
if: failure()
with:
name: Leak_Suspects-${{ matrix.branch }}
path: 'dump_Leak_Suspects.zip'

- name: Notify failure
if: failure()
run: |
curl -X POST \
'https://github.com/gitapi/repos/ballerina-platform/ballerina-release/dispatches' \
-H 'Accept: application/vnd.github.v3+json' \
-H 'Authorization: Bearer ${{ secrets.BALLERINA_BOT_TOKEN }}' \
--data "{
\"event_type\": \"notify-simulator-failure\",
\"client_payload\": {
\"branch\": \"${{ matrix.branch }}\"
}
}"


malinthar marked this conversation as resolved.
Show resolved Hide resolved
138 changes: 138 additions & 0 deletions language-server-simulator/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
description = 'Ballerina Language Server Simulator'

apply from: "$rootDir/gradle/javaProject.gradle"

configurations {
ballerinaDistribution
jBallerinaDistribution
dependency {
transitive true
}
}

ext {
distributionDir = "distribution"
nbalSourceDir = "nBallerinaSrc"
fhirSourceDir = "fhirSrc"
shortVersion = "${version}".split("-")[0]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@malinthar I think we could get rid of short version and just use the project version. This was used in pre swanlake releases

Copy link
Contributor Author

@malinthar malinthar Jul 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

We have to use the shortVersion to refer to the highlighted folder above

}

dependencies {
implementation "org.slf4j:slf4j-api:${project.slf4jApiVersion}"
implementation group: 'org.ballerinalang', name: 'ballerina-lang', version: "${ballerinaLangVersion}"
implementation group: 'org.ballerinalang', name: 'ballerina-parser', version: "${ballerinaLangVersion}"
implementation group: 'org.ballerinalang', name: 'language-server-core', version: "${ballerinaLangVersion}"
implementation group: 'org.ballerinalang', name: 'ballerina-tools-api', version: "${ballerinaLangVersion}"
implementation group: 'org.ballerinalang', name: 'language-server-commons', version: "${ballerinaLangVersion}"
implementation group: 'org.ballerinalang', name: 'ballerina-test-utils', version: "${ballerinaLangVersion}"
implementation(group: 'org.eclipse.lsp4j', name:'org.eclipse.lsp4j', version:"${eclipseLsp4jVersion}") {
exclude group: 'com.google.guava', module: 'guava'
}
implementation (group: 'org.eclipse.lsp4j', name:'org.eclipse.lsp4j.jsonrpc', version:"${eclipseLsp4jJsonrpcVersion}"){
exclude group: 'com.google.guava', module: 'guava'
}
implementation "org.slf4j:slf4j-jdk14:${slf4jJdk14Version}"
implementation "com.google.code.gson:gson:${gsonVersion}"
}

task unpackBallerinaDistribution(type: Copy) {
def sourceDir = "${buildDir}/${distributionDir}"
from zipTree { "${rootDir}/ballerina/build/distributions/ballerina-${version}-swan-lake.zip" }
new File("${sourceDir}").mkdirs()
into new File("${sourceDir}")
}

task copyPackages() {
dependsOn unpackBallerinaDistribution
def sourceDir = "${buildDir}/${distributionDir}" +
"/ballerina-${version}-swan-lake/distributions/ballerina-${shortVersion}/repo"
copy {
from "${sourceDir}"
into "${buildDir}/repo"
}
}

task downloadBalTestProject(type: Download) {
// Download nBallerina latest tag
src "https://github.com/ballerina-platform/nballerina/archive/refs/heads/main.zip"
onlyIfModified true
dest new File("${buildDir}/nballeirna-src.zip")
}


task downloadBalFHIRTestProject(type: Download) {
// Download nBallerina latest tag
src "https://github.com/ballerina-platform/module-ballerinax-health.fhir.r4/archive/refs/tags/uscore-v1.0.5.zip"
onlyIfModified true
dest new File("${buildDir}/fhir-src.zip")
}

task unpackBalTestProject(type: Copy) {
dependsOn downloadBalTestProject
def sourceDir = "${buildDir}/${nbalSourceDir}"
from zipTree { "${buildDir}/nballeirna-src.zip" }
new File("${sourceDir}").mkdirs()
into new File("${sourceDir}")
}

task unpackBalFHIRTestProject(type: Copy) {
dependsOn downloadBalFHIRTestProject
def sourceDir = "${buildDir}/${fhirSourceDir}"
from zipTree { "${buildDir}/fhir-src.zip" }
new File("${sourceDir}").mkdirs()
into new File("${sourceDir}")
}

task runLSSimulatorOnnBallerina(type: JavaExec) {
dependsOn copyPackages
dependsOn unpackBalTestProject

def extractedBalSrcDir = "${buildDir}/${nbalSourceDir}/nballerina-main/compiler"
systemProperty "ls.simulation.src", "${extractedBalSrcDir}"

systemProperty "ballerina.home", "$buildDir/"
systemProperty "ballerina.version", "${ballerinaLangVersion}"
systemProperty "ls.simulation.duration", "60"
systemProperty "ls.simulation.skipGenerators", System.getProperty("ls.simulation.skipGenerators")
systemProperty "LANG_REPO_BUILD", "false"

jvmArgs = ['-XX:+HeapDumpOnOutOfMemoryError', "-XX:HeapDumpPath=$rootDir/dump.hprof"]

maxHeapSize "1536m"
group = "Execution"
description = "Run the main class with JavaExecTask"
classpath = sourceSets.main.runtimeClasspath
main = "org.ballerinalang.langserver.simulator.EditorSimulator"
}

task runLSSimulatorOnFHIR(type: JavaExec) {
dependsOn copyPackages
dependsOn unpackBalFHIRTestProject

def extractedBalSrcDir = "${buildDir}/${fhirSourceDir}/module-ballerinax-health.fhir.r4-uscore-v1.0.5/base"
systemProperty "ls.simulation.src", "${extractedBalSrcDir}"

systemProperty "ballerina.home", "$buildDir/"
systemProperty "ballerina.version", "${ballerinaLangVersion}"
systemProperty "ls.simulation.duration", "60"
systemProperty "ls.simulation.skipGenerators", System.getProperty("ls.simulation.skipGenerators")
systemProperty "LANG_REPO_BUILD", "false"

jvmArgs = ['-XX:+HeapDumpOnOutOfMemoryError', "-XX:HeapDumpPath=$rootDir/dump.hprof"]

maxHeapSize "1536m"
group = "Execution"
description = "Run the main class with JavaExecTask"
classpath = sourceSets.main.runtimeClasspath
main = "org.ballerinalang.langserver.simulator.EditorSimulator"
}

tasks.compileJava {
doFirst {
options.encoding = 'UTF-8'
options.compilerArgs = [
'--module-path', classpath.asPath,
]
classpath = files()
}
}
5 changes: 5 additions & 0 deletions language-server-simulator/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
eclipseLsp4jVersion=0.15.0
eclipseLsp4jJsonrpcVersion=0.15.0
slf4jJdk14Version=1.7.26
gsonVersion=2.9.1
slf4jApiVersion=1.7.s26
12 changes: 12 additions & 0 deletions language-server-simulator/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module io.ballerina.language.server.simulator {
uses org.ballerinalang.langserver.simulator.generators.CodeSnippetGenerator;
requires org.eclipse.lsp4j;
requires io.ballerina.language.server.commons;
requires io.ballerina.language.server.core;
requires org.eclipse.lsp4j.jsonrpc;
requires io.ballerina.lang;
requires io.ballerina.parser;
requires io.ballerina.tools.api;
requires com.google.gson;
requires org.slf4j;
}
Loading
Loading