main.yml 5.6 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. with:
  19. submodules: true
  20. - uses: ilammy/msvc-dev-cmd@v1
  21. - name: Compile
  22. shell: powershell
  23. run: |
  24. python amalgamate.py
  25. cd amalgamated
  26. cl.exe /std:c11 /utf-8 /Ox /I. pocketpy.c main.c /link /out:pkpy.exe
  27. build_win32:
  28. runs-on: windows-latest
  29. steps:
  30. - uses: actions/checkout@v4
  31. with:
  32. submodules: true
  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. with:
  54. submodules: true
  55. - name: Setup Clang
  56. uses: egor-tensin/setup-clang@v1
  57. with:
  58. version: 15
  59. platform: x64
  60. - name: Install dependencies
  61. run: sudo apt-get install -y libclang-rt-15-dev
  62. - name: Unit Test with Coverage
  63. run: bash run_tests.sh
  64. - name: Upload coverage reports to Codecov
  65. uses: codecov/codecov-action@v4
  66. with:
  67. token: ${{ secrets.CODECOV_TOKEN }}
  68. directory: .coverage
  69. if: github.ref == 'refs/heads/main'
  70. - name: Compile and Test
  71. run: |
  72. mkdir -p output/x86_64
  73. python cmake_build.py
  74. python scripts/run_tests.py
  75. cp main output/x86_64
  76. cp libpocketpy.so output/x86_64
  77. env:
  78. CC: clang
  79. - uses: actions/upload-artifact@v4
  80. with:
  81. name: linux
  82. path: output
  83. - name: Benchmark
  84. run: python scripts/run_tests.py benchmark
  85. build_linux_x86:
  86. runs-on: ubuntu-latest
  87. steps:
  88. - uses: actions/checkout@v4
  89. with:
  90. submodules: true
  91. - name: Setup Alpine Linux for aarch64
  92. uses: jirutka/setup-alpine@v1
  93. with:
  94. arch: x86
  95. packages: gcc g++ make cmake libc-dev linux-headers python3
  96. - name: Build and Test
  97. run: |
  98. uname -m
  99. python cmake_build.py
  100. python scripts/run_tests.py
  101. python scripts/run_tests.py benchmark
  102. shell: alpine.sh --root {0}
  103. build_darwin:
  104. runs-on: macos-latest
  105. steps:
  106. - uses: actions/checkout@v4
  107. with:
  108. submodules: true
  109. - name: Compile and Test
  110. run: |
  111. python cmake_build.py
  112. python scripts/run_tests.py
  113. - name: Benchmark
  114. run: python scripts/run_tests.py benchmark
  115. - name: Test Amalgamated Build
  116. run: python amalgamate.py
  117. build_android:
  118. runs-on: ubuntu-latest
  119. steps:
  120. - uses: actions/checkout@v4
  121. with:
  122. submodules: true
  123. - uses: nttld/setup-ndk@v1
  124. id: setup-ndk
  125. with:
  126. ndk-version: r23
  127. local-cache: false
  128. add-to-path: false
  129. - name: Compile Shared Library
  130. run: |
  131. bash build_android.sh arm64-v8a
  132. bash build_android.sh armeabi-v7a
  133. bash build_android.sh x86_64
  134. mkdir -p output/arm64-v8a
  135. mkdir -p output/armeabi-v7a
  136. mkdir -p output/x86_64
  137. cp build/android/arm64-v8a/libpocketpy.so output/arm64-v8a
  138. cp build/android/armeabi-v7a/libpocketpy.so output/armeabi-v7a
  139. cp build/android/x86_64/libpocketpy.so output/x86_64
  140. env:
  141. ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
  142. - uses: actions/upload-artifact@v4
  143. with:
  144. name: android
  145. path: output
  146. build_ios:
  147. runs-on: macos-latest
  148. steps:
  149. - uses: actions/checkout@v4
  150. with:
  151. submodules: true
  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