main.yml 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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: recursive
  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 /experimental:c11atomics /utf-8 /Ox /fp:precise /DPK_ENABLE_DETERMINISM=1 /I. pocketpy.c main.c /link Ws2_32.lib /out:pkpy.exe
  27. if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
  28. cl.exe /std:c11 /experimental:c11atomics /utf-8 /Ox /fp:precise /I../include pocketpy.c ../src2/test_dmath.c /link Ws2_32.lib /out:test_dmath.exe
  29. if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
  30. ./test_dmath.exe --cases ../tests/dmath/cases
  31. if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
  32. cd ..
  33. ./amalgamated/pkpy.exe tests/930_dmath.py
  34. if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
  35. ./amalgamated/pkpy.exe tests/932_dmath_consumers.py
  36. build_win32:
  37. runs-on: windows-latest
  38. steps:
  39. - uses: actions/checkout@v4
  40. with:
  41. submodules: recursive
  42. - uses: ilammy/msvc-dev-cmd@v1
  43. - name: Compile
  44. shell: bash
  45. run: |
  46. mkdir -p output/x86_64
  47. python cmake_build.py Release -DPK_BUILD_MODULE_LZ4=ON -DPK_BUILD_MODULE_CUTE_PNG=ON -DPK_BUILD_MODULE_MSGPACK=ON -DPK_BUILD_MATH_TESTS=ON
  48. ctest --test-dir build -C Release --output-on-failure
  49. cp main.exe output/x86_64
  50. cp pocketpy.dll output/x86_64
  51. - uses: actions/upload-artifact@v4
  52. with:
  53. name: windows
  54. path: output
  55. - name: Unit Test
  56. run: python scripts/run_tests.py
  57. - name: Benchmark
  58. run: python scripts/run_tests.py benchmark
  59. build_linux:
  60. runs-on: ubuntu-22.04
  61. steps:
  62. - uses: actions/checkout@v4
  63. with:
  64. submodules: recursive
  65. - name: Setup Clang
  66. uses: egor-tensin/setup-clang@v1
  67. with:
  68. version: 19
  69. platform: x64
  70. - name: Run Sanitizers
  71. run: |
  72. sudo apt-get install -y libclang-rt-19-dev
  73. bash build_g.sh
  74. bash run_tests.sh
  75. rm -rf ./main
  76. clang -std=c11 -Iinclude -O1 -g -fno-fast-math -ffp-contract=off -fsanitize=undefined,float-cast-overflow -fno-sanitize-recover=all src/common/dmath.c src/common/dmath_zig.c src/common/dmath_openlibm.c src2/test_dmath.c -lm -o test_dmath_sanitized
  77. ./test_dmath_sanitized
  78. - name: Run Script Check
  79. run: |
  80. python scripts/check_pragma_once.py include
  81. python scripts/check_undef.py src
  82. python scripts/dmath/generate.py --check
  83. - name: Unit Test with Coverage
  84. run: bash run_tests.sh
  85. - name: Upload coverage reports to Codecov
  86. uses: codecov/codecov-action@v4
  87. with:
  88. token: ${{ secrets.CODECOV_TOKEN }}
  89. directory: .coverage
  90. if: github.ref == 'refs/heads/main'
  91. - name: Compile and Test
  92. run: |
  93. python scripts/check_pragma_once.py include
  94. mkdir -p output/x86_64
  95. python cmake_build.py Release -DPK_BUILD_MODULE_LZ4=ON -DPK_BUILD_MODULE_CUTE_PNG=ON -DPK_BUILD_MODULE_MSGPACK=ON -DPK_BUILD_MATH_TESTS=ON
  96. ctest --test-dir build -C Release --output-on-failure
  97. python scripts/run_tests.py
  98. cp main output/x86_64
  99. cp libpocketpy.so output/x86_64
  100. env:
  101. CC: clang
  102. - uses: actions/upload-artifact@v4
  103. with:
  104. name: linux
  105. path: output
  106. - name: Benchmark
  107. run: python scripts/run_tests.py benchmark
  108. build_darwin:
  109. runs-on: macos-latest
  110. steps:
  111. - uses: actions/checkout@v4
  112. with:
  113. submodules: recursive
  114. - name: Compile and Test
  115. run: |
  116. python cmake_build.py Release -DPK_BUILD_MODULE_LZ4=ON -DPK_BUILD_MODULE_CUTE_PNG=ON -DPK_BUILD_MODULE_MSGPACK=ON -DPK_BUILD_MATH_TESTS=ON
  117. ctest --test-dir build -C Release --output-on-failure
  118. python scripts/run_tests.py
  119. - name: Benchmark
  120. run: python scripts/run_tests.py benchmark
  121. - name: Test Amalgamated Build
  122. run: python amalgamate.py
  123. build_android_libs:
  124. runs-on: ubuntu-latest
  125. steps:
  126. - uses: actions/checkout@v4
  127. with:
  128. submodules: recursive
  129. - uses: nttld/setup-ndk@v1
  130. id: setup-ndk
  131. with:
  132. ndk-version: r23
  133. local-cache: false
  134. add-to-path: false
  135. - name: Compile Shared Library
  136. run: |
  137. bash build_android_libs.sh arm64-v8a
  138. bash build_android_libs.sh armeabi-v7a
  139. bash build_android_libs.sh x86_64
  140. mkdir -p output/arm64-v8a
  141. mkdir -p output/armeabi-v7a
  142. mkdir -p output/x86_64
  143. cp build/android/arm64-v8a/libpocketpy.so output/arm64-v8a
  144. cp build/android/armeabi-v7a/libpocketpy.so output/armeabi-v7a
  145. cp build/android/x86_64/libpocketpy.so output/x86_64
  146. env:
  147. ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
  148. - uses: actions/upload-artifact@v4
  149. with:
  150. name: android
  151. path: output
  152. build_darwin_libs:
  153. runs-on: macos-latest
  154. steps:
  155. - uses: actions/checkout@v4
  156. with:
  157. submodules: recursive
  158. - name: Compile Frameworks
  159. run: |
  160. bash build_darwin_libs.sh
  161. mkdir -p output
  162. cp build/libpocketpy.a output/libpocketpy.a
  163. - uses: actions/upload-artifact@v4
  164. with:
  165. name: darwin
  166. path: output
  167. build_ios_libs:
  168. runs-on: macos-latest
  169. steps:
  170. - uses: actions/checkout@v4
  171. with:
  172. submodules: recursive
  173. - name: Compile Frameworks
  174. run: |
  175. bash build_ios_libs.sh
  176. mkdir -p output
  177. cp -r build/pocketpy.xcframework output/pocketpy.xcframework
  178. - uses: actions/upload-artifact@v4
  179. with:
  180. name: ios
  181. path: output
  182. build_linux_multiarch:
  183. runs-on: ubuntu-latest
  184. strategy:
  185. matrix:
  186. arch: [x86, aarch64, armv7]
  187. steps:
  188. - uses: actions/checkout@v4
  189. with:
  190. submodules: recursive
  191. - name: Setup Alpine Linux for ${{ matrix.arch }}
  192. uses: jirutka/setup-alpine@v1
  193. with:
  194. arch: ${{ matrix.arch }}
  195. packages: gcc g++ make cmake libc-dev linux-headers python3 git
  196. - name: Build and Test
  197. run: |
  198. echo "Building for architecture: ${{ matrix.arch }}"
  199. uname -m
  200. python -c "import struct; print(8 * struct.calcsize('P'))"
  201. python cmake_build.py Release -DPK_BUILD_MATH_TESTS=ON
  202. ctest --test-dir build -C Release --output-on-failure
  203. python scripts/run_tests.py
  204. shell: alpine.sh --root {0}
  205. merge:
  206. runs-on: ubuntu-latest
  207. needs: [ build_win32, build_linux, build_darwin, build_android_libs, build_darwin_libs, build_ios_libs ]
  208. steps:
  209. - name: "Create output directory"
  210. run: "mkdir $GITHUB_WORKSPACE/output"
  211. - name: "Merge win32"
  212. uses: actions/download-artifact@v4.1.7
  213. with:
  214. name: windows
  215. path: $GITHUB_WORKSPACE/output/windows
  216. - name: "Merge linux"
  217. uses: actions/download-artifact@v4.1.7
  218. with:
  219. name: linux
  220. path: $GITHUB_WORKSPACE/output/linux
  221. - name: "Merge android"
  222. uses: actions/download-artifact@v4.1.7
  223. with:
  224. name: android
  225. path: $GITHUB_WORKSPACE/output/android
  226. - name: "Merge darwin"
  227. uses: actions/download-artifact@v4.1.7
  228. with:
  229. name: darwin
  230. path: $GITHUB_WORKSPACE/output/darwin
  231. - name: "Merge ios"
  232. uses: actions/download-artifact@v4.1.7
  233. with:
  234. name: ios
  235. path: $GITHUB_WORKSPACE/output/ios
  236. - name: "Upload merged artifact"
  237. uses: actions/upload-artifact@v4.3.3
  238. with:
  239. name: all-in-one
  240. path: $GITHUB_WORKSPACE/output