main.yml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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:c11 /utf-8 /Ox /I. pocketpy.c main.c /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. - name: Test Amalgamated Build
  106. run: python amalgamate.py
  107. build_android:
  108. runs-on: ubuntu-latest
  109. steps:
  110. - uses: actions/checkout@v4
  111. - uses: nttld/setup-ndk@v1
  112. id: setup-ndk
  113. with:
  114. ndk-version: r23
  115. local-cache: false
  116. add-to-path: false
  117. - name: Compile Shared Library
  118. run: |
  119. bash build_android.sh arm64-v8a
  120. bash build_android.sh armeabi-v7a
  121. bash build_android.sh x86_64
  122. mkdir -p output/arm64-v8a
  123. mkdir -p output/armeabi-v7a
  124. mkdir -p output/x86_64
  125. cp build/android/arm64-v8a/libpocketpy.so output/arm64-v8a
  126. cp build/android/armeabi-v7a/libpocketpy.so output/armeabi-v7a
  127. cp build/android/x86_64/libpocketpy.so output/x86_64
  128. env:
  129. ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
  130. - uses: actions/upload-artifact@v4
  131. with:
  132. name: android
  133. path: output
  134. build_ios:
  135. runs-on: macos-latest
  136. steps:
  137. - uses: actions/checkout@v4
  138. - name: Compile Frameworks
  139. run: |
  140. git clone https://github.com/leetal/ios-cmake --depth 1 ~/ios-cmake
  141. bash build_ios.sh
  142. mkdir -p output
  143. cp -r build/pocketpy.xcframework output/pocketpy.xcframework
  144. - uses: actions/upload-artifact@v4
  145. with:
  146. name: ios
  147. path: output
  148. merge:
  149. runs-on: ubuntu-latest
  150. needs: [ build_win32, build_linux, build_darwin, build_android, build_ios ]
  151. steps:
  152. - name: "Create output directory"
  153. run: "mkdir $GITHUB_WORKSPACE/output"
  154. - name: "Merge win32"
  155. uses: actions/download-artifact@v4.1.7
  156. with:
  157. name: windows
  158. path: $GITHUB_WORKSPACE/output/windows
  159. - name: "Merge linux"
  160. uses: actions/download-artifact@v4.1.7
  161. with:
  162. name: linux
  163. path: $GITHUB_WORKSPACE/output/linux
  164. # - name: "Merge darwin"
  165. # uses: actions/download-artifact@v4.1.7
  166. # with:
  167. # name: macos
  168. # path: $GITHUB_WORKSPACE/output/macos
  169. - name: "Merge android"
  170. uses: actions/download-artifact@v4.1.7
  171. with:
  172. name: android
  173. path: $GITHUB_WORKSPACE/output/android
  174. - name: "Merge ios"
  175. uses: actions/download-artifact@v4.1.7
  176. with:
  177. name: ios
  178. path: $GITHUB_WORKSPACE/output/ios
  179. - name: "Upload merged artifact"
  180. uses: actions/upload-artifact@v4.3.3
  181. with:
  182. name: all-in-one
  183. path: $GITHUB_WORKSPACE/output