main.yml 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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 and Test
  65. run: |
  66. mkdir -p output/x86_64
  67. python cmake_build.py
  68. python scripts/run_tests.py
  69. cp main output/x86_64
  70. cp libpocketpy.so output/x86_64
  71. env:
  72. CXX: clang++
  73. CC: clang
  74. - uses: actions/upload-artifact@v4
  75. with:
  76. name: linux
  77. path: output
  78. - name: Benchmark
  79. run: python scripts/run_tests.py benchmark
  80. - name: C Binding Test
  81. run: bash run_c_binding_test.sh
  82. build_linux_x86:
  83. runs-on: ubuntu-latest
  84. steps:
  85. - uses: actions/checkout@v4
  86. - name: Setup Alpine Linux for aarch64
  87. uses: jirutka/setup-alpine@v1
  88. with:
  89. arch: x86
  90. packages: gcc g++ make cmake libc-dev linux-headers python3
  91. - name: Build and Test
  92. run: |
  93. uname -m
  94. python cmake_build.py
  95. python scripts/run_tests.py
  96. python scripts/run_tests.py benchmark
  97. shell: alpine.sh --root {0}
  98. build_darwin:
  99. runs-on: macos-latest
  100. steps:
  101. - uses: actions/checkout@v4
  102. - name: Compile and Test
  103. run: |
  104. python cmake_build.py
  105. python scripts/run_tests.py
  106. - name: Benchmark
  107. run: python scripts/run_tests.py benchmark
  108. # - run: |
  109. # python amalgamate.py
  110. # cd plugins/macos/pocketpy
  111. # mkdir output
  112. # xcodebuild clean build CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO
  113. # cp -r build/Release/pocketpy.bundle output
  114. # - uses: actions/upload-artifact@v4
  115. # with:
  116. # name: macos
  117. # path: plugins/macos/pocketpy/output
  118. build_android:
  119. runs-on: ubuntu-latest
  120. steps:
  121. - uses: actions/checkout@v4
  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. - name: Compile Frameworks
  150. run: |
  151. git clone https://github.com/leetal/ios-cmake --depth 1 ~/ios-cmake
  152. bash build_ios.sh
  153. mkdir -p output
  154. cp -r build/pocketpy.xcframework output/pocketpy.xcframework
  155. - uses: actions/upload-artifact@v4
  156. with:
  157. name: ios
  158. path: output
  159. merge:
  160. runs-on: ubuntu-latest
  161. needs: [ build_win32, build_linux, build_darwin, build_android, build_ios ]
  162. steps:
  163. - name: "Create output directory"
  164. run: "mkdir $GITHUB_WORKSPACE/output"
  165. - name: "Merge win32"
  166. uses: actions/download-artifact@v4.1.7
  167. with:
  168. name: windows
  169. path: $GITHUB_WORKSPACE/output/windows
  170. - name: "Merge linux"
  171. uses: actions/download-artifact@v4.1.7
  172. with:
  173. name: linux
  174. path: $GITHUB_WORKSPACE/output/linux
  175. # - name: "Merge darwin"
  176. # uses: actions/download-artifact@v4.1.7
  177. # with:
  178. # name: macos
  179. # path: $GITHUB_WORKSPACE/output/macos
  180. - name: "Merge android"
  181. uses: actions/download-artifact@v4.1.7
  182. with:
  183. name: android
  184. path: $GITHUB_WORKSPACE/output/android
  185. - name: "Merge ios"
  186. uses: actions/download-artifact@v4.1.7
  187. with:
  188. name: ios
  189. path: $GITHUB_WORKSPACE/output/ios
  190. - name: "Upload merged artifact"
  191. uses: actions/upload-artifact@v4.3.3
  192. with:
  193. name: all-in-one
  194. path: $GITHUB_WORKSPACE/output