-
Notifications
You must be signed in to change notification settings - Fork 632
210 lines (174 loc) · 7.83 KB
/
build-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
199
200
201
202
203
204
205
206
207
208
209
210
name: run tests
on:
pull_request:
push:
schedule:
- cron: 0 2 * * * # run at 2 AM UTC
workflow_dispatch:
jobs:
build:
name: "Test Python ${{ matrix.python-version }} with MPI (${{ matrix.enable-mpi }})"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [3.7, '3.10']
enable-mpi: [false, true]
steps:
- name: Define common environment variables
run: |
echo "CPPFLAGS=-I${HOME}/local/include" >> $GITHUB_ENV
echo "LDFLAGS=-L${HOME}/local/lib" >> $GITHUB_ENV
echo "HDF5_BASE_CPPFLAGS=-I/usr/include/hdf5" >> $GITHUB_ENV
echo "HDF5_BASE_LDFLAGS=-L/usr/lib/x86_64-linux-gnu/hdf5" >> $GITHUB_ENV
echo "GEN_CTL_IO=${HOME}/local/bin/gen-ctl-io" >> $GITHUB_ENV
- run: |
echo "HDF5_SERIAL_CPPFLAGS=${HDF5_BASE_CPPFLAGS}/serial" >> $GITHUB_ENV
echo "HDF5_PARALLEL_CPPFLAGS=${HDF5_BASE_CPPFLAGS}/openmpi" >> $GITHUB_ENV
echo "HDF5_SERIAL_LDFLAGS=${HDF5_BASE_LDFLAGS}/serial" >> $GITHUB_ENV
echo "HDF5_PARALLEL_LDFLAGS=${HDF5_BASE_LDFLAGS}/openmpi" >> $GITHUB_ENV
- name: Install pre-compiled dependencies
run: |
sudo apt-get -y update
sudo apt-get -y install autoconf automake libfftw3-dev libgsl-dev liblapack-dev guile-3.0-dev libpng-dev libtool swig
- name: Checkout libctl repository
uses: actions/checkout@v4
with:
repository: NanoComp/libctl
path: libctl-src
- name: Build and install libctl
run: cd libctl-src && sh autogen.sh --prefix=${HOME}/local --enable-shared && make -j $(nproc) && make install
- name: Checkout harminv repository
uses: actions/checkout@v4
with:
repository: NanoComp/harminv
path: harminv-src
- name: Build and install harminv
run: cd harminv-src && sh autogen.sh --prefix=${HOME}/local --enable-shared && make -j $(nproc) && make install
- name: Checkout MPB repository
uses: actions/checkout@v4
with:
repository: NanoComp/mpb
path: mpb-src
- name: Build and install MPB
run: cd mpb-src && sh autogen.sh --prefix=${HOME}/local --enable-shared LIBS=-ldl --with-libctl=${HOME}/local/share/libctl --with-hermitian-eps && make -j $(nproc) && make install
- name: Checkout libGDSII repository
uses: actions/checkout@v4
with:
repository: HomerReid/libGDSII
path: libGDSII-src
- name: Build and install libGDSII
run: cd libGDSII-src && sh autogen.sh --prefix=${HOME}/local && make install
- name: Define environment variables for serial build
if: ${{ matrix.enable-mpi == false }}
run: |
echo "MKCHECKFLAGS=-j $(nproc)" >> $GITHUB_ENV
echo "CPPFLAGS=${HDF5_SERIAL_CPPFLAGS} ${CPPFLAGS}" >> $GITHUB_ENV
echo "LDFLAGS=${HDF5_SERIAL_LDFLAGS} ${LDFLAGS}" >> $GITHUB_ENV
echo "MPICONF=--without-mpi" >> $GITHUB_ENV
- name: Define environment variables for MPI build
if: matrix.enable-mpi
run: |
echo "MKCHECKFLAGS=" >> $GITHUB_ENV
echo "CPPFLAGS=${HDF5_PARALLEL_CPPFLAGS} ${CPPFLAGS}" >> $GITHUB_ENV
echo "LDFLAGS=${HDF5_PARALLEL_LDFLAGS} ${LDFLAGS}" >> $GITHUB_ENV
echo "CC=mpicc" >> $GITHUB_ENV
echo "CXX=mpic++" >> $GITHUB_ENV
echo "HDF5_MPI=ON" >> $GITHUB_ENV
echo "MPICONF=--with-mpi" >> $GITHUB_ENV
- name: Install serial dependencies
if: ${{ matrix.enable-mpi == false }}
run: sudo apt-get -y install libhdf5-serial-dev
- name: Install MPI dependencies
if: matrix.enable-mpi
run: sudo apt-get -y install libopenmpi-dev mpi-default-bin openmpi-bin libhdf5-openmpi-dev libaec-dev
- name: Checkout Meep repository
uses: actions/checkout@v4
- name: Set up Python (version ${{ matrix.python-version }})
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Get pip cache dir
id: pip-cache
run: |
python -m pip install --upgrade pip wheel
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: pip cache
uses: actions/cache@v3
id: cache
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-py${{ matrix.python-version }}-mpi-${{ matrix.enable-mpi }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: ${{ runner.os }}-py${{ matrix.python-version }}-mpi-${{ matrix.enable-mpi }}-pip-
- name: Install Python dependencies
run: pip install -r python/requirements.txt
- name: Install nlopt
run: pip install nlopt
- name: Install coverage
if: ${{ matrix.enable-mpi == false && matrix.python-version == 3.7 }}
run: pip install coverage
- name: Install mpi4py
if: ${{ matrix.enable-mpi && steps.cache.outputs.cache-hit != true }}
run: pip install mpi4py
- name: Run autoreconf
run: |
autoreconf --verbose --install --symlink --force
MEEP_VERSION=$(./configure -V | grep meep | awk '{print $3}')
echo "MEEP_VERSION=${MEEP_VERSION}" >> $GITHUB_ENV
- name: Run configure with OpenMP
if: ${{ !(matrix.enable-mpi == false && matrix.python-version == 3.7) && !(matrix.enable-mpi == true && matrix.python-version == 3.10) }}
run: |
mkdir -p build &&
pushd build &&
../configure --enable-maintainer-mode --prefix=${HOME}/local --with-libctl=${HOME}/local/share/libctl ${MPICONF} --with-openmp &&
popd
- name: Run configure with coverage
if: ${{ matrix.enable-mpi == false && matrix.python-version == 3.7 }}
run: ./configure --enable-maintainer-mode --with-coverage --prefix=${HOME}/local --with-libctl=${HOME}/local/share/libctl ${MPICONF}
- name: Run configure with single-precision floating point and swig threads
if: ${{ matrix.enable-mpi == true && matrix.python-version == 3.10 }}
run: |
mkdir -p build &&
pushd build &&
../configure --enable-maintainer-mode --prefix=${HOME}/local --with-libctl=${HOME}/local/share/libctl ${MPICONF} --enable-single --enable-swig-python-threads &&
popd
- name: Run make
if: ${{ matrix.enable-mpi == false && matrix.python-version == 3.7 }}
run: make ${MKCHECKFLAGS}
- name: Run make check
if: ${{ matrix.enable-mpi == false && matrix.python-version == 3.7 }}
run: |
pushd python/ &&
{ make ${MKCHECKFLAGS} check || cat test-suite.log; } &&
popd
- name: Run make distcheck
if: ${{ !(matrix.enable-mpi == false && matrix.python-version == 3.7) }}
run: |
pushd build &&
make ${MKCHECKFLAGS} distcheck DISTCHECK_CONFIGURE_FLAGS="--with-libctl=${HOME}/local/share/libctl ${MPICONF}" &&
popd
- name: Generate coverage report
if: ${{ matrix.enable-mpi == false && matrix.python-version == 3.7 }}
run: |
pushd python/ &&
coverage combine -a &&
coverage report -i &&
coverage xml -i &&
popd
- name: Upload coverage to Codecov
if: ${{ matrix.enable-mpi == false && matrix.python-version == 3.7 }}
uses: codecov/codecov-action@v3
with:
files: ${{ github.workspace }}/python/coverage.xml
- name: Archive C++ test logs
if: ${{ failure() && !(matrix.enable-mpi == false && matrix.python-version == 3.7) }}
uses: actions/upload-artifact@v3
with:
name: cpp-tests-mpi-${{ matrix.enable-mpi }}-log
path: ${{ github.workspace }}/build/meep-${{ env.MEEP_VERSION }}/_build/sub/tests/test-suite.log
- name: Archive Python test logs
if: ${{ failure() && !(matrix.enable-mpi == false && matrix.python-version == 3.7) }}
uses: actions/upload-artifact@v3
with:
name: py${{ matrix.python-version }}-tests-mpi-${{ matrix.enable-mpi }}-log
path: ${{ github.workspace }}/build/meep-${{ env.MEEP_VERSION }}/_build/sub/python/test-suite.log