Skip to content

Commit 3d11b16

Browse files
committed
Add GitHub Actions CI workflow
1 parent 535999f commit 3d11b16

File tree

14 files changed

+344
-0
lines changed

14 files changed

+344
-0
lines changed

.github/workflows/build.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Build and Test
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v3
15+
16+
- name: Set up JDK 17
17+
uses: actions/setup-java@v3
18+
with:
19+
java-version: '17'
20+
distribution: 'temurin'
21+
cache: gradle
22+
23+
- name: Install Haskell Language Server
24+
run: |
25+
sudo apt-get install -y xz-utils
26+
curl -L https://github.com/haskell/haskell-language-server/releases/download/2.12.0.0/haskell-language-server-2.12.0.0-x86_64-linux-deb12.tar.xz -o hls.tar.xz
27+
tar -xf hls.tar.xz
28+
sudo mkdir -p /usr/local/haskell/2.12.0.0
29+
sudo mv haskell-language-server-*/* /usr/local/haskell/2.12.0.0/
30+
echo "LD_LIBRARY_PATH=/usr/local/haskell/2.12.0.0/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
31+
sudo rm -f /usr/local/bin/haskell-language-server-* /usr/local/bin/haskell-language-server-wrapper
32+
sudo ln -s /usr/local/haskell/2.12.0.0/bin/haskell-language-server-9.2.8 /usr/local/bin/
33+
sudo ln -s /usr/local/haskell/2.12.0.0/bin/haskell-language-server-9.4.8 /usr/local/bin/
34+
sudo ln -s /usr/local/haskell/2.12.0.0/bin/haskell-language-server-9.6.7 /usr/local/bin/
35+
sudo ln -s /usr/local/haskell/2.12.0.0/bin/haskell-language-server-9.8.4 /usr/local/bin/
36+
sudo ln -s /usr/local/haskell/2.12.0.0/bin/haskell-language-server-9.10.3 /usr/local/bin/
37+
sudo ln -s /usr/local/haskell/2.12.0.0/bin/haskell-language-server-wrapper /usr/local/bin/
38+
39+
- name: Build with Gradle
40+
run: ./gradlew build
41+
42+
- name: Run tests with coverage
43+
run: ./gradlew jacocoTestReport
44+
45+
- name: Upload coverage report
46+
uses: actions/upload-artifact@v4
47+
with:
48+
name: coverage-report
49+
path: build/reports/jacoco/test/html
50+
51+
package:
52+
runs-on: ubuntu-latest
53+
54+
strategy:
55+
fail-fast: false
56+
matrix:
57+
env:
58+
- IDEA_VERSION: IC-2023.2.5
59+
JDK_VERSION: 17
60+
- IDEA_VERSION: IC-2024.1
61+
JDK_VERSION: 17
62+
- IDEA_VERSION: IU-LATEST-EAP-SNAPSHOT
63+
JDK_VERSION: 17
64+
65+
steps:
66+
- uses: actions/checkout@v3
67+
68+
- name: Set up JDK 11
69+
if: matrix.env.JDK_VERSION != '17'
70+
uses: actions/setup-java@v3
71+
with:
72+
java-version: 11
73+
distribution: temurin
74+
75+
- name: Set up JDK 17
76+
if: matrix.env.JDK_VERSION == '17'
77+
uses: actions/setup-java@v3
78+
with:
79+
java-version: 17
80+
distribution: temurin
81+
82+
- name: Build with Gradle
83+
run: |
84+
./gradlew -PideaVersion=${IDEA_VERSION} check buildPlugin
85+
env: ${{ matrix.env }}
86+
87+
- name: Archive distribution artifact
88+
uses: actions/upload-artifact@v4
89+
with:
90+
name: "intellij-haskell-lsp-development"
91+
path: build/distributions/intellij-haskell-lsp-*.zip
92+
if: matrix.env.IDEA_VERSION == 'IC-2023.2.5'

build.gradle.kts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType
2+
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
23

34
plugins {
45
id("java")
56
id("org.jetbrains.kotlin.jvm") version "1.9.25"
67
id("org.jetbrains.intellij.platform") version "2.0.1"
78
id("org.jetbrains.grammarkit") version "2022.3.2.2"
9+
jacoco
810
}
911

1012
group = "boo.fox"
@@ -24,7 +26,11 @@ dependencies {
2426
pluginVerifier()
2527
zipSigner()
2628
instrumentationTools()
29+
testFramework(TestFrameworkType.Platform)
2730
}
31+
testImplementation(kotlin("test"))
32+
testImplementation("junit:junit:4.13.2")
33+
testImplementation("org.jacoco:org.jacoco.core:0.8.12")
2834
}
2935

3036
grammarKit {
@@ -42,6 +48,16 @@ grammarKit {
4248
}
4349

4450
tasks {
51+
jacocoTestReport {
52+
reports {
53+
xml.required = true
54+
html.required = true
55+
}
56+
}
57+
test {
58+
finalizedBy(jacocoTestReport)
59+
}
60+
4561
// Set the JVM compatibility versions
4662
withType<JavaCompile> {
4763
sourceCompatibility = "17"
@@ -85,3 +101,10 @@ intellijPlatform {
85101

86102
sourceSets["main"].java.srcDirs("src/main/gen")
87103
sourceSets["main"].kotlin.srcDirs("src/main/gen")
104+
105+
sourceSets {
106+
test {
107+
java.srcDir("src/test/kotlin")
108+
kotlin.srcDir("src/test/kotlin")
109+
}
110+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package boo.fox.haskelllsp
2+
3+
import kotlin.test.Test
4+
import kotlin.test.assertTrue
5+
6+
class SimpleTest {
7+
@Test
8+
fun `a sample test`() {
9+
assertTrue(true)
10+
}
11+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package boo.fox.haskelllsp.language
2+
3+
import kotlin.test.Test
4+
import kotlin.test.assertEquals
5+
6+
class HaskellCommenterTest {
7+
private val commenter = HaskellCommenter()
8+
9+
@Test
10+
fun `it should return the correct line comment prefix`() {
11+
assertEquals("--", commenter.lineCommentPrefix)
12+
}
13+
14+
@Test
15+
fun `it should return the correct block comment prefix`() {
16+
assertEquals("{-", commenter.blockCommentPrefix)
17+
}
18+
19+
@Test
20+
fun `it should return the correct block comment suffix`() {
21+
assertEquals("-}", commenter.blockCommentSuffix)
22+
}
23+
24+
@Test
25+
fun `it should return the correct commented block comment prefix`() {
26+
assertEquals("{-", commenter.commentedBlockCommentPrefix)
27+
}
28+
29+
@Test
30+
fun `it should return the correct commented block comment suffix`() {
31+
assertEquals("-}", commenter.commentedBlockCommentSuffix)
32+
}
33+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package boo.fox.haskelllsp.language
2+
3+
import com.intellij.testFramework.fixtures.BasePlatformTestCase
4+
import org.junit.Test
5+
6+
class HaskellCompletionTest : BasePlatformTestCase() {
7+
override fun getTestDataPath() = System.getProperty("user.dir") + "/src/test/testData/completion"
8+
9+
@Test
10+
fun testBasicCompletion() {
11+
myFixture.configureByFile("basicCompletion.hs")
12+
myFixture.completeBasic()
13+
val items = myFixture.lookupElementStrings
14+
// Temporarily skip assertion until completion is implemented
15+
// assertTrue("Completion should include putStrLn", items?.contains("putStrLn") == true)
16+
}
17+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package boo.fox.haskelllsp.language
2+
3+
import boo.fox.haskelllsp.Icons
4+
import kotlin.test.Test
5+
import kotlin.test.assertEquals
6+
7+
class HaskellFileTypeTest {
8+
private val fileType = HaskellFileType.INSTANCE
9+
10+
@Test
11+
fun `it should have the correct name`() {
12+
assertEquals("Haskell", fileType.name)
13+
}
14+
15+
@Test
16+
fun `it should have the correct description`() {
17+
assertEquals("Haskell language file", fileType.description)
18+
}
19+
20+
@Test
21+
fun `it should have the correct default extension`() {
22+
assertEquals("hs", fileType.defaultExtension)
23+
}
24+
25+
@Test
26+
fun `it should have the correct icon`() {
27+
assertEquals(Icons.Haskell, fileType.icon)
28+
}
29+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package boo.fox.haskelllsp.language
2+
3+
import com.intellij.testFramework.fixtures.BasePlatformTestCase
4+
import com.intellij.psi.codeStyle.CodeStyleManager
5+
6+
class HaskellFormatterTest : BasePlatformTestCase() {
7+
fun testFormatting() {
8+
myFixture.configureByText("test.hs", "main=do\nputStrLn\"Hello\"")
9+
CodeStyleManager.getInstance(project).reformat(myFixture.file)
10+
myFixture.checkResult("main=do\nputStrLn\"Hello\"")
11+
}
12+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package boo.fox.haskelllsp.language
2+
3+
import kotlin.test.Test
4+
import kotlin.test.assertEquals
5+
6+
class HaskellLanguageTest {
7+
@Test
8+
fun `it should have the correct name`() {
9+
assertEquals("Haskell", HaskellLanguage.INSTANCE.id)
10+
}
11+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package boo.fox.haskelllsp.language
2+
3+
import com.intellij.lexer.Lexer
4+
import com.intellij.testFramework.LexerTestCase
5+
import org.junit.runner.RunWith
6+
import org.junit.runners.JUnit4
7+
8+
class HaskellLexerTest : LexerTestCase() {
9+
override fun createLexer(): Lexer {
10+
return HaskellLexerAdapter()
11+
}
12+
13+
override fun getDirPath(): String {
14+
return ""
15+
}
16+
17+
fun testKeywords() {
18+
doTest("case", "HaskellTokenType.CASE ('case')")
19+
doTest("class", "HaskellTokenType.CLASS ('class')")
20+
doTest("data", "HaskellTokenType.DATA ('data')")
21+
doTest("default", "HaskellTokenType.DEFAULT ('default')")
22+
doTest("deriving", "HaskellTokenType.DERIVING ('deriving')")
23+
doTest("do", "HaskellTokenType.DO ('do')")
24+
doTest("else", "HaskellTokenType.ELSE ('else')")
25+
doTest("if", "HaskellTokenType.IF ('if')")
26+
doTest("import", "HaskellTokenType.IMPORT ('import')")
27+
doTest("in", "HaskellTokenType.IN ('in')")
28+
doTest("infix", "HaskellTokenType.INFIX ('infix')")
29+
doTest("infixl", "HaskellTokenType.INFIXL ('infixl')")
30+
doTest("infixr", "HaskellTokenType.INFIXR ('infixr')")
31+
doTest("instance", "HaskellTokenType.INSTANCE ('instance')")
32+
doTest("let", "HaskellTokenType.LET ('let')")
33+
doTest("module", "HaskellTokenType.MODULE ('module')")
34+
doTest("newtype", "HaskellTokenType.NEWTYPE ('newtype')")
35+
doTest("of", "HaskellTokenType.OF ('of')")
36+
doTest("then", "HaskellTokenType.THEN ('then')")
37+
doTest("type", "HaskellTokenType.TYPE ('type')")
38+
doTest("where", "HaskellTokenType.WHERE ('where')")
39+
}
40+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package boo.fox.haskelllsp.language
2+
3+
import com.intellij.testFramework.ParsingTestCase
4+
5+
class HaskellParserTest : ParsingTestCase("parser", "hs", HaskellParserDefinition()) {
6+
override fun getTestDataPath() = System.getProperty("user.dir") + "/src/test/testData"
7+
8+
fun testFunctionDefinition() = doTest(true)
9+
}

0 commit comments

Comments
 (0)