forked from commercialhaskell/stack
-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (104 loc) · 3.21 KB
/
unit-tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
name: Unit tests
on:
pull_request:
push:
branches:
- master
- stable
- rc/**
workflow_dispatch:
# As of 6 May 2024, ubuntu-latest and windows-latest come with Stack 2.15.5 and
# GHC 9.8.2. However, macos-latest does not come with Haskell tools.
jobs:
pedantic:
name: Pedantic
runs-on: ubuntu-latest
steps:
- name: Clone project
uses: actions/checkout@v4
- name: Cache dependencies
uses: actions/cache@v4
with:
path: ~/.stack
key: ${{ runner.os }}-${{ hashFiles('stack.yaml') }}
restore-keys: |
${{ runner.os }}-
- name: Pedantic build
run: |
stack build --pedantic
- name: disable-git-info build
run: |
stack build --pedantic --flag stack:disable-git-info
unit-tests:
name: Unit tests
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
extra-suffix: ""
stack-args: ""
- os: ubuntu-latest
extra-suffix: "alpine"
stack-args: "--docker --system-ghc --no-install-ghc --flag stack:static"
- os: windows-latest
extra-suffix: ""
stack-args: ""
- os: macos-latest
extra-suffix: ""
stack-args: ""
steps:
- name: Clone project
uses: actions/checkout@v4
- name: Cache dependencies on Unix-like OS
if: startsWith(runner.os, 'Linux') || startsWith(runner.os, 'macOS')
uses: actions/cache@v4
with:
path: ~/.stack
key: ${{ runner.os }}-${{ hashFiles('stack.yaml') }}-${{ matrix.extra-suffix }}
- name: Cache dependencies on Windows
if: startsWith(runner.os, 'Windows')
uses: actions/cache@v4
with:
path: |
~\AppData\Roaming\stack
~\AppData\Local\Programs\stack
key: ${{ runner.os }}-${{ hashFiles('stack.yaml') }}-${{ matrix.extra-suffix }}
- name: Run tests
shell: bash
run: |
set -ex
if [[ "${{ matrix.os }}" == "macos-latest" ]]
then
# macos-latest does not include Haskell tools as at 2024-05-06.
curl -sSL https://get.haskellstack.org/ | sh
fi
if [[ "${{ matrix.extra-suffix }}" == "alpine" ]]
then
mkdir -p ~/.stack
touch ~/.stack/config.yaml
cat > ~/.stack/config.yaml <<EOF
extra-include-dirs:
- /usr/include
extra-lib-dirs:
- /lib
- /usr/lib
EOF
fi
stack test ${{ matrix.stack-args }} --haddock --no-haddock-deps --ghc-options="-Werror -O0" --copy-bins --local-bin-path bin
# Get output about whether the exe is dynamically linked
if [[ "${{ matrix.os }}" == "macos-latest" ]]
then
echo "Skipping ldd check on Mac"
elif [[ "${{ matrix.os }}" == "windows-latest" ]]
then
echo "Skipping ldd check on Windows"
elif [[ "${{ matrix.extra-suffix }}" == "alpine" ]]
then
# ldd returns exit code 1 if it's static, so failure is success
(ldd ./bin/stack && exit 1) || true
else
ldd ./bin/stack
fi
./bin/stack --version