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 1 commit
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
75 changes: 75 additions & 0 deletions .github/workflows/language_server_simulator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
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"]
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: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://chat.googleapis.com/v1/spaces/${{secrets.NOTIFICATIONS_CHAT_ID}}/messages?key=${{secrets.NOTIFICATIONS_CHAT_KEY}}&token=${{secrets.NOTIFICATIONS_CHAT_TOKEN}}' \
# --header 'Content-Type: application/json' \
# -d '{"text": "*language server simulator failure in ${{ matrix.branch }}* (skipped generators: ${{ matrix.skipGenerators }}) \nPlease \n visit <https://github.com/ballerina-platform/ballerina-lang/actions/runs/${{github.run_id}}|the LS simulator run> for more information"}'
76 changes: 76 additions & 0 deletions .github/workflows/language_server_simulator_fhir.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
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" ]
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://chat.googleapis.com/v1/spaces/${{secrets.NOTIFICATIONS_CHAT_ID}}/messages?key=${{secrets.NOTIFICATIONS_CHAT_KEY}}&token=${{secrets.NOTIFICATIONS_CHAT_TOKEN}}' \
# --header 'Content-Type: application/json' \
# -d '{"text": "*language server simulator failure in ${{ matrix.branch }}* (skipped generators: ${{ matrix.skipGenerators }}) \nPlease \n visit <https://github.com/ballerina-platform/ballerina-lang/actions/runs/${{github.run_id}}|the LS simulator run> for more information"}'

7 changes: 7 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,10 @@ c2cVersion=2.8.0-20230622-141400-8d9a68f
dataMapperVersion=2.2.0

installerVersion=69c0a0e-9c6a-4062-ae1e-2209c25e4f51

# Language Server Simulator
eclipseLsp4jVersion=0.15.0
eclipseLsp4jJsonrpcVersion=0.15.0
slf4jJdk14Version=1.7.26
gsonVersion=2.9.1
slf4jApiVersion=1.7.s26
139 changes: 139 additions & 0 deletions language-server-simulator/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
apply from: "$rootDir/gradle/javaProject.gradle"

configurations {
dependency {
transitive true
}
}

ext {
distributionDir = "distribution"
nbalSourceDir = "nBallerinaSrc"
fhirSourceDir = "fhirSrc"
}

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() {
def fileDir = "${buildDir}/${distributionDir}" +
"/ballerina-${version}-swan-lake/distributions/ballerina-version"
File filePath = new File("${fileDir}");
def balVersion = filePath.readLines().get(0)
def sourceDir = "${buildDir}/${distributionDir}" +
"/ballerina-${version}-swan-lake/distributions/${balVersion}/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 unpackBallerinaDistribution
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 unpackBallerinaDistribution
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()
}
}
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