tests.yml 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. name: Tests
  2. on: [push, pull_request]
  3. jobs:
  4. unit-tests:
  5. runs-on: ubuntu-latest
  6. strategy:
  7. matrix:
  8. go: ['1.14', '1.15']
  9. steps:
  10. - uses: actions/checkout@v2
  11. with:
  12. # clone in the gopath
  13. path: src/github.com/${{ github.repository }}
  14. - uses: actions/setup-go@v2
  15. with:
  16. stable: false
  17. go-version: ${{ matrix.go }}
  18. - run: |
  19. # `env` doesn't allow for variable expansion, so we use the GITHUB_ENV
  20. # trick.
  21. echo "GOPATH=$GITHUB_WORKSPACE" >> $GITHUB_ENV
  22. echo "GO111MODULE=on" >> $GITHUB_ENV
  23. - name: run unit tests
  24. run: |
  25. cd $GITHUB_WORKSPACE/src/github.com/${{ github.repository }}
  26. go get -v -t ./...
  27. echo "" > coverage.txt
  28. for d in $(go list ./...); do
  29. go test -v -race -coverprofile=profile.out -covermode=atomic "${d}"
  30. if [ -f profile.out ]; then
  31. cat profile.out >> coverage.txt
  32. rm profile.out
  33. fi
  34. done
  35. - name: report to codecov
  36. run: bash <(curl -s https://codecov.io/bash) -c -f coverage.txt -F unittest
  37. integration-tests:
  38. runs-on: ubuntu-latest
  39. strategy:
  40. matrix:
  41. go: ['1.14', '1.15']
  42. steps:
  43. - uses: actions/checkout@v2
  44. with:
  45. # clone in the gopath
  46. path: src/github.com/${{ github.repository }}
  47. - uses: actions/setup-go@v2
  48. with:
  49. stable: false
  50. go-version: ${{ matrix.go }}
  51. - run: |
  52. # `env` doesn't allow for variable expansion, so we use the GITHUB_ENV
  53. # trick.
  54. echo "GOPATH=$GITHUB_WORKSPACE" >> $GITHUB_ENV
  55. echo "GO111MODULE=on" >> $GITHUB_ENV
  56. - name: run integ tests
  57. run: |
  58. cd $GITHUB_WORKSPACE/src/github.com/${{ github.repository }}
  59. go get -v -t ./...
  60. echo "" > coverage.txt
  61. for d in $(go list ./...); do
  62. go test -c -tags=integration -v -race -coverprofile=profile.out -covermode=atomic "${d}"
  63. testbin="./$(basename $d).test"
  64. # only run it if it was built - i.e. if there are integ tests
  65. test -x "${testbin}" && sudo "./${testbin}"
  66. if [ -f profile.out ]; then
  67. cat profile.out >> coverage.txt
  68. rm profile.out
  69. fi
  70. done
  71. - name: report to codecov
  72. run: bash <(curl -s https://codecov.io/bash) -c -f coverage.txt -F integtest