build.yml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. name: CI
  2. on:
  3. workflow_dispatch: # allows manual triggering
  4. inputs:
  5. create_release:
  6. description: 'Create new release'
  7. required: true
  8. type: boolean
  9. push:
  10. paths: ['.github/workflows/**', 'CMakeLists.txt', 'Makefile', '**.h', '*.c', '**.cpp']
  11. pull_request:
  12. types: [opened, synchronize, edited, reopened, review_requested, ready_for_review]
  13. paths: ['CMakeLists.txt', 'Makefile', '**.h', '*.c', '**.cpp']
  14. env:
  15. BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
  16. jobs:
  17. ubuntu-latest-make:
  18. runs-on: ubuntu-latest
  19. steps:
  20. - name: Clone
  21. id: checkout
  22. uses: actions/checkout@v1
  23. - name: Dependencies
  24. id: depends
  25. run: |
  26. sudo apt-get update
  27. sudo apt-get install build-essential
  28. - name: Build
  29. id: make_build
  30. run: |
  31. make
  32. ubuntu-latest-cmake:
  33. runs-on: ubuntu-latest
  34. steps:
  35. - name: Clone
  36. id: checkout
  37. uses: actions/checkout@v1
  38. - name: Dependencies
  39. id: depends
  40. run: |
  41. sudo apt-get update
  42. sudo apt-get install build-essential
  43. - name: Build
  44. id: cmake_build
  45. run: |
  46. mkdir build
  47. cd build
  48. cmake ..
  49. cmake --build . --config Release
  50. - name: Test
  51. id: cmake_test
  52. run: |
  53. cd build
  54. ctest --output-on-failure
  55. ubuntu-latest-cmake-sanitizer:
  56. runs-on: ubuntu-latest
  57. continue-on-error: true
  58. strategy:
  59. matrix:
  60. sanitizer: [ADDRESS, THREAD, UNDEFINED]
  61. steps:
  62. - name: Clone
  63. id: checkout
  64. uses: actions/checkout@v1
  65. - name: Dependencies
  66. id: depends
  67. run: |
  68. sudo apt-get update
  69. sudo apt-get install build-essential
  70. - name: Build
  71. id: cmake_build
  72. run: |
  73. mkdir build
  74. cd build
  75. cmake .. -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON
  76. cmake --build . --config Release
  77. - name: Test
  78. id: cmake_test
  79. run: |
  80. cd build
  81. ctest --output-on-failure
  82. macOS-latest-make:
  83. runs-on: macos-latest
  84. steps:
  85. - name: Clone
  86. id: checkout
  87. uses: actions/checkout@v1
  88. - name: Dependencies
  89. id: depends
  90. run: |
  91. brew update
  92. - name: Build
  93. id: make_build
  94. run: |
  95. make
  96. macOS-latest-cmake:
  97. runs-on: macOS-latest
  98. steps:
  99. - name: Clone
  100. id: checkout
  101. uses: actions/checkout@v1
  102. - name: Dependencies
  103. id: depends
  104. run: |
  105. brew update
  106. - name: Build
  107. id: cmake_build
  108. run: |
  109. mkdir build
  110. cd build
  111. cmake -DLLAMA_AVX2=OFF ..
  112. cmake --build . --config Release
  113. - name: Test
  114. id: cmake_test
  115. run: |
  116. cd build
  117. ctest --output-on-failure
  118. windows-latest-cmake:
  119. runs-on: windows-latest
  120. strategy:
  121. matrix:
  122. include:
  123. - build: 'avx2'
  124. defines: ''
  125. - build: 'avx'
  126. defines: '-DLLAMA_AVX2=OFF'
  127. - build: 'avx512'
  128. defines: '-DLLAMA_AVX512=ON'
  129. steps:
  130. - name: Clone
  131. id: checkout
  132. uses: actions/checkout@v1
  133. - name: Build
  134. id: cmake_build
  135. run: |
  136. mkdir build
  137. cd build
  138. cmake .. ${{ matrix.defines }}
  139. cmake --build . --config Release
  140. - name: Check AVX512F support
  141. id: check_avx512f
  142. if: ${{ matrix.build == 'avx512' }}
  143. continue-on-error: true
  144. run: |
  145. cd build
  146. Set-Content -Path .\avx512f.exe -Value ([Convert]::FromBase64String('TVqQAAMAAAAEAAAA//8AALgAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAyAAAAA4fug4AtAnNIbgBTM0hVGhpcyBwcm9ncmFtIGNhbm5vdCBiZSBydW4gaW4gRE9TIG1vZGUuDQ0KJAAAAAAAAAClmfXY4fibi+H4m4vh+JuL4fiai+P4m4si98aL4vibi7Xbq4vg+JuLUmljaOH4m4sAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQRQAATAEBAGo6H2QAAAAAAAAAAOAADwELAQYAAAIAAAAAAAAAAAAADBAAAAAQAAAAIAAAAABAAAAQAAAAAgAABAAAAAAAAAAEAAAAAAAAAAAgAAAAAgAAAAAAAAMAAAAAABAAABAAAAAAEAAAEAAAAAAAABAAAAAAAAAAAAAAAFQQAAAoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC50ZXh0AAAAsgAAAAAQAAAAAgAAAAIAAAAAAAAAAAAAAAAAACAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACUEAAAiBAAAAAAAABVi+xRUVNTuAcAAAAPosHrEGaD4wGJXfxbg0X8MI1F+GoAUI1F/GoBUGr1/xUAEEAAUP8VBBBAAItF/FuDwND32BvAQMnDzMx8EAAAAAAAAAAAAACkEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAlBAAAIgQAAAAAAAApANXcml0ZUZpbGUAuQFHZXRTdGRIYW5kbGUAAEtFUk5FTDMyLmRsbAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==')) -AsByteStream
  147. .\avx512f.exe && echo " AVX512F: YES" && ( echo HAS_AVX512F=1 >> $env:GITHUB_ENV ) || echo " AVX512F: NO"
  148. - name: Test
  149. id: cmake_test
  150. if: ${{ matrix.build != 'avx512' || env.HAS_AVX512F == '1' }} # Test AVX-512 only when possible
  151. run: |
  152. cd build
  153. ctest -C Release --output-on-failure
  154. - name: Get commit hash
  155. id: commit
  156. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  157. uses: pr-mpt/actions-commit-hash@v2
  158. - name: Pack artifacts
  159. id: pack_artifacts
  160. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  161. run: |
  162. 7z a llama-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-${{ matrix.build }}-x64.zip .\build\bin\Release\*
  163. - name: Upload artifacts
  164. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  165. uses: actions/upload-artifact@v3
  166. with:
  167. path: |
  168. llama-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-${{ matrix.build }}-x64.zip
  169. release:
  170. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  171. runs-on: ubuntu-latest
  172. needs:
  173. - ubuntu-latest-make
  174. - ubuntu-latest-cmake
  175. - macOS-latest-make
  176. - macOS-latest-cmake
  177. - windows-latest-cmake
  178. steps:
  179. - name: Download artifacts
  180. id: download-artifact
  181. uses: actions/download-artifact@v3
  182. - name: Get commit hash
  183. id: commit
  184. uses: pr-mpt/actions-commit-hash@v2
  185. - name: Create release
  186. id: create_release
  187. uses: anzz1/action-create-release@v1
  188. env:
  189. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  190. with:
  191. tag_name: ${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}
  192. - name: Upload release
  193. id: upload_release
  194. uses: actions/github-script@v3
  195. with:
  196. github-token: ${{secrets.GITHUB_TOKEN}}
  197. script: |
  198. const path = require('path');
  199. const fs = require('fs');
  200. const release_id = '${{ steps.create_release.outputs.id }}';
  201. for (let file of await fs.readdirSync('./artifact')) {
  202. if (path.extname(file) === '.zip') {
  203. console.log('uploadReleaseAsset', file);
  204. await github.repos.uploadReleaseAsset({
  205. owner: context.repo.owner,
  206. repo: context.repo.repo,
  207. release_id: release_id,
  208. name: file,
  209. data: await fs.readFileSync(`./artifact/${file}`)
  210. });
  211. }
  212. }
  213. # ubuntu-latest-gcc:
  214. # runs-on: ubuntu-latest
  215. #
  216. # strategy:
  217. # matrix:
  218. # build: [Debug, Release]
  219. #
  220. # steps:
  221. # - name: Clone
  222. # uses: actions/checkout@v1
  223. #
  224. # - name: Dependencies
  225. # run: |
  226. # sudo apt-get update
  227. # sudo apt-get install build-essential
  228. # sudo apt-get install cmake
  229. #
  230. # - name: Configure
  231. # run: cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  232. #
  233. # - name: Build
  234. # run: |
  235. # make
  236. #
  237. # ubuntu-latest-clang:
  238. # runs-on: ubuntu-latest
  239. #
  240. # strategy:
  241. # matrix:
  242. # build: [Debug, Release]
  243. #
  244. # steps:
  245. # - name: Clone
  246. # uses: actions/checkout@v1
  247. #
  248. # - name: Dependencies
  249. # run: |
  250. # sudo apt-get update
  251. # sudo apt-get install build-essential
  252. # sudo apt-get install cmake
  253. #
  254. # - name: Configure
  255. # run: cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }} -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang
  256. #
  257. # - name: Build
  258. # run: |
  259. # make
  260. #
  261. # ubuntu-latest-gcc-sanitized:
  262. # runs-on: ubuntu-latest
  263. #
  264. # strategy:
  265. # matrix:
  266. # sanitizer: [ADDRESS, THREAD, UNDEFINED]
  267. #
  268. # steps:
  269. # - name: Clone
  270. # uses: actions/checkout@v1
  271. #
  272. # - name: Dependencies
  273. # run: |
  274. # sudo apt-get update
  275. # sudo apt-get install build-essential
  276. # sudo apt-get install cmake
  277. #
  278. # - name: Configure
  279. # run: cmake . -DCMAKE_BUILD_TYPE=Debug -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON
  280. #
  281. # - name: Build
  282. # run: |
  283. # make
  284. #
  285. # windows:
  286. # runs-on: windows-latest
  287. #
  288. # strategy:
  289. # matrix:
  290. # build: [Release]
  291. # arch: [Win32, x64]
  292. # include:
  293. # - arch: Win32
  294. # s2arc: x86
  295. # - arch: x64
  296. # s2arc: x64
  297. #
  298. # steps:
  299. # - name: Clone
  300. # uses: actions/checkout@v1
  301. #
  302. # - name: Add msbuild to PATH
  303. # uses: microsoft/setup-msbuild@v1
  304. #
  305. # - name: Configure
  306. # run: >
  307. # cmake -S . -B ./build -A ${{ matrix.arch }}
  308. # -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  309. #
  310. # - name: Build
  311. # run: |
  312. # cd ./build
  313. # msbuild ALL_BUILD.vcxproj -t:build -p:configuration=${{ matrix.build }} -p:platform=${{ matrix.arch }}
  314. #
  315. # - name: Upload binaries
  316. # uses: actions/upload-artifact@v1
  317. # with:
  318. # name: llama-bin-${{ matrix.arch }}
  319. # path: build/bin/${{ matrix.build }}
  320. #
  321. # windows-blas:
  322. # runs-on: windows-latest
  323. #
  324. # strategy:
  325. # matrix:
  326. # build: [Release]
  327. # arch: [Win32, x64]
  328. # blas: [ON]
  329. # include:
  330. # - arch: Win32
  331. # obzip: https://github.com/xianyi/OpenBLAS/releases/download/v0.3.21/OpenBLAS-0.3.21-x86.zip
  332. # s2arc: x86
  333. # - arch: x64
  334. # obzip: https://github.com/xianyi/OpenBLAS/releases/download/v0.3.21/OpenBLAS-0.3.21-x64.zip
  335. # s2arc: x64
  336. #
  337. # steps:
  338. # - name: Clone
  339. # uses: actions/checkout@v1
  340. #
  341. # - name: Add msbuild to PATH
  342. # uses: microsoft/setup-msbuild@v1
  343. #
  344. # - name: Fetch OpenBLAS
  345. # if: matrix.blas == 'ON'
  346. # run: |
  347. # C:/msys64/usr/bin/wget.exe -qO blas.zip ${{ matrix.obzip }}
  348. # 7z x blas.zip -oblas -y
  349. # copy blas/include/cblas.h .
  350. # copy blas/include/openblas_config.h .
  351. # echo "blasdir=$env:GITHUB_WORKSPACE/blas" >> $env:GITHUB_ENV
  352. #
  353. # - name: Configure
  354. # run: >
  355. # cmake -S . -B ./build -A ${{ matrix.arch }}
  356. # -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  357. # -DLLAMA_SUPPORT_OPENBLAS=${{ matrix.blas }}
  358. # -DCMAKE_LIBRARY_PATH="$env:blasdir/lib"
  359. #
  360. # - name: Build
  361. # run: |
  362. # cd ./build
  363. # msbuild ALL_BUILD.vcxproj -t:build -p:configuration=${{ matrix.build }} -p:platform=${{ matrix.arch }}
  364. #
  365. # - name: Copy libopenblas.dll
  366. # if: matrix.blas == 'ON'
  367. # run: copy "$env:blasdir/bin/libopenblas.dll" build/bin/${{ matrix.build }}
  368. #
  369. # - name: Upload binaries
  370. # if: matrix.blas == 'ON'
  371. # uses: actions/upload-artifact@v1
  372. # with:
  373. # name: llama-blas-bin-${{ matrix.arch }}
  374. # path: build/bin/${{ matrix.build }}
  375. #
  376. # emscripten:
  377. # runs-on: ubuntu-latest
  378. #
  379. # strategy:
  380. # matrix:
  381. # build: [Release]
  382. #
  383. # steps:
  384. # - name: Clone
  385. # uses: actions/checkout@v1
  386. #
  387. # - name: Dependencies
  388. # run: |
  389. # wget -q https://github.com/emscripten-core/emsdk/archive/master.tar.gz
  390. # tar -xvf master.tar.gz
  391. # emsdk-master/emsdk update
  392. # emsdk-master/emsdk install latest
  393. # emsdk-master/emsdk activate latest
  394. #
  395. # - name: Configure
  396. # run: echo "tmp"
  397. #
  398. # - name: Build
  399. # run: |
  400. # pushd emsdk-master
  401. # source ./emsdk_env.sh
  402. # popd
  403. # emcmake cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  404. # make