-
Notifications
You must be signed in to change notification settings - Fork 14
198 lines (196 loc) · 8.11 KB
/
ci.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
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
name: Main
on:
pull_request:
branches: [main]
push:
branches: [main]
release:
types: [published]
schedule:
- cron: '30 20 * * *' # Warning: Timezone dep - 20:00 is 1:00
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
build:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- name: ubu22-gcc12-clang16
os: ubuntu-22.04
compiler: gcc-12
clang-runtime: '16'
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Save PR Info
run: |
mkdir -p ./pr
echo ${{ github.event.number }} > ./pr/NR
echo ${{ github.repository }} > ./pr/REPO
- uses: nelonoel/[email protected]
- name: Setup compiler on Linux
if: runner.os == 'Linux'
run: |
# https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html
vers="${compiler#*-}"
os_codename="`cat /etc/os-release | grep UBUNTU_CODENAME | cut -d = -f 2`"
sudo apt update
if [[ "${{ matrix.compiler }}" == *"gcc"* ]]; then
sudo apt install -y gcc-${vers} g++-${vers}
echo "CC=gcc-${vers}" >> $GITHUB_ENV
echo "CXX=g++-${vers}" >> $GITHUB_ENV
else
if ! sudo apt install -y clang-${vers}; then
curl https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
echo "deb https://apt.llvm.org/${os_codename}/ llvm-toolchain-${os_codename}-${vers} main" | sudo tee -a /etc/apt/sources.list
sudo apt update
sudo apt install -y clang-${vers}
fi
echo "CC=clang-${vers}" >> $GITHUB_ENV
echo "CXX=clang++-${vers}" >> $GITHUB_ENV
fi
env:
compiler: ${{ matrix.compiler }}
- name: Restore Cache LLVM/Clang runtime build directory
uses: actions/cache/restore@v3
id: cache
with:
path: clang-dev
key: ${{ runner.os }}-${{ matrix.os }}-${{ matrix.compiler }}-clang${{ matrix.clang-runtime }}.x-patch-${{ hashFiles(format('patches/llvm/clang{0}-*.patch', matrix.clang-runtime)) || 'none' }}
- name: Build runtime LLVM/Clang on Linux if the cache is invalid
if: ${{ runner.os == 'Linux' && steps.cache.outputs.cache-hit != 'true' }}
run: |
# Warning: If this part of the clang build script is changed to give a different
# result, then clear cache 'cache' by hand:
# https://github.com/compiler-research/xeus-clang-repl/actions/caches
UNIX_DISTRO=$(lsb_release -rs)
# Fetch clang-dev
git clone --depth=1 --branch "release/${{ matrix.clang-runtime }}.x" --single-branch https://github.com/llvm/llvm-project.git clang-dev
cd clang-dev
# Apply patches
echo "Apply clang${{ matrix.clang-runtime }}-*.patch patches:"
compgen -G "../patches/llvm/clang${{ matrix.clang-runtime }}-*.patch" > /dev/null && find ../patches/llvm/clang${{ matrix.clang-runtime }}-*.patch -printf "%f\n" && git apply ../patches/llvm/clang${{ matrix.clang-runtime }}-*.patch
# Build clang-dev
mkdir build
mkdir inst
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD="host;NVPTX" -DLLVM_OPTIMIZED_TABLEGEN=On -DLLVM_ENABLE_PROJECTS="clang" -DLLVM_ENABLE_RUNTIMES="openmp" -DCMAKE_INSTALL_PREFIX=../inst ../llvm
make ClangDriverOptions clang-repl openmp openmp-resource-headers -j$(nproc --all)
make install -j$(nproc --all)
make clean -j$(nproc --all)
cd ..
rm -rf $(find . -maxdepth 1 ! -name "inst" ! -name ".")
cd ..
- name: Save Cache LLVM/Clang runtime build directory
uses: actions/cache/save@v3
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
with:
path: clang-dev
key: ${{ steps.cache.outputs.cache-primary-key }}
- name: Set PATH_TO_LLVM_BUILD etc to Env
run: |
export PATH_TO_LLVM_BUILD="$(realpath clang-dev/inst)"
export PATH=$PATH_TO_LLVM_BUILD/bin:$PATH
export LD_LIBRARY_PATH=$PATH_TO_LLVM_BUILD/lib:$LD_LIBRARY_PATH
echo "PATH_TO_LLVM_BUILD=$PATH_TO_LLVM_BUILD" >> $GITHUB_ENV
echo "PATH=$PATH" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" >> $GITHUB_ENV
- name: Create clang-dev.tar.bz2 for artifact/release asset
run: |
#TODO: Clean unneeded folders...
# Tar prebuild clang-dev for dev binder containers
tar -cjf clang-dev.tar.bz2 ./clang-dev
- name: Add assets to Release
id: add_release_assets
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/v')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
token: ${{ secrets.GITHUB_TOKEN }}
files: |
clang-dev.tar.bz2
- name: Archive clang-dev artifact
uses: actions/upload-artifact@v3
with:
name: clang-dev
path: clang-dev.tar.bz2
retention-days: ${{ github.event_name=='schedule' && 2 || 7 }}
- name: Install xeus-clang-repl deps on Linux
if: runner.os == 'Linux' #TODO: exclude on release
run: |
# Install xeus-clang-repl deps
sudo apt-get update --yes
sudo apt-get install --yes --no-install-recommends ncurses-dev libtinfo-dev libtinfo5
#
conda update --all
conda install -y -q -c conda-forge \
'xeus>=2.0,<3.0' \
'nlohmann_json>=3.9.1,<3.10' \
'cppzmq>=4.6.0,<5' \
'xtl>=0.7,<0.8' \
pugixml \
'cxxopts>=2.2.1,<2.3' \
libuuid \
pytest \
jupyter_kernel_test
- name: Build and Install CppInterOp on Linux
if: runner.os == 'Linux'
run: |
# Build CppInterOp next to cling and llvm-project.
LLVM_DIR="$(realpath clang-dev)"
LLVM_BUILD_DIR="$(realpath clang-dev/inst)"
#CPLUS_INCLUDE_PATH="${LLVM_DIR}/llvm/include:${LLVM_DIR}/clang/include:${LLVM_BUILD_DIR}/include:${LLVM_BUILD_DIR}/tools/clang/include"
CPLUS_INCLUDE_PATH="${LLVM_BUILD_DIR}/include/llvm:${LLVM_BUILD_DIR}/include/clang"
git clone https://github.com/compiler-research/CppInterOp.git
export CPPINTEROP_DIR=$PWD/cppyy-backend/python/cppyy_backend/
cd CppInterOp
mkdir build
cd build
export CPPINTEROP_BUILD_DIR=$PWD
cmake -DCMAKE_BUILD_TYPE=Release \
-DUSE_CLING=OFF \
-DUSE_REPL=ON \
-DLLVM_DIR=$LLVM_BUILD_DIR \
-DLLVM_USE_LINKER=gold \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_INSTALL_PREFIX=$CPPINTEROP_DIR \
../
cmake --build . --parallel $(nproc --all)
cd ../..
# We need CPPINTEROP_DIR, LLVM_BUILD_DIR and CPLUS_INCLUDE_PATH later
echo "CPPINTEROP_DIR=$CPPINTEROP_DIR" >> $GITHUB_ENV
echo "CPPINTEROP_BUILD_DIR=$CPPINTEROP_BUILD_DIR" >> $GITHUB_ENV
echo "LLVM_BUILD_DIR=$LLVM_BUILD_DIR" >> $GITHUB_ENV
echo "CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH" >> $GITHUB_ENV
- name: Build xeus-clang-repl on Linux
if: runner.os == 'Linux' #TODO: exclude on release
run: |
## Build and Install xeus-clang-repl
mkdir build
cd build
PP=$KERNEL_PYTHON_PREFIX
if [[ -z "$PP" ]]; then
PP=$(conda info --base)
fi
cmake -DCMAKE_PREFIX_PATH=$PP -DCMAKE_INSTALL_PREFIX=$PP \
-DCMAKE_INSTALL_LIBDIR=lib -DLLVM_DIR=$PATH_TO_LLVM_BUILD \
-DLLVM_CONFIG_EXTRA_PATH_HINTS=$PATH_TO_LLVM_BUILD \
-DCPPINTEROP_DIR=$CPPINTEROP_BUILD_DIR \
-DLLVM_USE_LINKER=gold \
-DLLVM_REQUIRED_VERSION=${{ matrix.clang-runtime }} ..
make install
- name: Setup tmate session
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
# When debugging increase to a suitable value!
timeout-minutes: ${{ github.event.pull_request && 1 || 20 }}