main.yml 5.7 KB

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