main.yml 6.5 KB

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