-
Notifications
You must be signed in to change notification settings - Fork 10
68 lines (64 loc) · 1.95 KB
/
test.yml
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
name: Tests
on:
pull_request:
push:
branches:
- develop
- main
- master
- release/**
permissions:
contents: write
pull-requests: write
# Automatically cancel run if another commit to the same ref is detected.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test-unit-cover:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v4
with:
go-version: '1.21'
check-latest: true
- uses: actions/checkout@v4
- uses: technote-space/get-diff-action@v6.1.2
with:
PATTERNS: |
**/**.sol
**/**.go
go.mod
go.sum
- name: Test and create coverage report
run: |
make test-unit-cover
if: env.GIT_DIFF
- name: Check if test coverage is above threshold
uses: vladopajic/go-test-coverage@v2
with:
profile: cover.out
local-prefix: github.com/ExocoreNetwork/exocore
# TODO: increase this threshold with time to 80
threshold-total: 10
if: env.GIT_DIFF
- name: Extract coverage data
id: extract_coverage
run: |
echo "coverage=$(head -n 1 $GITHUB_ACTION | awk -F'=' '{print $2}')" >> $GITHUB_ENV
- name: Find comment
id: find-comment
uses: peter-evans/find-comment@v2
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
if: env.GIT_DIFF && github.event_name == 'pull_request'
- name: Comment coverage on PR
uses: peter-evans/create-or-update-comment@v3
with:
issue-number: ${{ github.event.pull_request.number }}
comment-id: ${{ steps.find-comment.outputs.comment-id }}
body: |
Total Coverage: ${{ env.coverage }}
edit-mode: replace
if: env.GIT_DIFF && github.event_name == 'pull_request'