tests.yml 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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.20', '1.21']
  9. steps:
  10. - uses: actions/checkout@v4
  11. with:
  12. # clone in the gopath
  13. path: src/github.com/${{ github.repository }}
  14. fetch-depth: 0
  15. - uses: actions/setup-go@v5
  16. with:
  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. go test -v -race -coverprofile=coverage.txt -covermode=atomic ./...
  28. - name: report coverage to codecov
  29. uses: codecov/codecov-action@v4
  30. with:
  31. files: coverage.txt
  32. disable_search: true
  33. flags: unittests
  34. fail_ci_if_error: true
  35. verbose: true
  36. root_dir: ${{ github.workspace }}/src/github.com/${{ github.repository }}
  37. working-directory: ${{ github.workspace }}/src/github.com/${{ github.repository }}
  38. env:
  39. CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
  40. integration-tests:
  41. runs-on: ubuntu-latest
  42. strategy:
  43. matrix:
  44. go: ['1.20', '1.21']
  45. steps:
  46. - uses: actions/checkout@v4
  47. with:
  48. # clone in the gopath
  49. path: src/github.com/${{ github.repository }}
  50. fetch-depth: 0
  51. - uses: actions/setup-go@v5
  52. with:
  53. go-version: ${{ matrix.go }}
  54. - run: |
  55. # `env` doesn't allow for variable expansion, so we use the GITHUB_ENV
  56. # trick.
  57. echo "GOPATH=$GITHUB_WORKSPACE" >> $GITHUB_ENV
  58. echo "GO111MODULE=on" >> $GITHUB_ENV
  59. - name: setup integ tests
  60. run: |
  61. cd $GITHUB_WORKSPACE/src/github.com/${{ github.repository }}
  62. ./.ci/setup-integ.sh
  63. - name: run integ tests
  64. run: |
  65. cd $GITHUB_WORKSPACE/src/github.com/${{ github.repository }}/integ
  66. go get -v -t -tags=integration ./...
  67. echo "" > "${GITHUB_WORKSPACE}"/coverage.txt
  68. for d in $(go list -tags=integration ./...); do
  69. go test -c -tags=integration -v -race -coverprofile=profile.out -covermode=atomic "${d}"
  70. testbin="./$(basename $d).test"
  71. # only run it if it was built - i.e. if there are integ tests
  72. test -x "${testbin}" && sudo "./${testbin}"
  73. if [ -f profile.out ]; then
  74. cat profile.out >> "${GITHUB_WORKSPACE}"/coverage.txt
  75. rm profile.out
  76. fi
  77. done
  78. - name: report coverage to codecov
  79. uses: codecov/codecov-action@v4
  80. with:
  81. files: ${{github.workspace}}/coverage.txt
  82. disable_search: true
  83. flags: integtests
  84. fail_ci_if_error: true
  85. verbose: true
  86. root_dir: ${{ github.workspace }}/src/github.com/${{ github.repository }}
  87. working-directory: ${{ github.workspace }}/src/github.com/${{ github.repository }}
  88. env:
  89. CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}