compilation_on_android_ubuntu.yml 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  1. # Copyright (C) 2019 Intel Corporation. All rights reserved.
  2. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  3. name: compilation on android, ubuntu-20.04, ubuntu-22.04
  4. on:
  5. # will be triggered on PR events
  6. pull_request:
  7. types:
  8. - opened
  9. - synchronize
  10. paths:
  11. - ".github/**"
  12. - "build-scripts/**"
  13. - "core/**"
  14. - "!core/deps/**"
  15. - "product-mini/**"
  16. - "samples/**"
  17. - "!samples/workload/**"
  18. - "tests/wamr-test-suites/**"
  19. - "wamr-compiler/**"
  20. - "wamr-sdk/**"
  21. # will be triggered on push events
  22. push:
  23. branches:
  24. - main
  25. - "dev/**"
  26. paths:
  27. - ".github/**"
  28. - "build-scripts/**"
  29. - "core/**"
  30. - "!core/deps/**"
  31. - "product-mini/**"
  32. - "samples/**"
  33. - "!samples/workload/**"
  34. - "tests/wamr-test-suites/**"
  35. - "wamr-compiler/**"
  36. - "wamr-sdk/**"
  37. # allow to be triggered manually
  38. workflow_dispatch:
  39. # Cancel any in-flight jobs for the same PR/branch so there's only one active
  40. # at a time
  41. concurrency:
  42. group: ${{ github.workflow }}-${{ github.ref }}
  43. cancel-in-progress: true
  44. env:
  45. # For BUILD
  46. AOT_BUILD_OPTIONS: " -DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_FAST_JIT=0 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
  47. CLASSIC_INTERP_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=0 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_JIT=0 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
  48. FAST_INTERP_BUILD_OPTIONS: " -DWAMR_BUILD_AOT=0 -DWAMR_BUILD_FAST_INTERP=1 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_JIT=0 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
  49. FAST_JIT_BUILD_OPTIONS: " -DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
  50. LLVM_LAZY_JIT_BUILD_OPTIONS: " -DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_FAST_JIT=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=1"
  51. LLVM_EAGER_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_FAST_JIT=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=0"
  52. MULTI_TIER_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=1"
  53. # For Spec Test
  54. DEFAULT_TEST_OPTIONS: "-s spec -b -P"
  55. MULTI_MODULES_TEST_OPTIONS: "-s spec -b -M -P"
  56. SIMD_TEST_OPTIONS: "-s spec -b -S -P"
  57. THREADS_TEST_OPTIONS: "-s spec -b -p -P"
  58. X86_32_TARGET_TEST_OPTIONS: "-m x86_32 -P"
  59. WASI_TEST_OPTIONS: "-s wasi_certification -w"
  60. jobs:
  61. build_llvm_libraries_on_ubuntu_2004:
  62. uses: ./.github/workflows/build_llvm_libraries.yml
  63. with:
  64. os: "ubuntu-20.04"
  65. arch: "X86"
  66. build_llvm_libraries_on_ubuntu_2204:
  67. uses: ./.github/workflows/build_llvm_libraries.yml
  68. with:
  69. os: "ubuntu-22.04"
  70. arch: "X86"
  71. build_wamrc:
  72. needs:
  73. [build_llvm_libraries_on_ubuntu_2004, build_llvm_libraries_on_ubuntu_2204]
  74. runs-on: ${{ matrix.os }}
  75. strategy:
  76. matrix:
  77. include:
  78. - os: ubuntu-20.04
  79. llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2004.outputs.cache_key }}
  80. - os: ubuntu-22.04
  81. llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}
  82. steps:
  83. - name: checkout
  84. uses: actions/checkout@v3
  85. # since jobs.id can't contain the dot character
  86. # it is hard to use `format` to assemble the cache key
  87. - name: Get LLVM libraries
  88. id: retrieve_llvm_libs
  89. uses: actions/cache@v3
  90. with:
  91. path: |
  92. ./core/deps/llvm/build/bin
  93. ./core/deps/llvm/build/include
  94. ./core/deps/llvm/build/lib
  95. ./core/deps/llvm/build/libexec
  96. ./core/deps/llvm/build/share
  97. key: ${{ matrix.llvm_cache_key }}
  98. - name: Quit if cache miss
  99. if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true'
  100. run: echo "::error::can not get prebuilt llvm libraries" && exit 1
  101. - name: Build wamrc
  102. run: |
  103. mkdir build && cd build
  104. cmake ..
  105. cmake --build . --config Release --parallel 4
  106. working-directory: wamr-compiler
  107. build_iwasm:
  108. needs:
  109. [build_llvm_libraries_on_ubuntu_2004, build_llvm_libraries_on_ubuntu_2204]
  110. runs-on: ${{ matrix.os }}
  111. strategy:
  112. matrix:
  113. make_options_run_mode: [
  114. # Running mode
  115. $AOT_BUILD_OPTIONS,
  116. $CLASSIC_INTERP_BUILD_OPTIONS,
  117. $FAST_INTERP_BUILD_OPTIONS,
  118. $FAST_JIT_BUILD_OPTIONS,
  119. $LLVM_LAZY_JIT_BUILD_OPTIONS,
  120. $LLVM_EAGER_JIT_BUILD_OPTIONS,
  121. $MULTI_TIER_JIT_BUILD_OPTIONS,
  122. ]
  123. make_options_feature: [
  124. # Features
  125. "-DWAMR_BUILD_CUSTOM_NAME_SECTION=1",
  126. "-DWAMR_BUILD_DEBUG_AOT=1",
  127. "-DWAMR_BUILD_DEBUG_INTERP=1",
  128. "-DWAMR_BUILD_DUMP_CALL_STACK=1",
  129. "-DWAMR_BUILD_LIB_PTHREAD=1",
  130. "-DWAMR_BUILD_LOAD_CUSTOM_SECTION=1",
  131. "-DWAMR_BUILD_MINI_LOADER=1",
  132. "-DWAMR_BUILD_MEMORY_PROFILING=1",
  133. "-DWAMR_BUILD_MULTI_MODULE=1",
  134. "-DWAMR_BUILD_PERF_PROFILING=1",
  135. "-DWAMR_BUILD_REF_TYPES=1",
  136. "-DWAMR_BUILD_SIMD=1",
  137. "-DWAMR_BUILD_TAIL_CALL=1",
  138. "-DWAMR_DISABLE_HW_BOUND_CHECK=1",
  139. ]
  140. os: [ubuntu-20.04, ubuntu-22.04]
  141. platform: [android, linux]
  142. exclude:
  143. # uncompatiable feature and platform
  144. # uncompatiable mode and feature
  145. # MULTI_MODULE only on INTERP mode
  146. - make_options_run_mode: $AOT_BUILD_OPTIONS
  147. make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
  148. - make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
  149. make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
  150. - make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
  151. make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
  152. - make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
  153. make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
  154. - make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
  155. make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
  156. # SIMD only on JIT/AOT mode
  157. - make_options_run_mode: $CLASSIC_INTERP_BUILD_OPTIONS
  158. make_options_feature: "-DWAMR_BUILD_SIMD=1"
  159. - make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
  160. make_options_feature: "-DWAMR_BUILD_SIMD=1"
  161. # DEBUG_INTERP only on CLASSIC INTERP mode
  162. - make_options_run_mode: $AOT_BUILD_OPTIONS
  163. make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
  164. - make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
  165. make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
  166. - make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
  167. make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
  168. - make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
  169. make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
  170. - make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
  171. make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
  172. - make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
  173. make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
  174. # DEBUG_AOT only on JIT/AOT mode
  175. - make_options_run_mode: $CLASSIC_INTERP_BUILD_OPTIONS
  176. make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
  177. - make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
  178. make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
  179. # TODO: DEBUG_AOT on JIT
  180. - make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
  181. make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
  182. - make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
  183. make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
  184. - make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
  185. make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
  186. - make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
  187. make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
  188. # MINI_LOADER only on INTERP mode
  189. - make_options_run_mode: $AOT_BUILD_OPTIONS
  190. make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
  191. - make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
  192. make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
  193. - make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
  194. make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
  195. - make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
  196. make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
  197. - make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
  198. make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
  199. # Fast-JIT and Multi-Tier-JIT mode don't support android(X86-32)
  200. - make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
  201. platform: android
  202. - make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
  203. platform: android
  204. # only test andorid on ubuntu latest
  205. - os: ubuntu-20.04
  206. platform: android
  207. include:
  208. - os: ubuntu-20.04
  209. llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2004.outputs.cache_key }}
  210. - os: ubuntu-22.04
  211. llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}
  212. steps:
  213. - name: checkout
  214. uses: actions/checkout@v3
  215. # only download llvm cache when needed
  216. - name: Get LLVM libraries
  217. id: retrieve_llvm_libs
  218. if: endsWith(matrix.make_options_run_mode, '_JIT_BUILD_OPTIONS')
  219. uses: actions/cache@v3
  220. with:
  221. path: |
  222. ./core/deps/llvm/build/bin
  223. ./core/deps/llvm/build/include
  224. ./core/deps/llvm/build/lib
  225. ./core/deps/llvm/build/libexec
  226. ./core/deps/llvm/build/share
  227. key: ${{ matrix.llvm_cache_key }}
  228. - name: Quit if cache miss
  229. if: endsWith(matrix.make_options_run_mode, '_JIT_BUILD_OPTIONS') && (steps.retrieve_llvm_libs.outputs.cache-hit != 'true')
  230. run: echo "::error::can not get prebuilt llvm libraries" && exit 1
  231. - name: Build iwasm
  232. run: |
  233. mkdir build && cd build
  234. cmake .. ${{ matrix.make_options_run_mode }} ${{ matrix.make_options_feature }}
  235. cmake --build . --config Release --parallel 4
  236. working-directory: product-mini/platforms/${{ matrix.platform }}
  237. build_samples_wasm_c_api:
  238. needs:
  239. [
  240. build_iwasm,
  241. build_llvm_libraries_on_ubuntu_2004,
  242. build_llvm_libraries_on_ubuntu_2204,
  243. build_wamrc,
  244. ]
  245. runs-on: ${{ matrix.os }}
  246. strategy:
  247. matrix:
  248. make_options: [
  249. # Running mode
  250. $AOT_BUILD_OPTIONS,
  251. $CLASSIC_INTERP_BUILD_OPTIONS,
  252. $FAST_INTERP_BUILD_OPTIONS,
  253. $FAST_JIT_BUILD_OPTIONS,
  254. $LLVM_LAZY_JIT_BUILD_OPTIONS,
  255. $LLVM_EAGER_JIT_BUILD_OPTIONS,
  256. $MULTI_TIER_JIT_BUILD_OPTIONS,
  257. ]
  258. os: [ubuntu-20.04, ubuntu-22.04]
  259. wasi_sdk_release:
  260. [
  261. "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-19/wasi-sdk-19.0-linux.tar.gz",
  262. ]
  263. wabt_release:
  264. [
  265. "https://github.com/WebAssembly/wabt/releases/download/1.0.31/wabt-1.0.31-ubuntu.tar.gz",
  266. ]
  267. include:
  268. - os: ubuntu-20.04
  269. llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2004.outputs.cache_key }}
  270. - os: ubuntu-22.04
  271. llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}
  272. steps:
  273. - name: checkout
  274. uses: actions/checkout@v3
  275. - name: Get LLVM libraries
  276. id: retrieve_llvm_libs
  277. if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS'))
  278. uses: actions/cache@v3
  279. with:
  280. path: |
  281. ./core/deps/llvm/build/bin
  282. ./core/deps/llvm/build/include
  283. ./core/deps/llvm/build/lib
  284. ./core/deps/llvm/build/libexec
  285. ./core/deps/llvm/build/share
  286. key: ${{ matrix.llvm_cache_key }}
  287. - name: Quit if cache miss
  288. if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS')) && (steps.retrieve_llvm_libs.outputs.cache-hit != 'true')
  289. run: echo "::error::can not get prebuilt llvm libraries" && exit 1
  290. - name: download and install wabt
  291. run: |
  292. cd /opt
  293. sudo wget ${{ matrix.wabt_release }}
  294. sudo tar -xzf wabt-1.0.31-*.tar.gz
  295. sudo mv wabt-1.0.31 wabt
  296. - name: Build wamrc
  297. if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS'))
  298. run: |
  299. mkdir build && cd build
  300. cmake ..
  301. cmake --build . --config Release --parallel 4
  302. working-directory: wamr-compiler
  303. - name: Build Sample [wasm-c-api]
  304. run: |
  305. cmake -S . -B build ${{ matrix.make_options }}
  306. cmake --build build --config Release --parallel 4
  307. ctest --test-dir build
  308. working-directory: samples/wasm-c-api
  309. build_samples_others:
  310. needs: [build_iwasm]
  311. runs-on: ${{ matrix.os }}
  312. strategy:
  313. matrix:
  314. os: [ubuntu-20.04, ubuntu-22.04]
  315. include:
  316. - os: ubuntu-20.04
  317. wasi_sdk_release: "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-19/wasi-sdk-19.0-linux.tar.gz"
  318. wabt_release: "https://github.com/WebAssembly/wabt/releases/download/1.0.31/wabt-1.0.31-ubuntu.tar.gz"
  319. - os: ubuntu-22.04
  320. wasi_sdk_release: "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-19/wasi-sdk-19.0-linux.tar.gz"
  321. wabt_release: "https://github.com/WebAssembly/wabt/releases/download/1.0.31/wabt-1.0.31-ubuntu.tar.gz"
  322. steps:
  323. - name: checkout
  324. uses: actions/checkout@v3
  325. - name: download and install wasi-sdk
  326. run: |
  327. cd /opt
  328. sudo wget ${{ matrix.wasi_sdk_release }}
  329. sudo tar -xzf wasi-sdk-*.tar.gz
  330. sudo mv wasi-sdk-19.0 wasi-sdk
  331. - name: download and install wabt
  332. run: |
  333. cd /opt
  334. sudo wget ${{ matrix.wabt_release }}
  335. sudo tar -xzf wabt-1.0.31-*.tar.gz
  336. sudo mv wabt-1.0.31 wabt
  337. - name: build wasi-libc (needed for wasi-threads)
  338. run: |
  339. mkdir wasi-libc
  340. cd wasi-libc
  341. git init
  342. # "Rename thread_spawn import" commit on main branch
  343. git fetch https://github.com/WebAssembly/wasi-libc \
  344. 8f5275796a82f8ecfd0833a4f3f444fa37ed4546
  345. git checkout FETCH_HEAD
  346. make -j \
  347. AR=/opt/wasi-sdk/bin/llvm-ar \
  348. NM=/opt/wasi-sdk/bin/llvm-nm \
  349. CC=/opt/wasi-sdk/bin/clang \
  350. THREAD_MODEL=posix
  351. working-directory: core/deps
  352. - name: Build Sample [basic]
  353. run: |
  354. cd samples/basic
  355. ./build.sh
  356. ./run.sh
  357. - name: Build Sample [file]
  358. run: |
  359. cd samples/file
  360. mkdir build && cd build
  361. cmake ..
  362. cmake --build . --config Release --parallel 4
  363. ./src/iwasm -f wasm-app/file.wasm -d .
  364. - name: Build Sample [multi-thread]
  365. run: |
  366. cd samples/multi-thread
  367. mkdir build && cd build
  368. cmake ..
  369. cmake --build . --config Release --parallel 4
  370. ./iwasm wasm-apps/test.wasm
  371. - name: Build Sample [multi-module]
  372. run: |
  373. cd samples/multi-module
  374. mkdir build && cd build
  375. cmake ..
  376. cmake --build . --config Release --parallel 4
  377. ./multi_module
  378. - name: Build Sample [spawn-thread]
  379. run: |
  380. cd samples/spawn-thread
  381. mkdir build && cd build
  382. cmake ..
  383. cmake --build . --config Release --parallel 4
  384. ./spawn_thread
  385. - name: Build Sample [ref-types]
  386. run: |
  387. cd samples/ref-types
  388. mkdir build && cd build
  389. cmake ..
  390. cmake --build . --config Release --parallel 4
  391. ./hello
  392. - name: Build Sample [simple]
  393. run: |
  394. ./build.sh -p host-interp
  395. python3 ./sample_test_run.py $(pwd)/out
  396. exit $?
  397. working-directory: ./samples/simple
  398. - name: Build Sample [wasi-threads]
  399. run: |
  400. cd samples/wasi-threads
  401. mkdir build && cd build
  402. cmake -DWASI_SYSROOT=`pwd`/../../../core/deps/wasi-libc/sysroot ..
  403. cmake --build . --config Release --parallel 4
  404. ./iwasm wasm-apps/no_pthread.wasm
  405. test:
  406. needs: [build_iwasm, build_llvm_libraries_on_ubuntu_2004, build_wamrc]
  407. runs-on: ubuntu-20.04
  408. strategy:
  409. matrix:
  410. running_mode:
  411. [
  412. "classic-interp",
  413. "fast-interp",
  414. "jit",
  415. "aot",
  416. "fast-jit",
  417. "multi-tier-jit",
  418. ]
  419. test_option:
  420. [
  421. $DEFAULT_TEST_OPTIONS,
  422. $MULTI_MODULES_TEST_OPTIONS,
  423. $SIMD_TEST_OPTIONS,
  424. $THREADS_TEST_OPTIONS,
  425. $WASI_TEST_OPTIONS,
  426. ]
  427. wasi_sdk_release:
  428. [
  429. "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-19/wasi-sdk-19.0-linux.tar.gz",
  430. ]
  431. llvm_cache_key:
  432. ["${{ needs.build_llvm_libraries_on_ubuntu_2004.outputs.cache_key }}"]
  433. exclude:
  434. # uncompatiable modes and features
  435. # classic-interp and fast-interp don't support simd
  436. - running_mode: "classic-interp"
  437. test_option: $SIMD_TEST_OPTIONS
  438. - running_mode: "fast-interp"
  439. test_option: $SIMD_TEST_OPTIONS
  440. # aot and jit don't support multi module
  441. - running_mode: "aot"
  442. test_option: $MULTI_MODULES_TEST_OPTIONS
  443. - running_mode: "jit"
  444. test_option: $MULTI_MODULES_TEST_OPTIONS
  445. # fast-jit doesn't support multi module, simd, and threads
  446. - running_mode: "fast-jit"
  447. test_option: $MULTI_MODULES_TEST_OPTIONS
  448. - running_mode: "fast-jit"
  449. test_option: $SIMD_TEST_OPTIONS
  450. - running_mode: "fast-jit"
  451. test_option: $THREADS_TEST_OPTIONS
  452. - running_mode: "fast-jit"
  453. test_option: $WASI_TEST_OPTIONS
  454. # multi-tier-jit doesn't support multi module, simd, and threads
  455. - running_mode: "multi-tier-jit"
  456. test_option: $MULTI_MODULES_TEST_OPTIONS
  457. - running_mode: "multi-tier-jit"
  458. test_option: $SIMD_TEST_OPTIONS
  459. - running_mode: "multi-tier-jit"
  460. test_option: $THREADS_TEST_OPTIONS
  461. - running_mode: "multi-tier-jit"
  462. test_option: $WASI_TEST_OPTIONS
  463. steps:
  464. - name: checkout
  465. uses: actions/checkout@v3
  466. - name: download and install wasi-sdk
  467. if: matrix.test_option == '$WASI_TEST_OPTIONS'
  468. run: |
  469. cd /opt
  470. sudo wget ${{ matrix.wasi_sdk_release }}
  471. sudo tar -xzf wasi-sdk-*.tar.gz
  472. sudo mv wasi-sdk-19.0 wasi-sdk
  473. - name: build wasi-libc (needed for wasi-threads)
  474. if: matrix.test_option == '$WASI_TEST_OPTIONS'
  475. run: |
  476. mkdir wasi-libc
  477. cd wasi-libc
  478. git init
  479. # "Rename thread_spawn import" commit on main branch
  480. git fetch https://github.com/WebAssembly/wasi-libc \
  481. 8f5275796a82f8ecfd0833a4f3f444fa37ed4546
  482. git checkout FETCH_HEAD
  483. make \
  484. AR=/opt/wasi-sdk/bin/llvm-ar \
  485. NM=/opt/wasi-sdk/bin/llvm-nm \
  486. CC=/opt/wasi-sdk/bin/clang \
  487. THREAD_MODEL=posix
  488. working-directory: core/deps
  489. - name: set env variable(if llvm are used)
  490. if: matrix.running_mode == 'aot' || matrix.running_mode == 'jit' || matrix.running_mode == 'multi-tier-jit'
  491. run: echo "USE_LLVM=true" >> $GITHUB_ENV
  492. - name: set env variable(if x86_32 test needed)
  493. if: >
  494. (matrix.test_option == '$DEFAULT_TEST_OPTIONS' || matrix.test_option == '$THREADS_TEST_OPTIONS'
  495. || matrix.test_option == '$WASI_TEST_OPTIONS')
  496. && matrix.running_mode != 'fast-jit' && matrix.running_mode != 'jit' && matrix.running_mode != 'multi-tier-jit'
  497. run: echo "TEST_ON_X86_32=true" >> $GITHUB_ENV
  498. #only download llvm libraries in jit and aot mode
  499. - name: Get LLVM libraries
  500. if: env.USE_LLVM == 'true'
  501. id: retrieve_llvm_libs
  502. uses: actions/cache@v3
  503. with:
  504. path: |
  505. ./core/deps/llvm/build/bin
  506. ./core/deps/llvm/build/include
  507. ./core/deps/llvm/build/lib
  508. ./core/deps/llvm/build/libexec
  509. ./core/deps/llvm/build/share
  510. key: ${{ matrix.llvm_cache_key }}
  511. - name: Quit if cache miss
  512. if: env.USE_LLVM == 'true' && steps.retrieve_llvm_libs.outputs.cache-hit != 'true'
  513. run: echo "::error::can not get prebuilt llvm libraries" && exit 1
  514. - name: install jq JSON processor
  515. if: matrix.running_mode == 'aot' && matrix.test_option == '$WASI_TEST_OPTIONS'
  516. run: sudo apt-get update && sudo apt install -y jq
  517. - name: Build WASI thread tests
  518. if: matrix.test_option == '$WASI_TEST_OPTIONS'
  519. run: WASI_SYSROOT=../../../../../core/deps/wasi-libc/sysroot bash build.sh
  520. working-directory: ./core/iwasm/libraries/lib-wasi-threads/test/
  521. - name: build socket api tests
  522. if: matrix.test_option == '$WASI_TEST_OPTIONS'
  523. run: WASI_SYSROOT=../../../../../core/deps/wasi-libc/sysroot bash build.sh
  524. working-directory: ./core/iwasm/libraries/lib-socket/test/
  525. - name: run tests
  526. timeout-minutes: 10
  527. run: ./test_wamr.sh ${{ matrix.test_option }} -t ${{ matrix.running_mode }}
  528. working-directory: ./tests/wamr-test-suites
  529. #only install x32 support libraries when to run x86_32 cases
  530. - name: install x32 support libraries
  531. if: env.TEST_ON_X86_32 == 'true'
  532. run:
  533. # Add another apt repository as some packages cannot
  534. # be downloaded with the github default repository
  535. sudo curl -sSL https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc &&
  536. sudo apt-add-repository https://packages.microsoft.com/ubuntu/20.04/prod &&
  537. sudo apt-get update &&
  538. sudo apt install -y g++-multilib lib32gcc-9-dev
  539. - name: run tests x86_32
  540. timeout-minutes: 10
  541. if: env.TEST_ON_X86_32 == 'true'
  542. run: ./test_wamr.sh ${{ env.X86_32_TARGET_TEST_OPTIONS }} ${{ matrix.test_option }} -t ${{ matrix.running_mode }}
  543. working-directory: ./tests/wamr-test-suites