main.yml 5.9 KB

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