main.yml 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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. python scripts/check_binding_retval.py
  71. - name: Unit Test with Coverage
  72. run: bash run_tests.sh
  73. - name: Upload coverage reports to Codecov
  74. uses: codecov/codecov-action@v4
  75. with:
  76. token: ${{ secrets.CODECOV_TOKEN }}
  77. directory: .coverage
  78. if: github.ref == 'refs/heads/main'
  79. - name: Compile and Test
  80. run: |
  81. python scripts/check_pragma_once.py include
  82. mkdir -p output/x86_64
  83. python cmake_build.py Release -DPK_BUILD_MODULE_LZ4=ON -DPK_BUILD_MODULE_CUTE_PNG=ON -DPK_BUILD_MODULE_MSGPACK=ON
  84. python scripts/run_tests.py
  85. cp main output/x86_64
  86. cp libpocketpy.so output/x86_64
  87. env:
  88. CC: clang
  89. - uses: actions/upload-artifact@v4
  90. with:
  91. name: linux
  92. path: output
  93. - name: Benchmark
  94. run: python scripts/run_tests.py benchmark
  95. build_darwin:
  96. runs-on: macos-latest
  97. steps:
  98. - uses: actions/checkout@v4
  99. with:
  100. submodules: recursive
  101. - name: Compile and Test
  102. run: |
  103. python cmake_build.py Release -DPK_BUILD_MODULE_LZ4=ON -DPK_BUILD_MODULE_CUTE_PNG=ON -DPK_BUILD_MODULE_MSGPACK=ON
  104. python scripts/run_tests.py
  105. - name: Benchmark
  106. run: python scripts/run_tests.py benchmark
  107. - name: Test Amalgamated Build
  108. run: python amalgamate.py
  109. build_android_libs:
  110. runs-on: ubuntu-latest
  111. steps:
  112. - uses: actions/checkout@v4
  113. with:
  114. submodules: recursive
  115. - uses: nttld/setup-ndk@v1
  116. id: setup-ndk
  117. with:
  118. ndk-version: r23
  119. local-cache: false
  120. add-to-path: false
  121. - name: Compile Shared Library
  122. run: |
  123. bash build_android_libs.sh arm64-v8a
  124. bash build_android_libs.sh armeabi-v7a
  125. bash build_android_libs.sh x86_64
  126. mkdir -p output/arm64-v8a
  127. mkdir -p output/armeabi-v7a
  128. mkdir -p output/x86_64
  129. cp build/android/arm64-v8a/libpocketpy.so output/arm64-v8a
  130. cp build/android/armeabi-v7a/libpocketpy.so output/armeabi-v7a
  131. cp build/android/x86_64/libpocketpy.so output/x86_64
  132. env:
  133. ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
  134. - uses: actions/upload-artifact@v4
  135. with:
  136. name: android
  137. path: output
  138. build_darwin_libs:
  139. runs-on: macos-latest
  140. steps:
  141. - uses: actions/checkout@v4
  142. with:
  143. submodules: recursive
  144. - name: Compile Frameworks
  145. run: |
  146. bash build_darwin_libs.sh
  147. mkdir -p output
  148. cp build/libpocketpy.a output/libpocketpy.a
  149. - uses: actions/upload-artifact@v4
  150. with:
  151. name: darwin
  152. path: output
  153. build_ios_libs:
  154. runs-on: macos-latest
  155. steps:
  156. - uses: actions/checkout@v4
  157. with:
  158. submodules: recursive
  159. - name: Compile Frameworks
  160. run: |
  161. bash build_ios_libs.sh
  162. mkdir -p output
  163. cp -r build/pocketpy.xcframework output/pocketpy.xcframework
  164. - uses: actions/upload-artifact@v4
  165. with:
  166. name: ios
  167. path: output
  168. build_linux_multiarch:
  169. runs-on: ubuntu-latest
  170. strategy:
  171. matrix:
  172. arch: [x86, aarch64, armv7]
  173. steps:
  174. - uses: actions/checkout@v4
  175. with:
  176. submodules: recursive
  177. - name: Setup Alpine Linux for ${{ matrix.arch }}
  178. uses: jirutka/setup-alpine@v1
  179. with:
  180. arch: ${{ matrix.arch }}
  181. packages: gcc g++ make cmake libc-dev linux-headers python3 git
  182. - name: Build and Test
  183. run: |
  184. echo "Building for architecture: ${{ matrix.arch }}"
  185. uname -m
  186. python -c "import struct; print(8 * struct.calcsize('P'))"
  187. python cmake_build.py
  188. python scripts/run_tests.py
  189. shell: alpine.sh --root {0}
  190. merge:
  191. runs-on: ubuntu-latest
  192. needs: [ build_win32, build_linux, build_darwin, build_android_libs, build_darwin_libs, build_ios_libs ]
  193. steps:
  194. - name: "Create output directory"
  195. run: "mkdir $GITHUB_WORKSPACE/output"
  196. - name: "Merge win32"
  197. uses: actions/download-artifact@v4.1.7
  198. with:
  199. name: windows
  200. path: $GITHUB_WORKSPACE/output/windows
  201. - name: "Merge linux"
  202. uses: actions/download-artifact@v4.1.7
  203. with:
  204. name: linux
  205. path: $GITHUB_WORKSPACE/output/linux
  206. - name: "Merge android"
  207. uses: actions/download-artifact@v4.1.7
  208. with:
  209. name: android
  210. path: $GITHUB_WORKSPACE/output/android
  211. - name: "Merge darwin"
  212. uses: actions/download-artifact@v4.1.7
  213. with:
  214. name: darwin
  215. path: $GITHUB_WORKSPACE/output/darwin
  216. - name: "Merge ios"
  217. uses: actions/download-artifact@v4.1.7
  218. with:
  219. name: ios
  220. path: $GITHUB_WORKSPACE/output/ios
  221. - name: "Upload merged artifact"
  222. uses: actions/upload-artifact@v4.3.3
  223. with:
  224. name: all-in-one
  225. path: $GITHUB_WORKSPACE/output