-
Notifications
You must be signed in to change notification settings - Fork 82
183 lines (181 loc) · 6.25 KB
/
cmake_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
name: cmake ci linux macos windows
on: [push, pull_request]
jobs:
prepare:
runs-on: ubuntu-22.04
outputs:
matrix: ${{ steps.generate_matrix.outputs.matrix }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Generate matrix
id: generate_matrix
run: |
MATRIX=$(python3 ${{ github.workspace }}/.github/workflows/generate_cmake_matrix.py)
echo "matrix=$MATRIX" >> $GITHUB_OUTPUT
pip-requirements:
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
cache : 'pip'
python-version: '3.10'
- name: Generate requirements.txt
run: |
pip install --upgrade pip
pip install pip-tools
pip-compile --all-build-deps python/finufft/pyproject.toml -o requirements.txt
echo pytest >> requirements.txt
sed -i -E 's/(==|>=|<=|>|<|~=|!=).*//' requirements.txt
cat requirements.txt
- name: Upload requirements.txt
uses: actions/upload-artifact@v4
with:
name: requirements
path: requirements.txt
cache:
strategy:
matrix:
os:
- ubuntu-22.04
- windows-2022
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: create cache directory
run: |
mkdir -p cpm
- name: Check if cache exists
id: cache
uses: actions/cache@v4
with:
key: cpm-cache-00-${{ hashFiles('CMakeLists.txt', 'cmake/*') }}
enableCrossOsArchive: true
path: cpm
- name: Setup Cpp
if: steps.cache.outputs.cache-hit != 'true'
uses: aminya/setup-cpp@v1
with:
cmake : true
- name: Download dependencies in cache linux
if: steps.cache.outputs.cache-hit != 'true' && runner.os == 'Linux'
run: |
cmake -S . -B ./build
rm -rf build
cmake -S . -B ./build -DFINUFFT_USE_DUCC0=ON
env:
CPM_SOURCE_CACHE: cpm
- name: Download dependencies in cache windows
if: steps.cache.outputs.cache-hit != 'true' && runner.os != 'Linux'
run: |
cmake -S . -B build
rm build -r -force
cmake -S . -B build -DFINUFFT_USE_DUCC0=ON
env:
CPM_SOURCE_CACHE: cpm
- name: Cache dependencies
uses: actions/cache/save@v4
with:
key: cpm-cache-00-${{ hashFiles('CMakeLists.txt', 'cmake/*') }}
enableCrossOsArchive: true
path: cpm
cmake-ci:
runs-on: ${{ matrix.os }}
needs: [prepare, cache, pip-requirements]
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.prepare.outputs.matrix) }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Restore Cache
uses: actions/cache/restore@v4
with:
key: cpm-cache-00-${{ hashFiles('CMakeLists.txt', 'cmake/*') }}
enableCrossOsArchive: true
path: cpm
- name: Download requirements.txt
uses: actions/download-artifact@v4
with:
name: requirements
- name: Run sccache-cache only on non-release runs
if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
uses: mozilla-actions/[email protected]
- name: Set caching env vars only on non-release runs
if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
run: |
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
echo "SCCACHE_GHA_VERSION=0" >> $GITHUB_ENV
- name: Setup Cpp
uses: aminya/setup-cpp@v1
with:
compiler: ${{ matrix.toolchain }}
vcvarsall: ${{ contains(matrix.os, 'windows') }}
cmake: true
ninja: true
vcpkg: false
cppcheck: false
clangtidy: false
- name: Set min macOS version and install fftw
if: runner.os == 'macOS'
run: |
brew install fftw
- name: Install fftw
if: runner.os == 'linux'
run: |
sudo apt update
sudo apt install -y libfftw3-dev
- name: Configure Cmake
run: |
cmake -S . -B ./build -G Ninja -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache -DCMAKE_BUILD_TYPE:STRING=${{matrix.build_type}} -DFINUFFT_ARCH_FLAGS=${{ matrix.arch_flags }} -DFINUFFT_BUILD_TESTS=ON -DFINUFFT_STATIC_LINKING=${{matrix.finufft_static_linking}} -DFINUFFT_USE_DUCC0=${{ matrix.ducc_fft }}
env:
CPM_SOURCE_CACHE: cpm
- name: Build
run: |
cmake --build ./build --config ${{matrix.build_type}}
- name: Test
working-directory: ./build
run: |
ctest -C ${{matrix.build_type}} --output-on-failure
- name: Set up Python
if: matrix.finufft_static_linking == 'off'
uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: 'pip'
cache-dependency-path: requirements.txt
- name: Build Python wheels
if: matrix.finufft_static_linking == 'off'
env:
MACOSX_DEPLOYMENT_TARGET: 13
CPM_SOURCE_CACHE: cpm
shell: bash
run: |
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements.txt
python3 -m pip install \
--verbose \
-C cmake.define.CMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-C cmake.define.FINUFFT_ARCH_FLAGS=${{ matrix.arch_flags }} \
-C cmake.define.FINUFFT_USE_DUCC0=${{ matrix.ducc_fft }} \
-C cmake.define.CMAKE_CXX_COMPILER_LAUNCHER=sccache \
-C cmake.define.CMAKE_C_COMPILER_LAUNCHER=sccache \
-C cmake.define.CMAKE_GENERATOR=Ninja \
-C cmake.define.CMAKE_GENERATOR_PLATFORM= \
python/finufft
- name: Test Python package
if: matrix.finufft_static_linking == 'off'
run: |
python3 -m pytest python/finufft/test
cleanup:
runs-on: ubuntu-22.04
needs: cmake-ci
steps:
- name: Artifact cleanup
uses: geekyeggo/delete-artifact@v5
with:
name: requirements