main.yml 6.5 KB

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