build.yml 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  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. macOS-latest-make:
  56. runs-on: macos-latest
  57. steps:
  58. - name: Clone
  59. id: checkout
  60. uses: actions/checkout@v1
  61. - name: Dependencies
  62. id: depends
  63. run: |
  64. brew update
  65. - name: Build
  66. id: make_build
  67. run: |
  68. make
  69. macOS-latest-cmake:
  70. runs-on: macOS-latest
  71. steps:
  72. - name: Clone
  73. id: checkout
  74. uses: actions/checkout@v1
  75. - name: Dependencies
  76. id: depends
  77. run: |
  78. brew update
  79. - name: Build
  80. id: cmake_build
  81. run: |
  82. mkdir build
  83. cd build
  84. cmake -DLLAMA_AVX2=OFF ..
  85. cmake --build . --config Release
  86. - name: Test
  87. id: cmake_test
  88. run: |
  89. cd build
  90. ctest --output-on-failure
  91. windows-latest-cmake:
  92. runs-on: windows-latest
  93. steps:
  94. - name: Clone
  95. id: checkout
  96. uses: actions/checkout@v1
  97. - name: Build
  98. id: cmake_build
  99. run: |
  100. mkdir build
  101. cd build
  102. cmake ..
  103. cmake --build . --config Release
  104. - name: Test
  105. id: cmake_test
  106. run: |
  107. cd build
  108. ctest -C Release --output-on-failure
  109. - name: Get commit hash
  110. id: commit
  111. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  112. uses: pr-mpt/actions-commit-hash@v2
  113. - name: Pack artifacts
  114. id: pack_artifacts
  115. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  116. run: |
  117. 7z a llama-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-x64.zip .\build\bin\Release\*
  118. - name: Create release
  119. id: create_release
  120. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  121. uses: zendesk/action-create-release@v1
  122. env:
  123. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  124. with:
  125. tag_name: ${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}
  126. - name: Upload release
  127. id: upload_release
  128. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  129. uses: actions/upload-release-asset@v1
  130. env:
  131. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  132. with:
  133. upload_url: ${{ steps.create_release.outputs.upload_url }}
  134. asset_path: .\llama-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-x64.zip
  135. asset_name: llama-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-x64.zip
  136. asset_content_type: application/octet-stream
  137. # ubuntu-latest-gcc:
  138. # runs-on: ubuntu-latest
  139. #
  140. # strategy:
  141. # matrix:
  142. # build: [Debug, Release]
  143. #
  144. # steps:
  145. # - name: Clone
  146. # uses: actions/checkout@v1
  147. #
  148. # - name: Dependencies
  149. # run: |
  150. # sudo apt-get update
  151. # sudo apt-get install build-essential
  152. # sudo apt-get install cmake
  153. #
  154. # - name: Configure
  155. # run: cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  156. #
  157. # - name: Build
  158. # run: |
  159. # make
  160. #
  161. # ubuntu-latest-clang:
  162. # runs-on: ubuntu-latest
  163. #
  164. # strategy:
  165. # matrix:
  166. # build: [Debug, Release]
  167. #
  168. # steps:
  169. # - name: Clone
  170. # uses: actions/checkout@v1
  171. #
  172. # - name: Dependencies
  173. # run: |
  174. # sudo apt-get update
  175. # sudo apt-get install build-essential
  176. # sudo apt-get install cmake
  177. #
  178. # - name: Configure
  179. # run: cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }} -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang
  180. #
  181. # - name: Build
  182. # run: |
  183. # make
  184. #
  185. # ubuntu-latest-gcc-sanitized:
  186. # runs-on: ubuntu-latest
  187. #
  188. # strategy:
  189. # matrix:
  190. # sanitizer: [ADDRESS, THREAD, UNDEFINED]
  191. #
  192. # steps:
  193. # - name: Clone
  194. # uses: actions/checkout@v1
  195. #
  196. # - name: Dependencies
  197. # run: |
  198. # sudo apt-get update
  199. # sudo apt-get install build-essential
  200. # sudo apt-get install cmake
  201. #
  202. # - name: Configure
  203. # run: cmake . -DCMAKE_BUILD_TYPE=Debug -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON
  204. #
  205. # - name: Build
  206. # run: |
  207. # make
  208. #
  209. # windows:
  210. # runs-on: windows-latest
  211. #
  212. # strategy:
  213. # matrix:
  214. # build: [Release]
  215. # arch: [Win32, x64]
  216. # include:
  217. # - arch: Win32
  218. # s2arc: x86
  219. # - arch: x64
  220. # s2arc: x64
  221. #
  222. # steps:
  223. # - name: Clone
  224. # uses: actions/checkout@v1
  225. #
  226. # - name: Add msbuild to PATH
  227. # uses: microsoft/setup-msbuild@v1
  228. #
  229. # - name: Configure
  230. # run: >
  231. # cmake -S . -B ./build -A ${{ matrix.arch }}
  232. # -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  233. #
  234. # - name: Build
  235. # run: |
  236. # cd ./build
  237. # msbuild ALL_BUILD.vcxproj -t:build -p:configuration=${{ matrix.build }} -p:platform=${{ matrix.arch }}
  238. #
  239. # - name: Upload binaries
  240. # uses: actions/upload-artifact@v1
  241. # with:
  242. # name: llama-bin-${{ matrix.arch }}
  243. # path: build/bin/${{ matrix.build }}
  244. #
  245. # windows-blas:
  246. # runs-on: windows-latest
  247. #
  248. # strategy:
  249. # matrix:
  250. # build: [Release]
  251. # arch: [Win32, x64]
  252. # blas: [ON]
  253. # include:
  254. # - arch: Win32
  255. # obzip: https://github.com/xianyi/OpenBLAS/releases/download/v0.3.21/OpenBLAS-0.3.21-x86.zip
  256. # s2arc: x86
  257. # - arch: x64
  258. # obzip: https://github.com/xianyi/OpenBLAS/releases/download/v0.3.21/OpenBLAS-0.3.21-x64.zip
  259. # s2arc: x64
  260. #
  261. # steps:
  262. # - name: Clone
  263. # uses: actions/checkout@v1
  264. #
  265. # - name: Add msbuild to PATH
  266. # uses: microsoft/setup-msbuild@v1
  267. #
  268. # - name: Fetch OpenBLAS
  269. # if: matrix.blas == 'ON'
  270. # run: |
  271. # C:/msys64/usr/bin/wget.exe -qO blas.zip ${{ matrix.obzip }}
  272. # 7z x blas.zip -oblas -y
  273. # copy blas/include/cblas.h .
  274. # copy blas/include/openblas_config.h .
  275. # echo "blasdir=$env:GITHUB_WORKSPACE/blas" >> $env:GITHUB_ENV
  276. #
  277. # - name: Configure
  278. # run: >
  279. # cmake -S . -B ./build -A ${{ matrix.arch }}
  280. # -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  281. # -DLLAMA_SUPPORT_OPENBLAS=${{ matrix.blas }}
  282. # -DCMAKE_LIBRARY_PATH="$env:blasdir/lib"
  283. #
  284. # - name: Build
  285. # run: |
  286. # cd ./build
  287. # msbuild ALL_BUILD.vcxproj -t:build -p:configuration=${{ matrix.build }} -p:platform=${{ matrix.arch }}
  288. #
  289. # - name: Copy libopenblas.dll
  290. # if: matrix.blas == 'ON'
  291. # run: copy "$env:blasdir/bin/libopenblas.dll" build/bin/${{ matrix.build }}
  292. #
  293. # - name: Upload binaries
  294. # if: matrix.blas == 'ON'
  295. # uses: actions/upload-artifact@v1
  296. # with:
  297. # name: llama-blas-bin-${{ matrix.arch }}
  298. # path: build/bin/${{ matrix.build }}
  299. #
  300. # emscripten:
  301. # runs-on: ubuntu-latest
  302. #
  303. # strategy:
  304. # matrix:
  305. # build: [Release]
  306. #
  307. # steps:
  308. # - name: Clone
  309. # uses: actions/checkout@v1
  310. #
  311. # - name: Dependencies
  312. # run: |
  313. # wget -q https://github.com/emscripten-core/emsdk/archive/master.tar.gz
  314. # tar -xvf master.tar.gz
  315. # emsdk-master/emsdk update
  316. # emsdk-master/emsdk install latest
  317. # emsdk-master/emsdk activate latest
  318. #
  319. # - name: Configure
  320. # run: echo "tmp"
  321. #
  322. # - name: Build
  323. # run: |
  324. # pushd emsdk-master
  325. # source ./emsdk_env.sh
  326. # popd
  327. # emcmake cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  328. # make