|
7 | 7 | workflow_dispatch: |
8 | 8 |
|
9 | 9 | jobs: |
10 | | - |
11 | 10 | test: |
12 | | - name: Test |
13 | 11 | runs-on: ubuntu-latest |
14 | 12 | steps: |
15 | | - - name: Set up Go 1.x |
16 | | - uses: actions/setup-go@v2 |
17 | | - with: |
18 | | - go-version: ^1.13 |
19 | | - |
20 | | - - name: Check out code into the Go module directory |
21 | | - uses: actions/checkout@v2 |
22 | | - |
23 | | - - name: Get dependencies |
24 | | - run: go mod vendor -v |
25 | | - |
26 | | - - name: Test |
27 | | - run: | |
28 | | - go test ./... -cover -count=1 -race -coverprofile ../main.out |
29 | | -
|
30 | | - - name: Set main branch code coverage |
31 | | - id: codecov-main-branch |
32 | | - uses: actions/github-script@v3 |
33 | | - with: |
34 | | - github-token: ${{secrets.GITHUB_TOKEN}} |
35 | | - result-encoding: string |
36 | | - script: | |
37 | | - const goTool = require(`${process.env.GITHUB_WORKSPACE}/.github/scripts/gotool.js`) |
38 | | - return await goTool({file: "../main.out"}) |
39 | | -
|
40 | | - - name: Checkout PR branch |
41 | | - uses: actions/checkout@v2 |
42 | | - |
43 | | - - name: Test PR branch |
44 | | - run: | |
45 | | - go test ./... -cover -count=1 -race -coverprofile ../pr.out |
46 | | -
|
47 | | - - name: Set PR branch code coverage |
48 | | - id: codecov-pr-branch |
49 | | - uses: actions/github-script@v3 |
50 | | - with: |
51 | | - github-token: ${{secrets.GITHUB_TOKEN}} |
52 | | - result-encoding: string |
53 | | - script: | |
54 | | - const goTool = require(`${process.env.GITHUB_WORKSPACE}/.github/scripts/gotool.js`) |
55 | | - return await goTool({file: "../pr.out"}) |
56 | | -
|
57 | | - - name: Create comment |
58 | | - if: github.event_name == 'pull_request' |
59 | | - uses: actions/github-script@v3 |
60 | | - env: |
61 | | - main_code_cov: ${{steps.codecov-main-branch.outputs.result}} |
62 | | - pr_code_cov: ${{steps.codecov-pr-branch.outputs.result}} |
63 | | - with: |
64 | | - github-token: ${{secrets.GITHUB_TOKEN}} |
65 | | - script: | |
66 | | - const runID = ${{github.run_id}} |
67 | | - mainCodeCov = process.env.main_code_cov.replace(/[\n\t\r]/g,"") |
68 | | - prCodeCov = process.env.pr_code_cov.replace(/[\n\t\r]/g,"") |
69 | | -
|
70 | | - const body = ` |
71 | | - ### Test Coverage Result |
72 | | - Success! :confetti_ball::confetti_ball::confetti_ball: |
| 13 | + - name: Checkout |
| 14 | + uses: actions/checkout@v2 |
73 | 15 |
|
74 | | - **Code Coverage** |
75 | | - Main: ${mainCodeCov} |
76 | | - PR : ${prCodeCov} |
| 16 | + - name: Set up Go 1.x |
| 17 | + uses: actions/setup-go@v2 |
| 18 | + with: |
| 19 | + go-version: 1.15 |
77 | 20 |
|
78 | | - Check Detail: [Here](https://github.com/${context.issue.owner}/${context.issue.repo}/actions/runs/${runID}) |
79 | | - ` |
| 21 | + - name: Run tests with coverage report output |
| 22 | + run: go test ./... -coverprofile=docs/coverage.out |
80 | 23 |
|
81 | | - github.issues.createComment({ |
82 | | - issue_number: context.issue.number, |
83 | | - owner: context.repo.owner, |
84 | | - repo: context.repo.repo, |
85 | | - body: body |
86 | | - }) |
| 24 | + - name: Comment |
| 25 | + uses: k1LoW/octocov-action@v0 |
0 commit comments