2
0

build.yml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. name: Build
  2. on: [ push, pull_request ]
  3. jobs:
  4. build-mirai-jvm:
  5. name: "JVM (${{ matrix.os }})"
  6. runs-on: ${{ matrix.os }}
  7. strategy:
  8. fail-fast: false
  9. matrix:
  10. os:
  11. - windows-2022
  12. - macos-12
  13. env:
  14. gradleArgs: --scan "-Dmirai.target=jvm;android;!other" "-Pkotlin.compiler.execution.strategy=in-process" "-Dorg.gradle.jvmargs=-Xmx4096m -Dfile.encoding=UTF-8"
  15. isMac: ${{ startsWith(matrix.os, 'macos') }}
  16. isWindows: ${{ startsWith(matrix.os, 'windows') }}
  17. isUbuntu: ${{ startsWith(matrix.os, 'ubuntu') }}
  18. isUnix: ${{ startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'ubuntu') }}
  19. steps:
  20. - uses: actions/checkout@v2
  21. with:
  22. submodules: 'recursive'
  23. - uses: actions/setup-java@v2
  24. with:
  25. distribution: 'temurin'
  26. java-version: '17'
  27. - name: Setup Gradle
  28. uses: gradle/gradle-build-action@v2
  29. - if: ${{ env.isUnix == 'true' }}
  30. run: chmod -R 777 *
  31. - if: ${{ env.isWindows == 'true' }}
  32. name: Setup Memory Environment on Windows
  33. run: >
  34. wmic pagefileset where name="D:\\pagefile.sys" set InitialSize=1024,MaximumSize=9216 &
  35. net stop mongodb
  36. shell: cmd
  37. continue-on-error: true
  38. - name: Clean and download dependencies
  39. run: ./gradlew clean ${{ env.gradleArgs }}
  40. # Build modules separately to save memory
  41. - name: "Compile mirai-core-utils"
  42. run: ./gradlew :mirai-core-utils:compileKotlinJvm :mirai-core-utils:compileKotlinAndroid ${{ env.gradleArgs }}
  43. - name: "Test mirai-core-utils"
  44. run: ./gradlew :mirai-core-utils:jvmTest :mirai-core-utils:androidTest ${{ env.gradleArgs }}
  45. - name: "Check mirai-core-utils Android API Level"
  46. run: ./gradlew :mirai-core-utils:checkAndroidApiLevel ${{ env.gradleArgs }}
  47. - name: "Compile mirai-core-api"
  48. run: ./gradlew :mirai-core-api:compileKotlinJvm :mirai-core-api:compileKotlinAndroid ${{ env.gradleArgs }}
  49. - name: "Test mirai-core-api"
  50. run: ./gradlew :mirai-core-api:jvmTest :mirai-core-api:androidTest ${{ env.gradleArgs }}
  51. - name: "Check mirai-core-api JVM ABI"
  52. run: ./gradlew :mirai-core-api:apiCheckAll ${{ env.gradleArgs }}
  53. - name: "Check mirai-core-api Android API Level"
  54. run: ./gradlew :mirai-core-api:checkAndroidApiLevel ${{ env.gradleArgs }}
  55. - name: "Compile mirai-core"
  56. run: ./gradlew :mirai-core:compileKotlinJvm :mirai-core:compileKotlinAndroid ${{ env.gradleArgs }}
  57. - name: "Test mirai-core"
  58. run: ./gradlew :mirai-core:jvmTest :mirai-core:androidTest ${{ env.gradleArgs }}
  59. - name: "Check mirai-core Android API Level"
  60. run: ./gradlew :mirai-core:checkAndroidApiLevel ${{ env.gradleArgs }}
  61. - name: Upload mirai-core-utils
  62. uses: actions/upload-artifact@v3
  63. with:
  64. name: mirai-core-utils
  65. path: mirai-core-utils/build/libs
  66. - name: Upload mirai-core-api
  67. uses: actions/upload-artifact@v3
  68. with:
  69. name: mirai-core-api
  70. path: mirai-core-api/build/libs
  71. - name: Upload mirai-core
  72. uses: actions/upload-artifact@v3
  73. with:
  74. name: mirai-core
  75. path: mirai-core/build/libs
  76. - name: "Build mirai-core-all"
  77. run: ./gradlew :mirai-core-all:shadowJar ${{ env.gradleArgs }}
  78. - name: Upload mirai-core-all
  79. uses: actions/upload-artifact@v3
  80. with:
  81. name: mirai-core-all
  82. path: mirai-core-all/build/libs
  83. # Console and tools
  84. - name: "Compile mirai-console"
  85. run: ./gradlew :mirai-console:assemble ${{ env.gradleArgs }}
  86. - name: "Test mirai-console"
  87. run: ./gradlew :mirai-console:check ${{ env.gradleArgs }}
  88. - name: "Check JVM ABI"
  89. run: ./gradlew :mirai-console:apiCheckAll ${{ env.gradleArgs }}
  90. - name: "Compile mirai-console integration-test"
  91. run: ./gradlew :mirai-console:check ${{ env.gradleArgs }}
  92. - name: "Test mirai-console integration-test"
  93. run: ./gradlew :mirai-console.integration-test:check ${{ env.gradleArgs }}
  94. - name: "Compile mirai-console-terminal"
  95. run: ./gradlew :mirai-console-terminal:assemble ${{ env.gradleArgs }}
  96. - name: "Test mirai-console-terminal"
  97. run: ./gradlew :mirai-console-terminal:check ${{ env.gradleArgs }}
  98. - name: "Compile mirai-console-gradle"
  99. run: ./gradlew :mirai-console-gradle:assemble ${{ env.gradleArgs }}
  100. - name: "Test mirai-console-gradle"
  101. run: ./gradlew :mirai-console-gradle:check ${{ env.gradleArgs }}
  102. - name: "Compile mirai-console-intellij"
  103. run: ./gradlew :mirai-console-intellij:assemble ${{ env.gradleArgs }}
  104. - name: "Build mirai-console-intellij plugin"
  105. run: ./gradlew :mirai-console-intellij:buildPlugin ${{ env.gradleArgs }}
  106. - name: "Test mirai-console-intellij"
  107. run: ./gradlew :mirai-console-intellij:check ${{ env.gradleArgs }}
  108. - name: "Compile mirai-logging"
  109. run:
  110. ./gradlew
  111. :mirai-logging-log4j2:assemble
  112. :mirai-logging-slf4j:assemble
  113. :mirai-logging-slf4j-logback:assemble
  114. :mirai-logging-slf4j-simple:assemble
  115. ${{ env.gradleArgs }}
  116. - name: "Test mirai-logging"
  117. run:
  118. ./gradlew
  119. :mirai-logging-log4j2:check
  120. :mirai-logging-slf4j:check
  121. :mirai-logging-slf4j-logback:check
  122. :mirai-logging-slf4j-simple:check
  123. ${{ env.gradleArgs }}
  124. - name: Upload mirai-console
  125. uses: actions/upload-artifact@v3
  126. with:
  127. name: mirai-console
  128. path: mirai-console/backend/mirai-console/build/libs
  129. - name: Upload mirai-console-terminal
  130. uses: actions/upload-artifact@v3
  131. with:
  132. name: mirai-console-terminal
  133. path: mirai-console/frontend/mirai-console-terminal/build/libs
  134. - name: Upload mirai-console-compiler-annotations
  135. uses: actions/upload-artifact@v3
  136. with:
  137. name: mirai-console-compiler-annotations
  138. path: mirai-console/tools/mirai-console-compiler-annotations/build/libs
  139. - name: Upload mirai-console-compiler-common
  140. uses: actions/upload-artifact@v3
  141. with:
  142. name: mirai-console-compiler-common
  143. path: mirai-console/tools/mirai-console-compiler-common/build/libs
  144. - name: Upload mirai-console-intellij
  145. uses: actions/upload-artifact@v3
  146. with:
  147. name: mirai-console-intellij
  148. path: mirai-console/tools/intelli-plugin/build/distribution
  149. - name: Upload mirai-logging-log4j2
  150. uses: actions/upload-artifact@v3
  151. with:
  152. name: mirai-logging-log4j2
  153. path: logging/mirai-logging-log4j2/build/libs
  154. - name: Upload mirai-logging-slf4j
  155. uses: actions/upload-artifact@v3
  156. with:
  157. name: mirai-logging-slf4j
  158. path: logging/mirai-logging-slf4j/build/libs
  159. - name: Upload mirai-logging-slf4j-logback
  160. uses: actions/upload-artifact@v3
  161. with:
  162. name: mirai-logging-slf4j-logback
  163. path: logging/mirai-logging-slf4j-logback/build/libs
  164. - name: Upload mirai-logging-slf4j-simple
  165. uses: actions/upload-artifact@v3
  166. with:
  167. name: mirai-logging-slf4j-simple
  168. path: logging/mirai-logging-slf4j-simple/build/libs
  169. build-mirai-all:
  170. name: "Everything (${{ matrix.os }})"
  171. runs-on: ${{ matrix.os }}
  172. strategy:
  173. fail-fast: false
  174. matrix:
  175. os:
  176. - macos-12
  177. env:
  178. gradleArgs: --scan
  179. isMac: ${{ startsWith(matrix.os, 'macos') }}
  180. isWindows: ${{ startsWith(matrix.os, 'windows') }}
  181. isUbuntu: ${{ startsWith(matrix.os, 'ubuntu') }}
  182. isUnix: ${{ startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'ubuntu') }}
  183. steps:
  184. - uses: actions/checkout@v2
  185. with:
  186. submodules: 'recursive'
  187. - uses: actions/setup-java@v2
  188. with:
  189. distribution: 'temurin'
  190. java-version: '17'
  191. - name: Setup Gradle
  192. uses: gradle/gradle-build-action@v2
  193. - name: Cache konan
  194. uses: pat-s/always-upload-cache@v3
  195. with:
  196. path: ~/.konan
  197. key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }}
  198. restore-keys: |
  199. ${{ runner.os }}-gradle-
  200. - if: ${{ env.isUnix == 'true' }}
  201. run: chmod -R 777 *
  202. # Prepare environment for linking for macOS
  203. - if: ${{ env.isMac == 'true' }}
  204. name: Install OpenSSL
  205. run: >
  206. git clone https://github.com/openssl/openssl.git --recursive &&
  207. cd openssl &&
  208. git checkout tags/openssl-3.0.3 &&
  209. ./Configure --prefix=/opt/openssl --openssldir=/usr/local/ssl &&
  210. make &&
  211. sudo make install
  212. - name: Clean and download dependencies
  213. run: ./gradlew clean ${{ env.gradleArgs }}
  214. - name: "Assemble"
  215. run: ./gradlew assemble ${{ env.gradleArgs }}
  216. - name: "Check"
  217. run: ./gradlew check ${{ env.gradleArgs }}
  218. - if: ${{ env.isMac == 'true' }}
  219. name: Ensure KDoc valid
  220. run: ./gradlew dokkaHtmlMultiModule
  221. build-mirai-core-native:
  222. name: "Native (${{ matrix.os }})"
  223. runs-on: ${{ matrix.os }}
  224. strategy:
  225. fail-fast: false
  226. matrix:
  227. os:
  228. - windows-2022
  229. - ubuntu-20.04
  230. - ubuntu-18.04
  231. - macos-12
  232. - macos-11
  233. include:
  234. - os: windows-2022
  235. targetName: mingwX64
  236. - os: ubuntu-20.04
  237. targetName: linuxX64
  238. - os: ubuntu-18.04
  239. targetName: linuxX64
  240. - os: macos-12
  241. targetName: macosX64
  242. - os: macos-11
  243. targetName: macosX64
  244. env:
  245. # FIXME there must be two or more targets, or we'll get error on `@OptionalExpectation`
  246. # > Declaration annotated with '@OptionalExpectation' can only be used in common module sources
  247. gradleArgs: --scan "-Dmirai.target=jvm;${{ matrix.targetName }};!other" "-Pkotlin.compiler.execution.strategy=in-process" "-Dorg.gradle.jvmargs=-Xmx4096m -Dfile.encoding=UTF-8"
  248. isMac: ${{ startsWith(matrix.os, 'macos') }}
  249. isWindows: ${{ startsWith(matrix.os, 'windows') }}
  250. isUbuntu: ${{ startsWith(matrix.os, 'ubuntu') }}
  251. isUnix: ${{ startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'ubuntu') }}
  252. VCPKG_DEFAULT_BINARY_CACHE: ${{ startsWith(matrix.os, 'windows') && 'C:\vcpkg\binary_cache' || '/usr/local/share/vcpkg/binary_cache' }}
  253. steps:
  254. - uses: actions/checkout@v2
  255. with:
  256. submodules: 'recursive'
  257. - uses: actions/setup-java@v2
  258. with:
  259. distribution: 'adopt-openj9'
  260. java-version: '17'
  261. - name: Setup Gradle
  262. uses: gradle/gradle-build-action@v2
  263. - name: Cache konan
  264. uses: pat-s/always-upload-cache@v3
  265. with:
  266. path: ~/.konan
  267. key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }}
  268. restore-keys: |
  269. ${{ runner.os }}-gradle-
  270. - name: Prepare to cache vcpkg
  271. if: ${{ env.isWindows == 'true' }}
  272. run: mkdir -p ${{ env.VCPKG_DEFAULT_BINARY_CACHE }}
  273. - name: Cache vcpkg
  274. if: ${{ env.isWindows == 'true' }}
  275. uses: pat-s/always-upload-cache@v3
  276. with:
  277. path: ${{ env.VCPKG_DEFAULT_BINARY_CACHE }}
  278. key: ${{ runner.os }}-vcpkg-binary-cache-${{ github.job }}
  279. restore-keys: |
  280. ${{ runner.os }}-vcpkg-binary-cache-
  281. - if: ${{ env.isUnix == 'true' }}
  282. run: chmod -R 777 *
  283. # Prepare environment for linking on macOS
  284. - if: ${{ env.isMac == 'true' }}
  285. name: Install OpenSSL on Mac OS
  286. run: >
  287. git clone https://github.com/openssl/openssl.git --recursive &&
  288. cd openssl &&
  289. git checkout tags/openssl-3.0.3 &&
  290. ./Configure --prefix=/opt/openssl --openssldir=/usr/local/ssl &&
  291. make &&
  292. sudo make install
  293. # Prepare environment for linking on Ubuntu
  294. - if: ${{ env.isUbuntu == 'true' }}
  295. name: Install OpenSSL on Ubuntu
  296. run: sudo apt install libssl-dev -y
  297. # Prepare environment for linking on Windows
  298. - if: ${{ env.isWindows == 'true' }}
  299. name: Setup Memory Environment on Windows
  300. run: >
  301. wmic pagefileset where name="D:\\pagefile.sys" set InitialSize=1024,MaximumSize=9216 &
  302. net stop mongodb
  303. shell: cmd
  304. continue-on-error: true
  305. - if: ${{ env.isWindows == 'true' }}
  306. name: Install OpenSSL & cURL on Windows
  307. run: |
  308. echo "set(VCPKG_BUILD_TYPE release)" | Out-File -FilePath "$env:VCPKG_INSTALLATION_ROOT\triplets\x64-windows.cmake" -Encoding utf8 -Append
  309. vcpkg install openssl:x64-windows curl[core,openssl]:x64-windows
  310. New-Item -Path $env:VCPKG_INSTALLATION_ROOT\installed\x64-windows\lib\crypto.lib -ItemType SymbolicLink -Value $env:VCPKG_INSTALLATION_ROOT\installed\x64-windows\lib\libcrypto.lib
  311. New-Item -Path $env:VCPKG_INSTALLATION_ROOT\installed\x64-windows\lib\ssl.lib -ItemType SymbolicLink -Value $env:VCPKG_INSTALLATION_ROOT\installed\x64-windows\lib\libssl.lib
  312. New-Item -Path $env:VCPKG_INSTALLATION_ROOT\installed\x64-windows\lib\curl.lib -ItemType SymbolicLink -Value $env:VCPKG_INSTALLATION_ROOT\installed\x64-windows\lib\libcurl.lib
  313. echo "$env:VCPKG_INSTALLATION_ROOT\installed\x64-windows\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
  314. - name: Clean and download dependencies
  315. run: ./gradlew clean ${{ env.gradleArgs }}
  316. - name: "Test mirai-core-utils for ${{ matrix.os }}"
  317. run: ./gradlew :mirai-core-utils:${{ matrix.targetName }}Test ${{ env.gradleArgs }}
  318. - name: "Test mirai-core-api for ${{ matrix.os }}"
  319. run: ./gradlew :mirai-core-api:${{ matrix.targetName }}Test ${{ env.gradleArgs }}
  320. - name: "Test mirai-core for ${{ matrix.os }}"
  321. run: ./gradlew :mirai-core:${{ matrix.targetName }}Test ${{ env.gradleArgs }}