Check for hie already existing
[lsp-test.git] / .github / workflows / haskell.yml
index e4cdf76e2a374e073f0bf41cd65a654514df1c8f..f7e11706f6197c33cdab48287a7cb7d2ce51c403 100644 (file)
@@ -1,32 +1,65 @@
 name: Haskell CI
 
-on: [push]
-
+on: [push, pull_request]
 jobs:
   build:
    
-    runs-on: ubuntu-latest
+    runs-on: ${{ matrix.os }}
+
+    env:
+      hieref: 8582a960dc1ca389734707f821b273b00bae54ab
+
+    strategy:
+      matrix:
+        ghc: ['8.6.5', '8.4.4']
+        os: [ubuntu-latest, macOS-latest]
+        exclude:
+          - os: macOS-latest
+            ghc: '8.4.4' # fails due to ghc panic
 
     steps:
     - uses: actions/checkout@v1
-    - uses: actions/setup-haskell@v1
+    - uses: bubba/setup-haskell@macos-ghcup
       with:
-        ghc-version: '8.6.5'
+        ghc-version: ${{ matrix.ghc }}
         cabal-version: '3.0'
     - run: cabal update
-    - name: Install HIE
+
+    - name: Clone HIE
+      uses: actions/checkout@v1
+      with:
+        repository: haskell/haskell-ide-engine
+        submodules: recursive
+        ref: ${{ env.hieref }}
+        path: haskell-ide-engine
+
+    - name: Cache Cabal
+      uses: actions/cache@v1.1.0
+      with:
+        path: ~/.cabal
+        key: ${{ runner.OS }}-${{ matrix.ghc }}-cabal-${{ env.hieref }}
+        restore-keys: |
+          ${{ runner.OS }}-${{ matrix.ghc }}-cabal
+
+    - name: Build HIE
       run: |
-        pushd $HOME
-        git clone https://github.com/haskell/haskell-ide-engine --recurse-submodules
-        cd haskell-ide-engine
+        if [ -e $HOME/.cabal/bin/hie ]; then
+            echo "hie is already built"
+            exit 0
+        fi
+        pushd ../haskell-ide-engine
         cabal install hie
         cabal install hoogle
-        export PATH=$PATH:$HOME/.cabal/bin
-        hoogle generate
         popd
+    - name: Generate hoogle database
+      run: hoogle generate
+    - name: Install JS Language Server
+      run: npm install javascript-typescript-langserver
     - name: Build
       run: cabal build
     - name: Test
       run: |
-        export PATH=$PATH:$HOME/.cabal/bin
+        echo $PATH
+        echo $(npm bin)
+        export PATH=$PATH:$(npm bin) 
         cabal test