main.yml 5.6 KB

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