main.yml 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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
  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
  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
  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:
  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.sh arm64-v8a
  119. bash build_android.sh armeabi-v7a
  120. bash build_android.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_ios:
  134. runs-on: macos-latest
  135. steps:
  136. - uses: actions/checkout@v4
  137. with:
  138. submodules: recursive
  139. - name: Compile Frameworks
  140. run: |
  141. git clone https://github.com/leetal/ios-cmake --depth 1 ~/ios-cmake
  142. bash build_ios.sh
  143. mkdir -p output
  144. cp -r build/pocketpy.xcframework output/pocketpy.xcframework
  145. - uses: actions/upload-artifact@v4
  146. with:
  147. name: ios
  148. path: output
  149. build_linux_multiarch:
  150. runs-on: ubuntu-latest
  151. strategy:
  152. matrix:
  153. arch: [x86, aarch64, armv7]
  154. steps:
  155. - uses: actions/checkout@v4
  156. with:
  157. submodules: recursive
  158. - name: Setup Alpine Linux for ${{ matrix.arch }}
  159. uses: jirutka/setup-alpine@v1
  160. with:
  161. arch: ${{ matrix.arch }}
  162. packages: gcc g++ make cmake libc-dev linux-headers python3 git
  163. - name: Build and Test
  164. run: |
  165. echo "Building for architecture: ${{ matrix.arch }}"
  166. uname -m
  167. python -c "import struct; print(8 * struct.calcsize('P'))"
  168. python cmake_build.py
  169. python scripts/run_tests.py
  170. shell: alpine.sh --root {0}
  171. merge:
  172. runs-on: ubuntu-latest
  173. needs: [ build_win32, build_linux, build_darwin, build_android, build_ios ]
  174. steps:
  175. - name: "Create output directory"
  176. run: "mkdir $GITHUB_WORKSPACE/output"
  177. - name: "Merge win32"
  178. uses: actions/download-artifact@v4.1.7
  179. with:
  180. name: windows
  181. path: $GITHUB_WORKSPACE/output/windows
  182. - name: "Merge linux"
  183. uses: actions/download-artifact@v4.1.7
  184. with:
  185. name: linux
  186. path: $GITHUB_WORKSPACE/output/linux
  187. # - name: "Merge darwin"
  188. # uses: actions/download-artifact@v4.1.7
  189. # with:
  190. # name: macos
  191. # path: $GITHUB_WORKSPACE/output/macos
  192. - name: "Merge android"
  193. uses: actions/download-artifact@v4.1.7
  194. with:
  195. name: android
  196. path: $GITHUB_WORKSPACE/output/android
  197. - name: "Merge ios"
  198. uses: actions/download-artifact@v4.1.7
  199. with:
  200. name: ios
  201. path: $GITHUB_WORKSPACE/output/ios
  202. - name: "Upload merged artifact"
  203. uses: actions/upload-artifact@v4.3.3
  204. with:
  205. name: all-in-one
  206. path: $GITHUB_WORKSPACE/output