-
Notifications
You must be signed in to change notification settings - Fork 1
160 lines (137 loc) · 5.29 KB
/
ci.yaml
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
name: CI
on:
push:
branches: [main, testing]
pull_request:
branches: [main]
env:
LD_LIBRARY_PATH: "/usr/local/lib:$LD_LIBRARY_PATH"
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
ghc: ['9.2.8']
cabal: ['3.8']
grpc: ['v1.54.2']
os: [ubuntu-latest] # TODO: macOS-latest
name: ghc-${{ matrix.ghc }} cabal-${{ matrix.cabal }} grpc-${{ matrix.grpc }} on ${{ matrix.os }}
env:
GRPC_RELEASE_DIR: /opt/grpc-${{ matrix.grpc }}
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Haskell caches
uses: actions/cache@v3
with:
path: |
~/.cabal/packages
~/.cabal/store
dist-newstyle
key: ${{ runner.os }}-${{ matrix.ghc }}-${{ matrix.cabal }}-v1-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/cabal.project') }}
restore-keys: |
${{ runner.os }}-${{ matrix.ghc }}-${{ matrix.cabal }}-v1-
- name: Grpc caches
uses: actions/cache@v3
with:
path: |
/opt/grpc-${{ matrix.grpc }}
key: ${{ runner.os }}-grpc-${{ matrix.grpc }}
restore-keys: |
${{ runner.os }}-grpc
- name: Check grpc caches
run: |
if [ -e "$GRPC_RELEASE_DIR/lib/libgrpc++.so" ]; then
echo '::set-output name=INSTALLED::yes'
else
# empty release dir
mkdir -p $GRPC_RELEASE_DIR && rm -rf $GRPC_RELEASE_DIR/*
SRC_DIR=$(mktemp -d)
cd $SRC_DIR && \
git init && git remote add origin https://github.com/grpc/grpc.git && \
git fetch --depth 1 origin ${{ matrix.grpc }} && \
git checkout FETCH_HEAD && \
git submodule update --init --recursive --depth 1
echo "::set-output name=INSTALLED::no"
echo "::set-output name=SRC_DIR::${SRC_DIR}"
fi
id: check-grpc-installed
- name: Install build deps on linux
if: runner.os == 'Linux'
run: |
sudo apt-get update
DEBIAN_FRONTEND="noninteractive" sudo apt-get install -y \
gcc-10 g++-10
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 20
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 20
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 20
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++-10 20
- name: (TODO) Install build deps on osx
if: runner.os == 'macOS'
run: echo "TODO"
- name: Build grpc on linux
if: runner.os == 'Linux'
run: |
if [ "${{ steps.check-grpc-installed.outputs.INSTALLED }}" == "yes" ]; then
echo "Use cached grpc: $GRPC_RELEASE_DIR"
else
sudo apt-get update
DEBIAN_FRONTEND="noninteractive" sudo apt-get install -y \
build-essential autoconf libtool libssl-dev pkg-config cmake
cd ${{ steps.check-grpc-installed.outputs.SRC_DIR }} && \
cmake -DCMAKE_INSTALL_PREFIX=$GRPC_RELEASE_DIR \
-DgRPC_BUILD_TESTS=OFF \
-DBUILD_SHARED_LIBS=ON \
-DgRPC_INSTALL=ON \
-DCMAKE_BUILD_TYPE=Release \
-DgRPC_SSL_PROVIDER=package \
. && \
make -j $(nproc) && \
sudo make install -j $(nproc)
fi
- name: (TODO) Build grpc on osx
if: runner.os == 'macOS'
run: |
brew install autoconf libtool [email protected] pkg-config cmake shtool
- name: Setup grpc
run: |
sudo mkdir -p /usr/local/{bin,lib,include}
sudo ln -s $(realpath $GRPC_RELEASE_DIR/bin)/* /usr/local/bin/
sudo ln -s $(realpath $GRPC_RELEASE_DIR/lib)/* /usr/local/lib/
sudo ln -s $(realpath $GRPC_RELEASE_DIR/include)/* /usr/local/include/
- name: Setup Haskell
uses: haskell/actions/setup@v2
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: ${{ matrix.cabal }}
- name: Update system PATH
run: |
echo "$HOME/.cabal/bin" >> $GITHUB_PATH
- name: generate example grpc c++ files
run: make -f example/Makefile
- name: sdist
run: |
mkdir -p $HOME/sdist
cabal sdist all --output-dir $HOME/sdist
- name: unpack
run: |
rm -rf $GITHUB_WORKSPACE/*
find $HOME/sdist -maxdepth 1 -type f -name '*.tar.gz' -exec tar -C $GITHUB_WORKSPACE -xzvf {} \;
cd $GITHUB_WORKSPACE && \
echo "packages:" > cabal.project && \
find . -maxdepth 4 -type f -name "*.cabal" -exec echo " {}" \; >> cabal.project
- name: build
run: |
cabal install proto-lens-protoc # hs-grpc-example requires this
cabal build all --upgrade-dependencies --enable-tests --enable-benchmarks
- name: test
run: cabal test all --test-show-details=always
# Unfortunately, there is no `cabal check all`
- name: check
run: |
for f in $(cat cabal.project |grep "\.cabal$"); do
bash -c "cd $(dirname $f) && cabal check"
done
- name: haddock
run: cabal haddock all