main.yml 5.7 KB

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