| 1 | name: Sanitized CI |
| 2 | |
| 3 | ## Running these jobs is slow (over ~1 hour, sometimes even 2) |
| 4 | ## so we run them only when there is a chance that the generated |
| 5 | ## C code could have changed, or for some critical vlib modules, |
| 6 | ## like `builtin`, `os`, `sync`, where they have demonstrated |
| 7 | ## their usefulness by catching actual very hard to find bugs. |
| 8 | ## The cost of this selective running is delayed feedback when |
| 9 | ## there are bugs in other V modules. |
| 10 | ## The positive is *much faster CI runs* for most V contributors, |
| 11 | ## that make PRs that are not concerning V itself, or the critical |
| 12 | ## V modules. |
| 13 | |
| 14 | on: |
| 15 | workflow_dispatch: |
| 16 | push: |
| 17 | branches: |
| 18 | - master |
| 19 | paths: |
| 20 | - '!**' |
| 21 | - '!**.md' |
| 22 | - '!**.yml' |
| 23 | - 'vlib/builtin/**.v' |
| 24 | - 'vlib/strconv/**.v' |
| 25 | - 'vlib/strings/**.v' |
| 26 | - 'vlib/math/**.v' |
| 27 | - 'vlib/math/big/**.v' |
| 28 | - 'vlib/arrays/**.v' |
| 29 | - 'vlib/crypto/ecdsa/**.v' |
| 30 | - 'vlib/datatypes/**.v' |
| 31 | - 'vlib/os/**.v' |
| 32 | - 'vlib/sync/**.v' |
| 33 | - 'vlib/v/tests/**.v' |
| 34 | - 'vlib/v/ast/**.v' |
| 35 | - 'vlib/v/scanner/**.v' |
| 36 | - 'vlib/v/parser/**.v' |
| 37 | - 'vlib/v/checker/**.v' |
| 38 | - 'vlib/v/gen/c/**.v' |
| 39 | - 'vlib/v/builder/**.v' |
| 40 | - 'vlib/v/cflag/**.v' |
| 41 | - 'vlib/v/live/**.v' |
| 42 | - 'vlib/v/util/**.v' |
| 43 | - 'vlib/v/markused/**.v' |
| 44 | - 'vlib/v/preludes/**.v' |
| 45 | - 'vlib/v/embed_file/**.v' |
| 46 | - 'vlib/x/json2/**.v' |
| 47 | - '**/sanitized_ci.yml' |
| 48 | pull_request: |
| 49 | paths: |
| 50 | - '!**' |
| 51 | - 'vlib/builtin/**.v' |
| 52 | - 'vlib/strconv/**.v' |
| 53 | - 'vlib/strings/**.v' |
| 54 | - 'vlib/math/**.v' |
| 55 | - 'vlib/math/big/**.v' |
| 56 | - 'vlib/arrays/**.v' |
| 57 | - 'vlib/crypto/ecdsa/**.v' |
| 58 | - 'vlib/datatypes/**.v' |
| 59 | - 'vlib/os/**.v' |
| 60 | - 'vlib/sync/**.v' |
| 61 | - 'vlib/v/tests/**.v' |
| 62 | - 'vlib/v/ast/**.v' |
| 63 | - 'vlib/v/scanner/**.v' |
| 64 | - 'vlib/v/parser/**.v' |
| 65 | - 'vlib/v/checker/**.v' |
| 66 | - 'vlib/v/gen/c/**.v' |
| 67 | - 'vlib/v/builder/**.v' |
| 68 | - 'vlib/v/cflag/**.v' |
| 69 | - 'vlib/v/live/**.v' |
| 70 | - 'vlib/v/util/**.v' |
| 71 | - 'vlib/v/markused/**.v' |
| 72 | - 'vlib/v/preludes/**.v' |
| 73 | - 'vlib/v/embed_file/**.v' |
| 74 | - 'vlib/x/json2/**.v' |
| 75 | - '**/sanitized_ci.yml' |
| 76 | |
| 77 | concurrency: |
| 78 | group: sanitized-${{ github.workflow }}-${{ github.ref == 'refs/heads/master' && github.sha || github.ref }} |
| 79 | cancel-in-progress: true |
| 80 | |
| 81 | jobs: |
| 82 | sanitize-undefined-clang: |
| 83 | runs-on: ubuntu-22.04 |
| 84 | timeout-minutes: 120 |
| 85 | env: |
| 86 | VFLAGS: -cc clang -cflags -fno-omit-frame-pointer |
| 87 | VJOBS: 1 |
| 88 | UBSAN_OPTIONS: print_stacktrace=1:halt_on_error=1:print_suppressions=0:suppressions=/home/runner/work/v/v/.github/workflows/run_sanitizers_undefined.suppressions |
| 89 | VNATIVE_SKIP_LIBC_VV: 1 |
| 90 | VTEST_SHOW_LONGEST_BY_RUNTIME: 3 |
| 91 | VTEST_SHOW_LONGEST_BY_COMPTIME: 3 |
| 92 | VTEST_SHOW_LONGEST_BY_TOTALTIME: 3 |
| 93 | steps: |
| 94 | - uses: actions/checkout@v6 |
| 95 | - uses: ./.github/actions/cache-apt-packages-action |
| 96 | - name: Build V |
| 97 | run: make -j4 && ./v symlink |
| 98 | - name: V doctor |
| 99 | run: ./v doctor |
| 100 | - name: Ensure code is well formatted |
| 101 | run: ./v -silent test-cleancode |
| 102 | - name: Install dependencies |
| 103 | run: | |
| 104 | .github/workflows/disable_azure_mirror.sh |
| 105 | ./v retry -- sudo apt update |
| 106 | ./v retry -- sudo apt install --quiet -y postgresql libpq-dev libssl-dev sqlite3 libsqlite3-dev valgrind |
| 107 | ./v retry -- sudo apt install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev libxrandr-dev libasound2-dev libegl-dev |
| 108 | ./v retry -- sudo apt install clang |
| 109 | - name: Recompile V with -cstrict |
| 110 | run: ./v -cg -cstrict -o v cmd/v |
| 111 | - name: Self tests (-fsanitize=undefined) |
| 112 | run: | |
| 113 | ./v -cflags -fsanitize=undefined -o v2 cmd/v |
| 114 | ./v2 -cflags -fsanitize=undefined -silent test-self vlib |
| 115 | - name: Build examples (V compiled with -fsanitize=undefined) |
| 116 | run: ./v2 -silent build-examples |
| 117 | |
| 118 | sanitize-undefined-gcc: |
| 119 | runs-on: ubuntu-22.04 |
| 120 | timeout-minutes: 120 |
| 121 | env: |
| 122 | VFLAGS: -cc gcc -cflags -fno-omit-frame-pointer |
| 123 | VJOBS: 1 |
| 124 | UBSAN_OPTIONS: print_stacktrace=1:halt_on_error=1:print_suppressions=0:suppressions=/home/runner/work/v/v/.github/workflows/run_sanitizers_undefined.suppressions |
| 125 | VNATIVE_SKIP_LIBC_VV: 1 |
| 126 | VTEST_SHOW_LONGEST_BY_RUNTIME: 3 |
| 127 | VTEST_SHOW_LONGEST_BY_COMPTIME: 3 |
| 128 | VTEST_SHOW_LONGEST_BY_TOTALTIME: 3 |
| 129 | steps: |
| 130 | - uses: actions/checkout@v6 |
| 131 | - uses: ./.github/actions/cache-apt-packages-action |
| 132 | - name: Build V |
| 133 | run: make -j4 && ./v symlink |
| 134 | - name: V doctor |
| 135 | run: ./v doctor |
| 136 | - name: Ensure code is well formatted |
| 137 | run: ./v -silent test-cleancode |
| 138 | - name: Install dependencies |
| 139 | run: | |
| 140 | .github/workflows/disable_azure_mirror.sh |
| 141 | ./v retry -- sudo apt update |
| 142 | ./v retry -- sudo apt install --quiet -y postgresql libpq-dev libssl-dev sqlite3 libsqlite3-dev valgrind |
| 143 | ./v retry -- sudo apt install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev libxrandr-dev libasound2-dev libegl-dev |
| 144 | - name: Recompile V with -cstrict |
| 145 | run: ./v -cg -cstrict -o v cmd/v |
| 146 | - name: Self tests (-fsanitize=undefined) |
| 147 | run: | |
| 148 | ./v -cflags -fsanitize=undefined -o v2 cmd/v |
| 149 | ./v2 -cflags -fsanitize=undefined -silent test-self vlib |
| 150 | - name: Build examples (V compiled with -fsanitize=undefined) |
| 151 | run: ./v2 -silent build-examples |
| 152 | |
| 153 | sanitize-address-clang: |
| 154 | runs-on: ubuntu-22.04 |
| 155 | timeout-minutes: 300 |
| 156 | env: |
| 157 | VFLAGS: -cc clang -cflags -fno-omit-frame-pointer |
| 158 | VJOBS: 1 |
| 159 | ASAN_OPTIONS: detect_leaks=1 |
| 160 | LSAN_OPTIONS: max_leaks=1:print_suppressions=0:suppressions=/home/runner/work/v/v/.github/workflows/run_sanitizers_leak.suppressions |
| 161 | VNATIVE_SKIP_LIBC_VV: 1 |
| 162 | VTEST_SHOW_LONGEST_BY_RUNTIME: 3 |
| 163 | VTEST_SHOW_LONGEST_BY_COMPTIME: 3 |
| 164 | VTEST_SHOW_LONGEST_BY_TOTALTIME: 3 |
| 165 | steps: |
| 166 | - uses: actions/checkout@v6 |
| 167 | - uses: ./.github/actions/cache-apt-packages-action |
| 168 | - name: Build V |
| 169 | run: make -j4 && ./v symlink |
| 170 | - name: V doctor |
| 171 | run: ./v doctor |
| 172 | - name: Ensure code is well formatted |
| 173 | run: ./v -silent test-cleancode |
| 174 | - name: Install dependencies |
| 175 | run: | |
| 176 | .github/workflows/disable_azure_mirror.sh |
| 177 | ./v retry -- sudo apt update |
| 178 | ./v retry -- sudo apt install --quiet -y postgresql libpq-dev libssl-dev sqlite3 libsqlite3-dev valgrind |
| 179 | ./v retry -- sudo apt install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev libxrandr-dev libasound2-dev libegl-dev |
| 180 | ./v retry -- sudo apt install clang |
| 181 | - name: Recompile V with -cstrict |
| 182 | run: ./v -cg -cstrict -o v cmd/v |
| 183 | - name: Self tests (-fsanitize=address) |
| 184 | run: ./v -cflags -fsanitize=address,pointer-compare,pointer-subtract -silent test-self vlib |
| 185 | - name: Test vlib/v/tests/ (V compiled with -fsanitize=address) |
| 186 | run: | |
| 187 | ./v -cflags -fsanitize=address -o v cmd/v |
| 188 | ./v -cc tcc -silent test-self -asan-compiler vlib/v/tests/ |
| 189 | - name: Build examples (V compiled with -fsanitize=address) |
| 190 | run: ./v -silent build-examples |
| 191 | |
| 192 | sanitize-address-msvc: |
| 193 | runs-on: windows-2025 |
| 194 | timeout-minutes: 30 |
| 195 | env: |
| 196 | VFLAGS: -cc msvc |
| 197 | VJOBS: 1 |
| 198 | VNATIVE_SKIP_LIBC_VV: 1 |
| 199 | VTEST_SHOW_LONGEST_BY_RUNTIME: 3 |
| 200 | VTEST_SHOW_LONGEST_BY_COMPTIME: 3 |
| 201 | VTEST_SHOW_LONGEST_BY_TOTALTIME: 3 |
| 202 | steps: |
| 203 | - uses: actions/checkout@v6 |
| 204 | - name: Build |
| 205 | run: | |
| 206 | echo %VFLAGS% |
| 207 | echo $VFLAGS |
| 208 | .\makev.bat -msvc |
| 209 | .\v.exe self |
| 210 | - name: V doctor |
| 211 | run: .\v.exe doctor |
| 212 | - name: Ensure code is well formatted |
| 213 | run: .\v.exe -silent test-cleancode |
| 214 | # - name: Install dependencies |
| 215 | # run: | |
| 216 | # .\v.exe setup-freetype |
| 217 | # .\.github\workflows\windows-install-sqlite.bat |
| 218 | # - name: Self tests (/fsanitize=address) # TODO: |
| 219 | # run: .\v.exe -cflags "/fsanitize=address" -silent test-self vlib |
| 220 | |
| 221 | sanitize-address-gcc: |
| 222 | runs-on: ubuntu-22.04 |
| 223 | timeout-minutes: 300 |
| 224 | env: |
| 225 | VFLAGS: -cc gcc -cflags -fno-omit-frame-pointer |
| 226 | VJOBS: 1 |
| 227 | ASAN_OPTIONS: detect_leaks=1 |
| 228 | LSAN_OPTIONS: max_leaks=1:print_suppressions=0:suppressions=/home/runner/work/v/v/.github/workflows/run_sanitizers_leak.suppressions |
| 229 | VNATIVE_SKIP_LIBC_VV: 1 |
| 230 | VTEST_SHOW_LONGEST_BY_RUNTIME: 3 |
| 231 | VTEST_SHOW_LONGEST_BY_COMPTIME: 3 |
| 232 | VTEST_SHOW_LONGEST_BY_TOTALTIME: 3 |
| 233 | steps: |
| 234 | - uses: actions/checkout@v6 |
| 235 | - uses: ./.github/actions/cache-apt-packages-action |
| 236 | - name: Build V |
| 237 | run: make -j4 && ./v symlink |
| 238 | - name: V doctor |
| 239 | run: ./v doctor |
| 240 | - name: Ensure code is well formatted |
| 241 | run: ./v -silent test-cleancode |
| 242 | - name: Install dependencies |
| 243 | run: | |
| 244 | .github/workflows/disable_azure_mirror.sh |
| 245 | ./v retry -- sudo apt update |
| 246 | ./v retry -- sudo apt install --quiet -y postgresql libpq-dev libssl-dev sqlite3 libsqlite3-dev valgrind |
| 247 | ./v retry -- sudo apt install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev libxrandr-dev libasound2-dev libegl-dev |
| 248 | ./v retry -- sudo apt install clang |
| 249 | - name: Recompile V with -cstrict |
| 250 | run: ./v -cg -cstrict -o v cmd/v |
| 251 | - name: Self tests (-fsanitize=address) |
| 252 | run: ./v -cflags -fsanitize=address -silent test-self vlib |
| 253 | - name: Test vlib/v/tests/ (V compiled with -fsanitize=address) |
| 254 | run: | |
| 255 | ./v -cflags -fsanitize=address,pointer-compare,pointer-subtract -o v cmd/v |
| 256 | ./v -cc tcc -silent test-self -asan-compiler vlib/v/tests/ |
| 257 | - name: Build examples (V compiled with -fsanitize=address) |
| 258 | run: ./v -silent build-examples |
| 259 | |
| 260 | sanitize-memory-clang: |
| 261 | runs-on: ubuntu-22.04 |
| 262 | timeout-minutes: 300 |
| 263 | env: |
| 264 | VFLAGS: -cc clang -gc none -cflags -fno-omit-frame-pointer |
| 265 | VJOBS: 1 |
| 266 | VNATIVE_SKIP_LIBC_VV: 1 |
| 267 | VTEST_SHOW_LONGEST_BY_RUNTIME: 3 |
| 268 | VTEST_SHOW_LONGEST_BY_COMPTIME: 3 |
| 269 | VTEST_SHOW_LONGEST_BY_TOTALTIME: 3 |
| 270 | steps: |
| 271 | - uses: actions/checkout@v6 |
| 272 | - uses: ./.github/actions/cache-apt-packages-action |
| 273 | - name: Build V |
| 274 | run: make -j4 && ./v symlink |
| 275 | - name: V doctor |
| 276 | run: ./v doctor |
| 277 | - name: Ensure code is well formatted |
| 278 | run: ./v -silent test-cleancode |
| 279 | - name: Install dependencies |
| 280 | run: | |
| 281 | .github/workflows/disable_azure_mirror.sh |
| 282 | ./v retry -- sudo apt update |
| 283 | ./v retry -- sudo apt install --quiet -y postgresql libpq-dev libssl-dev sqlite3 libsqlite3-dev valgrind |
| 284 | ./v retry -- sudo apt install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev libxrandr-dev libasound2-dev libegl-dev |
| 285 | ./v retry -- sudo apt install clang |
| 286 | - name: Recompile V with clang and -cstrict |
| 287 | run: ./v -cc clang -cg -cstrict -o v cmd/v |
| 288 | - name: Self tests (-fsanitize=memory) |
| 289 | run: ./v -cflags -fsanitize=memory -silent test-self -msan-compiler vlib |
| 290 | - name: Test vlib/v/tests/ (V compiled with -fsanitize=memory) |
| 291 | run: | |
| 292 | ./v -cflags -fsanitize=memory -o v cmd/v |
| 293 | ./v -cc tcc -silent test-self -msan-compiler vlib/v/tests/ |
| 294 | - name: Build examples (V compiled with -fsanitize=memory) |
| 295 | run: ./v -silent build-examples |
| 296 | |
| 297 | sanitize-address-clang-without-gc: |
| 298 | runs-on: ubuntu-22.04 |
| 299 | timeout-minutes: 300 |
| 300 | env: |
| 301 | VFLAGS: -cc clang -gc none -cflags -fno-omit-frame-pointer |
| 302 | VJOBS: 1 |
| 303 | LSAN_OPTIONS: detect_leaks=0 |
| 304 | VNATIVE_SKIP_LIBC_VV: 1 |
| 305 | VTEST_SHOW_LONGEST_BY_RUNTIME: 3 |
| 306 | VTEST_SHOW_LONGEST_BY_COMPTIME: 3 |
| 307 | VTEST_SHOW_LONGEST_BY_TOTALTIME: 3 |
| 308 | steps: |
| 309 | - uses: actions/checkout@v6 |
| 310 | - uses: ./.github/actions/cache-apt-packages-action |
| 311 | - name: Build V |
| 312 | run: make -j4 && ./v symlink |
| 313 | - name: V doctor |
| 314 | run: ./v doctor |
| 315 | - name: Ensure code is well formatted |
| 316 | run: ./v -silent test-cleancode |
| 317 | - name: Install dependencies |
| 318 | run: | |
| 319 | .github/workflows/disable_azure_mirror.sh |
| 320 | ./v retry -- sudo apt update |
| 321 | ./v retry -- sudo apt install --quiet -y postgresql libpq-dev libssl-dev sqlite3 libsqlite3-dev valgrind |
| 322 | ./v retry -- sudo apt install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev libxrandr-dev libasound2-dev libegl-dev |
| 323 | ./v retry -- sudo apt install clang |
| 324 | - name: Recompile V with -cstrict |
| 325 | run: ./v -cg -cstrict -o v cmd/v |
| 326 | - name: Self tests (-fsanitize=address) |
| 327 | run: ./v -cflags -fsanitize=address -silent test-self vlib |
| 328 | |