1
0

main.yml 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. name: build
  2. on:
  3. push:
  4. paths-ignore:
  5. - 'docs/**'
  6. - 'web/**'
  7. - '**.md'
  8. pull_request:
  9. paths-ignore:
  10. - 'docs/**'
  11. - 'web/**'
  12. - '**.md'
  13. jobs:
  14. build_win32_amalgamated:
  15. runs-on: windows-latest
  16. steps:
  17. - uses: actions/checkout@v4
  18. with:
  19. submodules: recursive
  20. - uses: ilammy/msvc-dev-cmd@v1
  21. - name: Compile
  22. shell: powershell
  23. run: |
  24. python amalgamate.py
  25. cd amalgamated
  26. cl.exe /std:c11 /experimental:c11atomics /utf-8 /Ox /I. pocketpy.c main.c /link Ws2_32.lib /out:pkpy.exe
  27. build_win32:
  28. runs-on: windows-latest
  29. steps:
  30. - uses: actions/checkout@v4
  31. with:
  32. submodules: recursive
  33. - uses: ilammy/msvc-dev-cmd@v1
  34. - name: Compile
  35. shell: bash
  36. run: |
  37. mkdir -p output/x86_64
  38. python cmake_build.py Release -DPK_BUILD_MODULE_LZ4=ON -DPK_BUILD_MODULE_CUTE_PNG=ON -DPK_BUILD_MODULE_MSGPACK=ON
  39. cp main.exe output/x86_64
  40. cp pocketpy.dll output/x86_64
  41. - uses: actions/upload-artifact@v4
  42. with:
  43. name: windows
  44. path: output
  45. - name: Unit Test
  46. run: python scripts/run_tests.py
  47. - name: Benchmark
  48. run: python scripts/run_tests.py benchmark
  49. build_linux:
  50. runs-on: ubuntu-22.04
  51. steps:
  52. - uses: actions/checkout@v4
  53. with:
  54. submodules: recursive
  55. - name: Setup Clang
  56. uses: egor-tensin/setup-clang@v1
  57. with:
  58. version: 17
  59. platform: x64
  60. - name: Run Sanitizers
  61. run: |
  62. sudo apt-get install -y libclang-rt-17-dev
  63. bash build_g.sh
  64. bash run_tests.sh
  65. rm -rf ./main
  66. - name: Run Script Check
  67. run: |
  68. python scripts/check_pragma_once.py include
  69. python scripts/check_undef.py src
  70. - name: Unit Test with Coverage
  71. run: bash run_tests.sh
  72. - name: Upload coverage reports to Codecov
  73. uses: codecov/codecov-action@v4
  74. with:
  75. token: ${{ secrets.CODECOV_TOKEN }}
  76. directory: .coverage
  77. if: github.ref == 'refs/heads/main'
  78. - name: Compile and Test
  79. run: |
  80. python scripts/check_pragma_once.py include
  81. mkdir -p output/x86_64
  82. python cmake_build.py Release -DPK_BUILD_MODULE_LZ4=ON -DPK_BUILD_MODULE_CUTE_PNG=ON -DPK_BUILD_MODULE_MSGPACK=ON
  83. python scripts/run_tests.py
  84. cp main output/x86_64
  85. cp libpocketpy.so output/x86_64
  86. env:
  87. CC: clang
  88. - uses: actions/upload-artifact@v4
  89. with:
  90. name: linux
  91. path: output
  92. - name: Benchmark
  93. run: python scripts/run_tests.py benchmark
  94. build_darwin:
  95. runs-on: macos-latest
  96. steps:
  97. - uses: actions/checkout@v4
  98. with:
  99. submodules: recursive
  100. - name: Compile and Test
  101. run: |
  102. python cmake_build.py Release -DPK_BUILD_MODULE_LZ4=ON -DPK_BUILD_MODULE_CUTE_PNG=ON -DPK_BUILD_MODULE_MSGPACK=ON
  103. python scripts/run_tests.py
  104. - name: Benchmark
  105. run: python scripts/run_tests.py benchmark
  106. - name: Test Amalgamated Build
  107. run: python amalgamate.py
  108. build_android_libs:
  109. runs-on: ubuntu-latest
  110. steps:
  111. - uses: actions/checkout@v4
  112. with:
  113. submodules: recursive
  114. - uses: nttld/setup-ndk@v1
  115. id: setup-ndk
  116. with:
  117. ndk-version: r23
  118. local-cache: false
  119. add-to-path: false
  120. - name: Compile Shared Library
  121. run: |
  122. bash build_android_libs.sh arm64-v8a
  123. bash build_android_libs.sh armeabi-v7a
  124. bash build_android_libs.sh x86_64
  125. mkdir -p output/arm64-v8a
  126. mkdir -p output/armeabi-v7a
  127. mkdir -p output/x86_64
  128. cp build/android/arm64-v8a/libpocketpy.so output/arm64-v8a
  129. cp build/android/armeabi-v7a/libpocketpy.so output/armeabi-v7a
  130. cp build/android/x86_64/libpocketpy.so output/x86_64
  131. env:
  132. ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
  133. - uses: actions/upload-artifact@v4
  134. with:
  135. name: android
  136. path: output
  137. build_darwin_libs:
  138. runs-on: macos-latest
  139. steps:
  140. - uses: actions/checkout@v4
  141. with:
  142. submodules: recursive
  143. - name: Compile Frameworks
  144. run: |
  145. bash build_darwin_libs.sh
  146. mkdir -p output
  147. cp build/libpocketpy.a output/libpocketpy.a
  148. - uses: actions/upload-artifact@v4
  149. with:
  150. name: darwin
  151. path: output
  152. build_ios_libs:
  153. runs-on: macos-latest
  154. steps:
  155. - uses: actions/checkout@v4
  156. with:
  157. submodules: recursive
  158. - name: Compile Frameworks
  159. run: |
  160. bash build_ios_libs.sh
  161. mkdir -p output
  162. cp -r build/pocketpy.xcframework output/pocketpy.xcframework
  163. - uses: actions/upload-artifact@v4
  164. with:
  165. name: ios
  166. path: output
  167. build_linux_multiarch:
  168. runs-on: ubuntu-latest
  169. strategy:
  170. matrix:
  171. arch: [x86, aarch64, armv7]
  172. steps:
  173. - uses: actions/checkout@v4
  174. with:
  175. submodules: recursive
  176. - name: Setup Alpine Linux for ${{ matrix.arch }}
  177. uses: jirutka/setup-alpine@v1
  178. with:
  179. arch: ${{ matrix.arch }}
  180. packages: gcc g++ make cmake libc-dev linux-headers python3 git
  181. - name: Build and Test
  182. run: |
  183. echo "Building for architecture: ${{ matrix.arch }}"
  184. uname -m
  185. python -c "import struct; print(8 * struct.calcsize('P'))"
  186. python cmake_build.py
  187. python scripts/run_tests.py
  188. shell: alpine.sh --root {0}
  189. merge:
  190. runs-on: ubuntu-latest
  191. needs: [ build_win32, build_linux, build_darwin, build_android_libs, build_darwin_libs, build_ios_libs ]
  192. steps:
  193. - name: "Create output directory"
  194. run: "mkdir $GITHUB_WORKSPACE/output"
  195. - name: "Merge win32"
  196. uses: actions/download-artifact@v4.1.7
  197. with:
  198. name: windows
  199. path: $GITHUB_WORKSPACE/output/windows
  200. - name: "Merge linux"
  201. uses: actions/download-artifact@v4.1.7
  202. with:
  203. name: linux
  204. path: $GITHUB_WORKSPACE/output/linux
  205. - name: "Merge android"
  206. uses: actions/download-artifact@v4.1.7
  207. with:
  208. name: android
  209. path: $GITHUB_WORKSPACE/output/android
  210. - name: "Merge darwin"
  211. uses: actions/download-artifact@v4.1.7
  212. with:
  213. name: darwin
  214. path: $GITHUB_WORKSPACE/output/darwin
  215. - name: "Merge ios"
  216. uses: actions/download-artifact@v4.1.7
  217. with:
  218. name: ios
  219. path: $GITHUB_WORKSPACE/output/ios
  220. - name: "Upload merged artifact"
  221. uses: actions/upload-artifact@v4.3.3
  222. with:
  223. name: all-in-one
  224. path: $GITHUB_WORKSPACE/output