main.yml 5.9 KB

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