|
16 | 16 | name: Unit Tests |
17 | 17 | strategy: |
18 | 18 | matrix: |
19 | | - go-version: ["1.18"] |
| 19 | + go-version: ["1.19"] |
20 | 20 | platform: ["ubuntu-latest"] |
| 21 | + type: ["Tests","Cover"] # run coverage as separate job w/out -race to avoid killing process |
| 22 | + include: |
| 23 | + - type: "Tests" |
| 24 | + goflags: '-v -race -count=1 -json' |
| 25 | + - type: "Cover" |
| 26 | + goflags: "-v -count=1 -json" |
| 27 | + coveropts: "-coverprofile=coverage.txt -covermode=atomic" |
21 | 28 |
|
22 | 29 | runs-on: ${{ matrix.platform }} |
23 | 30 | timeout-minutes: 20 |
@@ -46,10 +53,21 @@ jobs: |
46 | 53 | - name: Install tparse |
47 | 54 | run: go install github.com/mfridman/tparse@latest |
48 | 55 |
|
| 56 | + - name: Check for .codecov.yaml |
| 57 | + id: codecov-enabled |
| 58 | + uses: andstor/file-existence-action@20b4d2e596410855db8f9ca21e96fbe18e12930b |
| 59 | + with: |
| 60 | + files: .codecov.yaml |
| 61 | + |
49 | 62 | - name: Test |
50 | 63 | env: |
51 | | - GOFLAGS: "-v -race -count=1 -json" |
52 | | - run: go test ./... | tparse -all |
| 64 | + COVER_OPTS: ${{ matrix.coveropts }} |
| 65 | + GOFLAGS: ${{ matrix.goflags }} |
| 66 | + run: go test $COVER_OPTS ./... | tparse -all -notests -format markdown >> $GITHUB_STEP_SUMMARY |
| 67 | + |
| 68 | + - if: steps.codecov-enabled.outputs.files_exists == 'true' |
| 69 | + name: Upload Codecov Report |
| 70 | + uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 |
53 | 71 |
|
54 | 72 | - name: Verify git clean |
55 | 73 | shell: bash |
|
61 | 79 | echo "::error:: $(git status)" |
62 | 80 | exit 1 |
63 | 81 | fi |
64 | | -
|
65 | | - # see https://github.com/timbray/quamina/issues/28 for details why a separate job |
66 | | - coverage: |
67 | | - name: Create Coverage Report |
68 | | - strategy: |
69 | | - matrix: |
70 | | - go-version: ["1.18"] |
71 | | - platform: ["ubuntu-latest"] |
72 | | - |
73 | | - runs-on: ${{ matrix.platform }} |
74 | | - timeout-minutes: 10 |
75 | | - |
76 | | - steps: |
77 | | - - name: Checkout repository |
78 | | - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c |
79 | | - |
80 | | - - name: Set up Go ${{ matrix.go-version }} |
81 | | - uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 |
82 | | - with: |
83 | | - go-version: ${{ matrix.go-version }} |
84 | | - id: go |
85 | | - |
86 | | - - name: Restore Go cache |
87 | | - uses: actions/cache@58c146cc91c5b9e778e71775dfe9bf1442ad9a12 |
88 | | - with: |
89 | | - path: | |
90 | | - ~/.cache/go-build |
91 | | - ~/go/pkg/mod |
92 | | -
|
93 | | - key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum', 'testdata/**') }} |
94 | | - restore-keys: | |
95 | | - ${{ runner.os }}-go-${{ matrix.go-version }}- |
96 | | -
|
97 | | - - name: Install tparse |
98 | | - run: go install github.com/mfridman/tparse@latest |
99 | | - |
100 | | - - name: Check for .codecov.yaml |
101 | | - id: codecov-enabled |
102 | | - uses: andstor/file-existence-action@20b4d2e596410855db8f9ca21e96fbe18e12930b |
103 | | - with: |
104 | | - files: .codecov.yaml |
105 | | - |
106 | | - - if: steps.codecov-enabled.outputs.files_exists == 'true' |
107 | | - name: Produce Go Coverage Report File |
108 | | - env: |
109 | | - COVER_OPTS: "-coverprofile=coverage.txt -covermode=atomic" |
110 | | - GOFLAGS: "-v -count=1 -json" |
111 | | - run: go test $COVER_OPTS ./... | tparse -all |
112 | | - |
113 | | - - if: steps.codecov-enabled.outputs.files_exists == 'true' |
114 | | - name: Upload Codecov Report |
115 | | - uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 |
0 commit comments