build.yml 13 KB

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