Skip to content

Commit

Permalink
chore(ci): coverage badge comment on PR
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxMustermann2 committed Mar 11, 2024
1 parent da20a21 commit b162a7f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
28 changes: 23 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ on:
- release/**

permissions:
contents: read
contents: write
pull-requests: write

# Automatically cancel run if another commit to the same ref is detected.
concurrency:
Expand All @@ -36,8 +37,25 @@ jobs:
run: |
make test-unit-cover
if: env.GIT_DIFF
- name: Upload coverage report
uses: actions/upload-artifact@v2
- name: check test coverage
if: github.event_name == 'pull_request'
uses: vladopajic/go-test-coverage@v2
with:
name: coverage-report
path: ./coverage.txt
profile: cover.out
local-prefix: github.com/ExocoreNetwork/exocore
threshold-total: 70
badge-file-name: coverage.svg
- name: Comment coverage on PR
uses: actions/github-script@v6
if: github.event_name == 'pull_request'
with:
script: |
const fs = require('fs');
const path = './coverage.svg';
const svgContent = fs.readFileSync(path, {encoding: 'utf8'});
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `## Test Coverage Badge\n\n![Coverage Badge](${svgContent})`
});
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ localnet-setup
.testnets

# Testing
coverage.txt
*.out
sim_log_file
tests/**/tmp/*
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ test-race: ARGS=-race
test-race: TEST_PACKAGES=$(PACKAGES_NOSIMULATION)
$(TEST_TARGETS): run-tests

test-unit-cover: ARGS=-timeout=15m -coverprofile=coverage.txt -covermode=atomic
test-unit-cover: ARGS=-timeout=15m -coverprofile=cover.out -covermode=atomic
test-unit-cover: TEST_PACKAGES=$(PACKAGES_UNIT)

test-e2e:
Expand Down

0 comments on commit b162a7f

Please sign in to comment.