main.yml 5.8 KB

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