main.yml 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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. - uses: ilammy/msvc-dev-cmd@v1
  19. - name: Compile
  20. shell: powershell
  21. run: |
  22. python amalgamate.py
  23. cd amalgamated
  24. cl.exe /std:c++17 /EHsc /utf-8 /Ox /I. /DPK_ENABLE_OS=1 main.cpp /link /out:pkpy.exe
  25. # - uses: actions/upload-artifact@v4
  26. # with:
  27. # name: amalgamated
  28. # path: amalgamated/pkpy.exe
  29. build_win32:
  30. runs-on: windows-latest
  31. steps:
  32. - uses: actions/checkout@v4
  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-20.04
  51. steps:
  52. - uses: actions/checkout@v4
  53. - name: Setup Clang
  54. uses: egor-tensin/setup-clang@v1
  55. with:
  56. version: 15
  57. platform: x64
  58. - name: Install libc++
  59. run: sudo apt-get install -y libc++-15-dev libc++1-15 libc++abi-15-dev libc++abi1-15 libclang-rt-15-dev
  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
  69. run: |
  70. mkdir -p output/x86_64
  71. python cmake_build.py
  72. cp main output/x86_64
  73. cp libpocketpy.so output/x86_64
  74. env:
  75. CXX: clang++
  76. CC: clang
  77. - uses: actions/upload-artifact@v4
  78. with:
  79. name: linux
  80. path: output
  81. - name: Benchmark
  82. run: python scripts/run_tests.py benchmark
  83. - name: C Binding Test
  84. run: bash run_c_binding_test.sh
  85. build_linux_x86:
  86. runs-on: ubuntu-latest
  87. steps:
  88. - uses: actions/checkout@v4
  89. - name: Setup Alpine Linux for aarch64
  90. uses: jirutka/setup-alpine@v1
  91. with:
  92. arch: x86
  93. packages: gcc g++ make cmake libc-dev linux-headers python3
  94. - name: Build and Test
  95. run: |
  96. uname -m
  97. python cmake_build.py
  98. python scripts/run_tests.py
  99. python scripts/run_tests.py benchmark
  100. shell: alpine.sh --root {0}
  101. build_darwin:
  102. runs-on: macos-latest
  103. steps:
  104. - uses: actions/checkout@v4
  105. - name: Compile and Test
  106. run: |
  107. python cmake_build.py
  108. python scripts/run_tests.py
  109. - name: Benchmark
  110. run: python scripts/run_tests.py benchmark
  111. - run: |
  112. python amalgamate.py
  113. cd plugins/macos/pocketpy
  114. mkdir output
  115. xcodebuild clean build CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO
  116. cp -r build/Release/pocketpy.bundle output
  117. - uses: actions/upload-artifact@v4
  118. with:
  119. name: macos
  120. path: plugins/macos/pocketpy/output
  121. build_android:
  122. runs-on: ubuntu-latest
  123. steps:
  124. - uses: actions/checkout@v4
  125. - uses: nttld/setup-ndk@v1
  126. id: setup-ndk
  127. with:
  128. ndk-version: r23
  129. local-cache: false
  130. add-to-path: false
  131. - name: Compile Shared Library
  132. run: |
  133. bash build_android.sh arm64-v8a
  134. bash build_android.sh armeabi-v7a
  135. bash build_android.sh x86_64
  136. mkdir -p output/arm64-v8a
  137. mkdir -p output/armeabi-v7a
  138. mkdir -p output/x86_64
  139. cp build/android/arm64-v8a/libpocketpy.so output/arm64-v8a
  140. cp build/android/armeabi-v7a/libpocketpy.so output/armeabi-v7a
  141. cp build/android/x86_64/libpocketpy.so output/x86_64
  142. env:
  143. ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
  144. - uses: actions/upload-artifact@v4
  145. with:
  146. name: android
  147. path: output
  148. build_ios:
  149. runs-on: macos-latest
  150. steps:
  151. - uses: actions/checkout@v4
  152. - name: Compile Frameworks
  153. run: |
  154. git clone https://github.com/leetal/ios-cmake --depth 1 ~/ios-cmake
  155. bash build_ios.sh
  156. mkdir -p output
  157. cp -r build/pocketpy.xcframework output/pocketpy.xcframework
  158. - uses: actions/upload-artifact@v4
  159. with:
  160. name: ios
  161. path: output
  162. merge:
  163. runs-on: ubuntu-latest
  164. needs: [ build_win32, build_linux, build_darwin, build_android, build_ios ]
  165. steps:
  166. - name: "Create output directory"
  167. run: "mkdir $GITHUB_WORKSPACE/output"
  168. - name: "Merge win32"
  169. uses: actions/download-artifact@v4.1.7
  170. with:
  171. name: windows
  172. path: $GITHUB_WORKSPACE/output/windows
  173. - name: "Merge linux"
  174. uses: actions/download-artifact@v4.1.7
  175. with:
  176. name: linux
  177. path: $GITHUB_WORKSPACE/output/linux
  178. - name: "Merge darwin"
  179. uses: actions/download-artifact@v4.1.7
  180. with:
  181. name: macos
  182. path: $GITHUB_WORKSPACE/output/macos
  183. - name: "Merge android"
  184. uses: actions/download-artifact@v4.1.7
  185. with:
  186. name: android
  187. path: $GITHUB_WORKSPACE/output/android
  188. - name: "Merge ios"
  189. uses: actions/download-artifact@v4.1.7
  190. with:
  191. name: ios
  192. path: $GITHUB_WORKSPACE/output/ios
  193. - name: "Upload merged artifact"
  194. uses: actions/upload-artifact@v4.3.3
  195. with:
  196. name: all-in-one
  197. path: $GITHUB_WORKSPACE/output