test.yml 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. name: "Test"
  2. on: [push, pull_request]
  3. jobs:
  4. utest:
  5. name: actions-test-utest
  6. runs-on: ubuntu-20.04
  7. steps:
  8. - name: Checkout repository
  9. uses: actions/checkout@v2
  10. ################################################################
  11. # Tests
  12. - name: Build test image
  13. run: docker build --tag srs:test -f trunk/Dockerfile.test .
  14. # For utest
  15. - name: Run SRS utest
  16. run: docker run --rm srs:test bash -c 'make && ./objs/srs_utest'
  17. coverage:
  18. name: actions-test-coverage
  19. runs-on: ubuntu-20.04
  20. steps:
  21. - name: Checkout repository
  22. uses: actions/checkout@v2
  23. ################################################################
  24. # Tests
  25. - name: Build coverage image
  26. run: docker build --tag srs:cov -f trunk/Dockerfile.cov .
  27. # For coverage
  28. - name: Run SRS covergae
  29. if: ${{ startsWith(github.ref, 'refs/heads/') || startsWith(github.ref, 'refs/pull/') }}
  30. run: |
  31. # The hash of commit.
  32. SRS_SHA=${{ github.sha }}
  33. # Note that the root of SRS, must contains .git, for report fixing.
  34. SRS_PROJECT=/srs
  35. # The github.ref is, for example, refs/heads/3.0release
  36. SRS_BRANCH=$(echo ${{ github.ref }}| awk -F 'refs/heads/' '{print $2}'| awk -F '/' '{print $1}')
  37. # The github.ref is, for example, refs/pull/2536/merge
  38. SRS_PR=$(echo ${{ github.ref }}| awk -F 'refs/pull/' '{print $2}'| awk -F '/' '{print $1}')
  39. echo "For ref=${{ github.ref }}, sha=${{ github.sha }}, SRS_BRANCH=$SRS_BRANCH, SRS_PR=$SRS_PR, SRS_SHA=$SRS_SHA, SRS_PROJECT=$SRS_PROJECT"
  40. docker run --rm --env SRS_BRANCH=$SRS_BRANCH --env SRS_PR=$SRS_PR --env SRS_SHA=$SRS_SHA --env SRS_PROJECT=$SRS_PROJECT \
  41. srs:cov bash -c 'make && ./objs/srs_utest && bash auto/coverage.sh'