build.yml 11 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 --verbose
  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. build_type: [Debug, Release]
  62. accelerate: [ON, OFF]
  63. steps:
  64. - name: Clone
  65. id: checkout
  66. uses: actions/checkout@v1
  67. - name: Dependencies
  68. id: depends
  69. run: |
  70. sudo apt-get update
  71. sudo apt-get install build-essential
  72. - name: Build
  73. id: cmake_build
  74. run: |
  75. mkdir build
  76. cd build
  77. cmake .. -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DLLAMA_ACCELERATE=${{ matrix.accelerate }}
  78. cmake --build . --config ${{ matrix.build_type }}
  79. - name: Test
  80. id: cmake_test
  81. run: |
  82. cd build
  83. ctest --verbose
  84. macOS-latest-make:
  85. runs-on: macos-latest
  86. steps:
  87. - name: Clone
  88. id: checkout
  89. uses: actions/checkout@v1
  90. - name: Dependencies
  91. id: depends
  92. run: |
  93. brew update
  94. - name: Build
  95. id: make_build
  96. run: |
  97. make
  98. macOS-latest-cmake:
  99. runs-on: macOS-latest
  100. steps:
  101. - name: Clone
  102. id: checkout
  103. uses: actions/checkout@v1
  104. - name: Dependencies
  105. id: depends
  106. run: |
  107. brew update
  108. - name: Build
  109. id: cmake_build
  110. run: |
  111. mkdir build
  112. cd build
  113. cmake -DLLAMA_AVX2=OFF ..
  114. cmake --build . --config Release
  115. - name: Test
  116. id: cmake_test
  117. run: |
  118. cd build
  119. ctest --verbose
  120. windows-latest-cmake:
  121. runs-on: windows-latest
  122. strategy:
  123. matrix:
  124. include:
  125. - build: 'avx2'
  126. defines: ''
  127. - build: 'avx'
  128. defines: '-DLLAMA_AVX2=OFF'
  129. - build: 'avx512'
  130. defines: '-DLLAMA_AVX512=ON'
  131. steps:
  132. - name: Clone
  133. id: checkout
  134. uses: actions/checkout@v1
  135. - name: Build
  136. id: cmake_build
  137. run: |
  138. mkdir build
  139. cd build
  140. cmake .. ${{ matrix.defines }}
  141. cmake --build . --config Release
  142. - name: Check AVX512F support
  143. id: check_avx512f
  144. if: ${{ matrix.build == 'avx512' }}
  145. continue-on-error: true
  146. run: |
  147. echo "TODO: check avx512f"
  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 --verbose
  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