Skip to content

Commit a1a7d36

Browse files
committed
[ ci ] Unify the CI workflow for testing on all platforms
1 parent bb5d5e5 commit a1a7d36

File tree

2 files changed

+68
-41
lines changed

2 files changed

+68
-41
lines changed

.github/workflows/test-unix.yaml renamed to .github/workflows/test.yaml

Lines changed: 50 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# modified from https://github.com/simonmichael/hledger/blob/master/.github/workflows/linux.yml
22

3-
name: CI (Unix)
3+
name: CI
44

55
defaults:
66
run:
@@ -19,7 +19,7 @@ jobs:
1919
runs-on: ${{ matrix.os }}
2020
strategy:
2121
matrix:
22-
os: [ubuntu-latest, macos-latest]
22+
os: [ubuntu-latest, macos-latest, windows-latest]
2323
fail-fast: false
2424
steps:
2525

@@ -78,13 +78,10 @@ jobs:
7878
run: |
7979
echo PKG_CONFIG_PATH="$(brew --prefix)/opt/icu4c/lib/pkgconfig" >> "${GITHUB_ENV}"
8080
81-
# - name: ⏬ Setup Haskell
82-
# uses: haskell-actions/setup@v2
83-
# id: setup-haskell
84-
# with:
85-
# ghc-version: ${{ env.GHC_VERSION }}
86-
# enable-stack: true
87-
# stack-version: 'latest'
81+
- name: Install the icu library (on Windows)
82+
if: runner.os == 'Windows'
83+
run: |
84+
stack exec -- pacman -S --noconfirm mingw-w64-x86_64-icu mingw-w64-x86_64-pkgconf
8885
8986
- name: 📸 Build Snapshot
9087
run: stack build --no-terminal --only-snapshot -j1
@@ -95,13 +92,6 @@ jobs:
9592
- name: 🧰 Build ALS
9693
run: stack build
9794

98-
99-
# - name: 🔨 Build
100-
# run: stack build
101-
102-
# - name: 🧪 Run tests
103-
# run: stack test
104-
10595
# things to be cached
10696

10797
- name: 💾 Cache stack global package db
@@ -119,7 +109,7 @@ jobs:
119109
key: ${{ steps.stack-work.outputs.cache-primary-key }}
120110

121111

122-
- name: 🔗 Bundle ICU4C DLLs (on macOS)
112+
- name: 📦 Bundle executable, DLLs and data files (on macOS)
123113
if: runner.os == 'macOS'
124114
run: | # Bundle icu4c DLLs
125115
@@ -209,8 +199,8 @@ jobs:
209199
echo " old path : $icudata_path"
210200
echo " new path : $icudata_path_new"
211201
212-
213-
- name: 📦 Compress files
202+
- name: 📦 Bundle executable, DLLs and data files (on Linux and macOS)
203+
if: runner.os != 'Windows'
214204
id: zip
215205
run: |
216206
# locate the data-dir
@@ -243,18 +233,53 @@ jobs:
243233
mv zip/als-macos.zip .
244234
fi
245235
236+
- name: 📦 Bundle executable, DLLs and data files (on Windows)
237+
if: runner.os == 'Windows'
238+
shell: pwsh
239+
run: |
240+
# locate the data-dir
241+
$snapshot = (stack path --snapshot-install-root)
242+
$datadir = (ls $snapshot\share *Agda-* -Recurse -Directory).FullName
243+
244+
# locate the executable
245+
$local = (stack path --local-install-root)
246+
$executable = (ls $local\bin *als.exe* -Recurse -File).FullName
247+
248+
# make a temporary directory for compresssing
249+
mkdir zip
250+
cp -r $datadir zip/data
251+
cp $executable zip/
252+
253+
# include text-icu DLLs
254+
$mingw64bin = (stack path --extra-library-dirs).split(", ") -match "\\bin"
255+
ls $mingw64bin
256+
cp (ls $mingw64bin *libicudt*) zip/
257+
cp (ls $mingw64bin *libicuin*) zip/
258+
cp (ls $mingw64bin *libicuuc*) zip/
259+
ls zip
260+
261+
# compress
262+
cd zip
263+
Compress-Archive * als-windows.zip
264+
cd ..
265+
mv zip/als-windows.zip .
266+
267+
246268
- name: 🧪 Run tests
247269
run: stack test --ta --als-path=zip/als
248270

