2
0

test.yml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. name: "Test"
  2. # @see https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#onpushpull_requestbranchestags
  3. on: [push, pull_request]
  4. # The dependency graph:
  5. # test(6m)
  6. # multiple-arch-armv7(13m)
  7. # multiple-arch-aarch64(7m)
  8. # cygwin64-cache(1m)
  9. # cygwin64(6m) - Must depends on cygwin64-cache.
  10. # fast(0s) - To limit all fastly run jobs after slow jobs.
  11. # build-centos7(3m)
  12. # build-ubuntu16(3m)
  13. # build-ubuntu18(2m)
  14. # build-ubuntu20(2m)
  15. # build-cross-arm(3m)
  16. # build-cross-aarch64(3m)
  17. # multiple-arch-amd64(2m)
  18. # coverage(3m)
  19. jobs:
  20. cygwin64-cache:
  21. name: cygwin64-cache
  22. steps:
  23. - name: Download Cache for Cygwin
  24. run: |
  25. echo "Generate convert.sh" &&
  26. echo "for file in \$(find objs -type l); do" > convert.sh &&
  27. echo " REAL=\$(readlink -f \$file) &&" >> convert.sh &&
  28. echo " echo \"convert \$file to \$REAL\" &&" >> convert.sh &&
  29. echo " rm -rf \$file &&" >> convert.sh &&
  30. echo " cp -r \$REAL \$file" >> convert.sh &&
  31. echo "done" >> convert.sh &&
  32. cat convert.sh &&
  33. docker run --rm -v $(pwd):/srs -w /usr/local/srs-cache/srs/trunk ossrs/srs:cygwin64-cache \
  34. bash -c "bash /srs/convert.sh && tar cf /srs/objs.tar.bz2 objs" &&
  35. pwd && du -sh *
  36. ##################################################################################################################
  37. - uses: actions/upload-artifact@v3
  38. with:
  39. name: srs-cache
  40. path: objs.tar.bz2
  41. retention-days: 1
  42. runs-on: ubuntu-20.04
  43. cygwin64:
  44. name: cygwin64
  45. needs:
  46. - cygwin64-cache
  47. steps:
  48. # See https://github.com/cygwin/cygwin-install-action#parameters
  49. # Note that https://github.com/egor-tensin/setup-cygwin fails to install packages.
  50. - name: Setup Cygwin
  51. uses: cygwin/cygwin-install-action@master
  52. with:
  53. platform: x86_64
  54. packages: bash make gcc-g++ cmake automake patch pkg-config tcl unzip
  55. install-dir: C:\cygwin64
  56. ##################################################################################################################
  57. - name: Checkout repository
  58. uses: actions/checkout@v3
  59. ##################################################################################################################
  60. # Note that we must download artifact after checkout code, because it will change the files in workspace.
  61. - uses: actions/download-artifact@v3
  62. with:
  63. name: srs-cache
  64. - uses: geekyeggo/delete-artifact@v2
  65. with:
  66. name: srs-cache
  67. ##################################################################################################################
  68. - name: Build and test SRS
  69. env:
  70. SHELLOPTS: igncr
  71. SRS_WORKSPACE: ${{ github.workspace }}
  72. shell: C:\cygwin64\bin\bash.exe --login '{0}'
  73. run: |
  74. WORKDIR=$(cygpath -u $SRS_WORKSPACE) && export PATH=/usr/bin:/usr/local/bin && cd ${WORKDIR} &&
  75. pwd && rm -rf /usr/local/srs-cache && mkdir -p /usr/local/srs-cache/srs/trunk && ls -lh &&
  76. tar xf objs.tar.bz2 -C /usr/local/srs-cache/srs/trunk/ && du -sh /usr/local/srs-cache/srs/trunk/* &&
  77. cd ${WORKDIR}/trunk && ./configure --gb28181=on --utest=on && ls -lh && du -sh * && du -sh objs/* &&
  78. cd ${WORKDIR}/trunk && make utest && ./objs/srs_utest
  79. runs-on: windows-latest
  80. build-centos7:
  81. name: build-centos7
  82. needs:
  83. - fast
  84. steps:
  85. - name: Checkout repository
  86. uses: actions/checkout@v3
  87. # Build for CentOS 7
  88. - name: Build on CentOS7, baseline
  89. run: DOCKER_BUILDKIT=1 docker build -f trunk/Dockerfile.builds --target centos7-baseline .
  90. - name: Build on CentOS7, with all features
  91. run: DOCKER_BUILDKIT=1 docker build -f trunk/Dockerfile.builds --target centos7-all .
  92. - name: Build on CentOS7, without WebRTC
  93. run: DOCKER_BUILDKIT=1 docker build -f trunk/Dockerfile.builds --target centos7-no-webrtc .
  94. - name: Build on CentOS7, without ASM
  95. run: DOCKER_BUILDKIT=1 docker build -f trunk/Dockerfile.builds --target centos7-no-asm .
  96. - name: Build on CentOS7, C++98, no FFmpeg
  97. run: DOCKER_BUILDKIT=1 docker build -f trunk/Dockerfile.builds --target centos7-ansi-no-ffmpeg .
  98. runs-on: ubuntu-20.04
  99. build-ubuntu16:
  100. name: build-ubuntu16
  101. needs:
  102. - fast
  103. steps:
  104. - name: Checkout repository
  105. uses: actions/checkout@v3
  106. # Build for Ubuntu16
  107. - name: Build on Ubuntu16, baseline
  108. run: DOCKER_BUILDKIT=1 docker build -f trunk/Dockerfile.builds --target ubuntu16-baseline .
  109. - name: Build on Ubuntu16, with all features
  110. run: DOCKER_BUILDKIT=1 docker build -f trunk/Dockerfile.builds --target ubuntu16-all .
  111. runs-on: ubuntu-20.04
  112. build-ubuntu18:
  113. name: build-ubuntu18
  114. needs:
  115. - fast
  116. steps:
  117. - name: Checkout repository
  118. uses: actions/checkout@v3
  119. # Build for Ubuntu18
  120. - name: Build on Ubuntu18, baseline
  121. run: DOCKER_BUILDKIT=1 docker build -f trunk/Dockerfile.builds --target ubuntu18-baseline .
  122. - name: Build on Ubuntu18, with all features
  123. run: DOCKER_BUILDKIT=1 docker build -f trunk/Dockerfile.builds --target ubuntu18-all .
  124. runs-on: ubuntu-20.04
  125. build-ubuntu20:
  126. name: build-ubuntu20
  127. needs:
  128. - fast
  129. steps:
  130. - name: Checkout repository
  131. uses: actions/checkout@v3
  132. # Build for Ubuntu20
  133. - name: Build on Ubuntu20, baseline
  134. run: DOCKER_BUILDKIT=1 docker build -f trunk/Dockerfile.builds --target ubuntu20-baseline .
  135. - name: Build on Ubuntu20, with all features
  136. run: DOCKER_BUILDKIT=1 docker build -f trunk/Dockerfile.builds --target ubuntu20-all .
  137. runs-on: ubuntu-20.04
  138. build-cross-arm:
  139. name: build-cross-arm
  140. needs:
  141. - fast
  142. steps:
  143. - name: Checkout repository
  144. uses: actions/checkout@v3
  145. - name: Cross Build for ARMv7 on Ubuntu16
  146. run: DOCKER_BUILDKIT=1 docker build -f trunk/Dockerfile.builds --target ubuntu16-cache-cross-armv7 .
  147. - name: Cross Build for ARMv7 on Ubuntu20
  148. run: DOCKER_BUILDKIT=1 docker build -f trunk/Dockerfile.builds --target ubuntu20-cache-cross-armv7 .
  149. runs-on: ubuntu-20.04
  150. build-cross-aarch64:
  151. name: build-cross-aarch64
  152. needs:
  153. - fast
  154. steps:
  155. - name: Checkout repository
  156. uses: actions/checkout@v3
  157. - name: Cross Build for AARCH64 on Ubuntu16
  158. run: DOCKER_BUILDKIT=1 docker build -f trunk/Dockerfile.builds --target ubuntu16-cache-cross-aarch64 .
  159. - name: Cross Build for AARCH64 on Ubuntu20
  160. run: DOCKER_BUILDKIT=1 docker build -f trunk/Dockerfile.builds --target ubuntu20-cache-cross-aarch64 .
  161. runs-on: ubuntu-20.04
  162. test:
  163. name: utest-regression-blackbox-test
  164. steps:
  165. - name: Checkout repository
  166. uses: actions/checkout@v3
  167. # Tests
  168. - name: Build test image
  169. run: docker build --tag srs:test --build-arg MAKEARGS='-j2' -f trunk/Dockerfile.test .
  170. # For blackbox-test
  171. - name: Run SRS blackbox-test
  172. run: |
  173. #docker run --rm -w /srs/trunk/3rdparty/srs-bench srs:test ./objs/srs_blackbox_test -test.v \
  174. # -test.run 'TestFast_RtmpPublish_DvrFlv_Basic' -srs-log -srs-stdout srs-ffmpeg-stderr -srs-dvr-stderr \
  175. # -srs-ffprobe-stdout
  176. docker run --rm -w /srs/trunk/3rdparty/srs-bench srs:test \
  177. ./objs/srs_blackbox_test -test.v -test.run '^TestFast' -test.parallel 64
  178. docker run --rm -w /srs/trunk/3rdparty/srs-bench srs:test \
  179. ./objs/srs_blackbox_test -test.v -test.run '^TestSlow' -test.parallel 4
  180. # For utest
  181. - name: Run SRS utest
  182. run: docker run --rm srs:test ./objs/srs_utest
  183. # For regression-test
  184. - name: Run SRS regression-test
  185. run: |
  186. docker run --rm srs:test bash -c './objs/srs -c conf/regression-test.conf && \
  187. cd 3rdparty/srs-bench && (./objs/srs_test -test.v || (cat ../../objs/srs.log && exit 1)) && \
  188. ./objs/srs_gb28181_test -test.v'
  189. runs-on: ubuntu-20.04
  190. coverage:
  191. name: coverage
  192. needs:
  193. - fast
  194. steps:
  195. - name: Checkout repository
  196. uses: actions/checkout@v3
  197. # Tests
  198. - name: Build coverage image
  199. run: docker build --tag srs:cov --build-arg MAKEARGS='-j2' -f trunk/Dockerfile.cov .
  200. # For coverage
  201. - name: Run SRS covergae
  202. if: ${{ startsWith(github.ref, 'refs/heads/') || startsWith(github.ref, 'refs/pull/') }}
  203. env:
  204. CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
  205. run: |
  206. # The hash of commit.
  207. SRS_SHA=${{ github.sha }}
  208. # Note that the root of SRS, must contains .git, for report fixing.
  209. SRS_PROJECT=/srs
  210. # The github.ref is, for example, refs/heads/develop
  211. SRS_BRANCH=$(echo ${{ github.ref }}| awk -F 'refs/heads/' '{print $2}'| awk -F '/' '{print $1}')
  212. # The github.ref is, for example, refs/pull/2536/merge
  213. SRS_PR=$(echo ${{ github.ref }}| awk -F 'refs/pull/' '{print $2}'| awk -F '/' '{print $1}')
  214. #
  215. echo "For github.ref=${{ github.ref }}, github.sha=${{ github.sha }}"
  216. echo "SRS_BRANCH=$SRS_BRANCH, SRS_PR=$SRS_PR, SRS_SHA=$SRS_SHA, SRS_PROJECT=$SRS_PROJECT"
  217. docker run --rm --env CODECOV_TOKEN=$CODECOV_TOKEN --env SRS_BRANCH=$SRS_BRANCH \
  218. --env SRS_PR=$SRS_PR --env SRS_SHA=$SRS_SHA --env SRS_PROJECT=$SRS_PROJECT \
  219. srs:cov bash -c './objs/srs_utest && bash auto/codecov.sh'
  220. #
  221. runs-on: ubuntu-20.04
  222. multiple-arch-armv7:
  223. name: multiple-arch-armv7
  224. steps:
  225. - name: Checkout repository
  226. uses: actions/checkout@v3
  227. # See https://github.com/crazy-max/ghaction-docker-buildx#moved-to-docker-organization
  228. # https://github.com/docker/setup-qemu-action
  229. - name: Set up QEMU
  230. uses: docker/setup-qemu-action@v2
  231. # https://github.com/docker/setup-buildx-action
  232. - name: Set up Docker Buildx
  233. uses: docker/setup-buildx-action@v2
  234. - name: Build multiple archs image
  235. run: |
  236. docker buildx build --platform linux/arm/v7 \
  237. --output "type=image,push=false" \
  238. --build-arg IMAGE=ossrs/srs:ubuntu20-cache \
  239. --build-arg INSTALLDEPENDS="NO" \
  240. -f Dockerfile .
  241. runs-on: ubuntu-20.04
  242. multiple-arch-aarch64:
  243. name: multiple-arch-aarch64
  244. steps:
  245. - name: Checkout repository
  246. uses: actions/checkout@v3
  247. # See https://github.com/crazy-max/ghaction-docker-buildx#moved-to-docker-organization
  248. # https://github.com/docker/setup-qemu-action
  249. - name: Set up QEMU
  250. uses: docker/setup-qemu-action@v2
  251. # https://github.com/docker/setup-buildx-action
  252. - name: Set up Docker Buildx
  253. uses: docker/setup-buildx-action@v2
  254. - name: Build multiple archs image
  255. run: |
  256. docker buildx build --platform linux/arm64/v8 \
  257. --output "type=image,push=false" \
  258. --build-arg IMAGE=ossrs/srs:ubuntu20-cache \
  259. --build-arg INSTALLDEPENDS="NO" \
  260. -f Dockerfile .
  261. runs-on: ubuntu-20.04
  262. multiple-arch-amd64:
  263. name: multiple-arch-amd64
  264. needs:
  265. - fast
  266. steps:
  267. - name: Checkout repository
  268. uses: actions/checkout@v3
  269. # See https://github.com/crazy-max/ghaction-docker-buildx#moved-to-docker-organization
  270. # https://github.com/docker/setup-qemu-action
  271. - name: Set up QEMU
  272. uses: docker/setup-qemu-action@v2
  273. # https://github.com/docker/setup-buildx-action
  274. - name: Set up Docker Buildx
  275. uses: docker/setup-buildx-action@v2
  276. - name: Build multiple archs image
  277. run: |
  278. docker buildx build --platform linux/amd64 \
  279. --output "type=image,push=false" \
  280. --build-arg IMAGE=ossrs/srs:ubuntu20-cache \
  281. -f Dockerfile .
  282. runs-on: ubuntu-20.04
  283. fast:
  284. name: fast
  285. needs:
  286. - cygwin64-cache
  287. steps:
  288. - run: echo 'Start fast jobs'
  289. runs-on: ubuntu-20.04
  290. done:
  291. name: done
  292. needs:
  293. - cygwin64
  294. - coverage
  295. - test
  296. - build-centos7
  297. - build-ubuntu16
  298. - build-ubuntu18
  299. - build-ubuntu20
  300. - build-cross-arm
  301. - build-cross-aarch64
  302. - multiple-arch-armv7
  303. - multiple-arch-aarch64
  304. - multiple-arch-amd64
  305. runs-on: ubuntu-20.04
  306. steps:
  307. - run: echo 'All done'