summaryrefslogtreecommitdiffhomepage
path: root/.github/workflows/tests.yml
blob: d0ffeab12be197545e74756cba444bfeebe6fe6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
name: Tests

on: [push, pull_request]

jobs:
  unit-tests:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        go: ['1.17', '1.18', '1.19', '1.20']
    env:
      GO111MODULE: on
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-go@v2
        with:
          stable: false
          go-version: ${{ matrix.go }}
      - name: run unit tests
        run: |
          go get -v -t ./...
          echo "" > "${GITHUB_WORKSPACE}"/coverage.txt
          for d in $(go list ./...); do
              go test -v -race -coverprofile=profile.out -covermode=atomic "${d}"
              if [ -f profile.out ]; then
                cat profile.out >> "${GITHUB_WORKSPACE}"/coverage.txt
                rm profile.out
              fi
          done
      - name: report coverage to codecov
        uses: codecov/codecov-action@v1
        with:
          files: coverage.txt
          flags: unittests
          fail_ci_if_error: true
          verbose: true
  integration-tests:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        go: ['1.17', '1.18', '1.19', '1.20']
    env:
      GO111MODULE: on
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-go@v2
        with:
          stable: false
          go-version: ${{ matrix.go }}
      - name: run integ tests
        run: |
          go get -v -t -tags=integration ./...
          echo "" > "${GITHUB_WORKSPACE}"/coverage.txt
          for d in $(go list -tags=integration ./...); do
              go test -c -tags=integration -v -race -coverprofile=profile.out -covermode=atomic "${d}"
              testbin="./$(basename $d).test"
              # only run it if it was built - i.e. if there are integ tests
              test -x "${testbin}" && sudo "./${testbin}"
              if [ -f profile.out ]; then
                cat profile.out >> "${GITHUB_WORKSPACE}"/coverage.txt
                rm profile.out
              fi
          done
      - name: report coverage to codecov
        uses: codecov/codecov-action@v1
        with:
          files: coverage.txt
          flags: integtests
          fail_ci_if_error: true
          verbose: true