249-
# - name: 🔨 Build and run tests
250-
# run: |
251-
252-
# stack test --ta --als-path=zip/als
253-
254271
# release (optional)
255272
- name: 🚢 Release Artifacts
256273
if: startsWith(github.ref, 'refs/tags/v') # so that only commits with a git tag would upload artifacts
257274
env:
258275
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
259276
run: |
260-
gh release upload ${{ github.ref_name }} als-ubuntu.zip --clobber
277+
if [[ ${{ runner.os }} == "Linux" ]]; then
278+
gh release upload ${{ github.ref_name }} als-ubuntu.zip --clobber
279+
fi
280+
if [[ ${{ runner.os }} == "macOS" ]]; then
281+
gh release upload ${{ github.ref_name }} als-macos.zip --clobber
282+
fi
283+
if [[ ${{ runner.os }} == "Windows" ]]; then
284+
gh release upload ${{ github.ref_name }} als-windows.zip --clobber
285+
fi

test/Test/LSP.hs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,42 @@
11
{-# LANGUAGE OverloadedStrings #-}
2+
23
module Test.LSP (tests) where
34

4-
import Control.Applicative.Combinators
5+
import Agda
56
import Control.Monad.IO.Class
7+
import qualified Data.Aeson as JSON
68
import Language.LSP.Protocol.Message
7-
import Language.LSP.Protocol.Types
89
import Language.LSP.Test
10+
import Switchboard (agdaCustomMethod)
911
import Test.Tasty
1012
import Test.Tasty.HUnit
11-
import qualified Data.Aeson as JSON
12-
import Switchboard ( agdaCustomMethod )
13-
import Agda
1413

1514
tests :: FilePath -> TestTree
16-
tests alsPath =
15+
tests alsPath =
1716
testGroup
1817
"LSP"
1918
[ testCase "load" (demo alsPath)
2019
]
2120

2221
demo :: FilePath -> IO ()
23-
demo alsPath =
22+
demo alsPath = do
23+
putStrLn $ "Running LSP tests on the server with the following path to the als executable: " ++ alsPath
2424
runSession alsPath fullLatestClientCaps "test/data/" $ do
25-
doc <- openDoc "A.agda" "agda"
25+
doc <- openDoc "A.agda" "agda"
2626

27-
-- Use your favourite favourite combinators.
28-
-- skipManyTill loggingNotification (count 1 publishDiagnosticsNotification)
27+
-- Use your favourite favourite combinators.
28+
-- skipManyTill loggingNotification (count 1 publishDiagnosticsNotification)
2929

30-
testCustomMethod "IOTCM \"test/data/A.agdaa\" NonInteractive Direct( Cmd_load \"test/data/A.agda\" [] )"
30+
testCustomMethod "IOTCM \"test/data/A.agdaa\" NonInteractive Direct( Cmd_load \"test/data/A.agda\" [] )"
3131

32-
-- Or use one of the helper functions
33-
-- getDocumentSymbols doc >>= liftIO . print
32+
-- Or use one of the helper functions
33+
-- getDocumentSymbols doc >>= liftIO . print
3434

3535
-- | Sends a custom method request to the server and expects a response of `CmdRes Nothing`
3636
testCustomMethod :: String -> Session ()
37-
testCustomMethod cmd = do
38-
TResponseMessage _ _ rsp <- request agdaCustomMethod $
39-
JSON.toJSON $ CmdReq cmd
37+
testCustomMethod cmd = do
38+
TResponseMessage _ _ rsp <-
39+
request agdaCustomMethod $
40+
JSON.toJSON $
41+
CmdReq cmd
4042
liftIO $ rsp @?= Right (JSON.toJSON (CmdRes Nothing))

0 commit comments

Comments
 (0)