main.yml 5.5 KB

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