main.yml 5.6 KB

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