main.yml 5.9 KB

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