-
Notifications
You must be signed in to change notification settings - Fork 0
175 lines (166 loc) · 6.35 KB
/
Copy pathci.yml
File metadata and controls
175 lines (166 loc) · 6.35 KB
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
name: CI
on:
push:
tags-ignore: ["v*"] # a release tag is covered by the Release workflow
pull_request:
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-test:
strategy:
fail-fast: false
matrix:
include:
- { os: ubuntu-latest, cc: gcc }
- { os: ubuntu-latest, cc: clang }
- { os: macos-latest, cc: clang }
- { os: windows-latest, cc: "" }
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Select compiler
if: matrix.cc != ''
run: echo "CC=${{ matrix.cc }}" >> "$GITHUB_ENV"
- name: Configure
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
- name: Build
run: cmake --build build --config Release
- name: Test
run: ctest --test-dir build -C Release --output-on-failure
- name: Run example (Unix)
if: runner.os != 'Windows'
run: ./build/vol_target_demo
- name: Run example (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: .\build\Release\vol_target_demo.exe
build-test-32bit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install 32-bit toolchain
run: sudo apt-get update && sudo apt-get install -y gcc-multilib
- name: Configure (-m32, size_t is 32 bits; SSE math, no x87 excess precision)
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-m32 -msse2 -mfpmath=sse" -DCMAKE_EXE_LINKER_FLAGS=-m32
- name: Build
run: cmake --build build
- name: Test
run: ctest --test-dir build --output-on-failure
- name: Run example
run: ./build/vol_target_demo
sanitize:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Configure (ASan + UBSan)
run: >
cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug
-DCMAKE_C_FLAGS="-fsanitize=address,undefined -fno-sanitize-recover=all"
-DCMAKE_EXE_LINKER_FLAGS="-fsanitize=address,undefined"
- name: Build
run: cmake --build build
- name: Test
run: ctest --test-dir build --output-on-failure
- name: Run example under sanitizers
run: ./build/vol_target_demo
install-consume:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build and install
run: |
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DMLRISK_BUILD_TESTS=OFF -DMLRISK_BUILD_EXAMPLES=OFF
cmake --build build
cmake --install build --prefix "$PWD/prefix"
- name: Consume via find_package
run: |
mkdir consumer && cd consumer
cat > main.c <<'C'
#include "mlrisk/mlrisk.h"
#include <stdio.h>
int main(void) {
double r[] = {0.01, -0.02, 0.015}, s[3];
mlr_status st = mlr_ewma_vol(r, 3, 0.94, s);
printf("mlrisk %s status %d sigma %.6f\n", MLRISK_VERSION, (int)st, s[2]);
return st == MLR_OK ? 0 : 1;
}
C
cat > CMakeLists.txt <<'CM'
cmake_minimum_required(VERSION 3.21)
project(consumer C)
find_package(mlrisk 3 REQUIRED)
add_executable(consumer main.c)
target_link_libraries(consumer PRIVATE mlrisk::mlrisk)
CM
cmake -S . -B build -DCMAKE_PREFIX_PATH="$GITHUB_WORKSPACE/prefix"
cmake --build build
./build/consumer
- name: Consume via pkg-config
run: |
export PKG_CONFIG_PATH="$PWD/prefix/lib/pkgconfig"
pkg-config --modversion mlrisk
read -ra FLAGS <<< "$(pkg-config --cflags --libs mlrisk)"
cc -std=c11 consumer/main.c "${FLAGS[@]}" -o consumer_pc
./consumer_pc
- name: Public headers compile as C++
run: |
echo '#include "mlrisk/mlrisk.h"' > headers.cpp
c++ -std=c++17 -Wall -Wextra -Werror -fsyntax-only -I prefix/include headers.cpp
reference:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v7
with:
python-version: "3.12"
cache: pip
cache-dependency-path: tests/reference/requirements.txt
- name: Install reference packages
run: pip install -r tests/reference/requirements.txt
- name: Build the example
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DMLRISK_BUILD_TESTS=OFF && cmake --build build
- name: Check the C library against independent references
run: MLRISK_DEMO=build/vol_target_demo python tests/reference/reference_check.py
- name: The GARCH fit reaches the optimum that brute force finds
run: |
python -m pip install .
python tests/reference/garch_multistart_check.py
python-package:
strategy:
fail-fast: false
matrix:
include:
- { os: ubuntu-latest, python: "3.9" }
- { os: ubuntu-latest, python: "3.13" }
- { os: macos-latest, python: "3.13" }
- { os: windows-latest, python: "3.13" }
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python }}
- name: Build and install the wheel
run: python -m pip install ".[test]"
- name: Test against the installed wheel
run: python -m pytest python/tests -q
- name: A source distribution carries the C it has to compile
if: matrix.os == 'ubuntu-latest'
run: |
python -m pip install build
python -m build --sdist --outdir dist .
cd "$(mktemp -d)"
python -m pip install --force-reinstall "$GITHUB_WORKSPACE"/dist/*.tar.gz
python -c "import walkforward; print(walkforward.__version__)"
- name: The worked example runs and reproduces its numbers
if: matrix.os == 'ubuntu-latest' && matrix.python == '3.13'
working-directory: examples
run: |
python -m pip install nbclient ipykernel matplotlib
jupyter execute spy_walk_forward.ipynb
- name: The package and the library it bundles agree on the version
run: python -c "import walkforward as wf; assert wf.__version__ == wf.c_version(), (wf.__version__, wf.c_version()); print(wf.__version__)"