Compare commits
9 Commits
master
...
lcov-repor
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
95f6a41024 | ||
|
|
70c09941cf | ||
|
|
21b4337b76 | ||
|
|
ad6c0d4ded | ||
|
|
601277a3e7 | ||
|
|
bb5d80096d | ||
|
|
85221ddbbc | ||
|
|
22c7408fb4 | ||
|
|
80ba4ab18c |
10
CHANGELOG.md
10
CHANGELOG.md
@ -1,14 +1,6 @@
|
||||
# Changelog
|
||||
|
||||
## v1.2.0
|
||||
|
||||
- Added the coverage percent to result title on Check [#4](https://github.com/devmasx/coverage-check-action/pull/4)
|
||||
|
||||
## v1.1.0
|
||||
|
||||
- Lcov
|
||||
|
||||
## v1.0.0
|
||||
|
||||
- Create check run in github
|
||||
- Simplecov
|
||||
- Adapter for brakeman report
|
||||
|
||||
23
README.md
23
README.md
@ -2,43 +2,28 @@
|
||||
|
||||
A GitHub Action that check minimum coverage percentage!
|
||||
|
||||
This action requires a Github token with `checks:write` scope to allow create the check run using the Github API v3.
|
||||
But no need to generate any new token, you can use the Github action token (`${{ github.token }}`)
|
||||
|
||||
### Usage
|
||||
|
||||
#### Lcov
|
||||
|
||||
```yml
|
||||
- uses: devmasx/coverage-check-action@v1.2.0
|
||||
- uses: devmasx/coverage-check-action@v1.1.0
|
||||
with:
|
||||
type: lcov
|
||||
result_path: coverage/example.lcov
|
||||
min_coverage: 90
|
||||
token: ${{ github.token }}
|
||||
token: ${{secrets.GITHUB_TOKEN}}
|
||||
```
|
||||
|
||||
#### [Simplecov](https://github.com/colszowka/simplecov)
|
||||
|
||||
```yml
|
||||
- uses: devmasx/coverage-check-action@v1.2.0
|
||||
- uses: devmasx/coverage-check-action@v1.1.0
|
||||
with:
|
||||
type: simplecov
|
||||
result_path: coverage/.last_run.json
|
||||
min_coverage: 90
|
||||
token: ${{ github.token }}
|
||||
```
|
||||
|
||||
#### Report name
|
||||
|
||||
```yml
|
||||
- uses: devmasx/coverage-check-action@v1.2.0
|
||||
with:
|
||||
type: lcov
|
||||
result_path: coverage/example.lcov
|
||||
min_coverage: 90
|
||||
token: ${{ github.token }}
|
||||
report_name: "My Github Action Check Name"
|
||||
token: ${{secrets.GITHUB_TOKEN}}
|
||||
```
|
||||
|
||||
## Screenshots
|
||||
|
||||
@ -12,12 +12,10 @@ inputs:
|
||||
token:
|
||||
description: "Github token for create checks"
|
||||
required: true
|
||||
default: "World"
|
||||
min_coverage:
|
||||
description: "Minimum coverage"
|
||||
default: "80"
|
||||
report_name:
|
||||
description: "Name of the github action check"
|
||||
default: "Coverage"
|
||||
result_path:
|
||||
description: "Json with coverage result"
|
||||
required: true
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class GithubCheckRunService
|
||||
def initialize(report, github_data, report_name, report_adapter)
|
||||
CHECK_NAME = 'Coverage'
|
||||
|
||||
def initialize(report, github_data, report_adapter)
|
||||
@report = report
|
||||
@github_data = github_data
|
||||
@report_name = report_name
|
||||
@report_adapter = report_adapter
|
||||
@client = GithubClient.new(@github_data[:token], user_agent: 'coverage-action')
|
||||
end
|
||||
@ -17,7 +18,6 @@ class GithubCheckRunService
|
||||
@summary = @report_adapter.summary(@report)
|
||||
@annotations = @report_adapter.annotations(@report)
|
||||
@conclusion = @report_adapter.conslusion(@report)
|
||||
@percent = @report_adapter.lines_covered_percent(@report)
|
||||
|
||||
@client.patch(
|
||||
"#{endpoint_url}/#{id}",
|
||||
@ -33,7 +33,7 @@ class GithubCheckRunService
|
||||
|
||||
def create_check_payload
|
||||
{
|
||||
name: @report_name,
|
||||
name: CHECK_NAME,
|
||||
head_sha: @github_data[:sha],
|
||||
status: 'in_progress',
|
||||
started_at: Time.now.iso8601
|
||||
@ -42,13 +42,13 @@ class GithubCheckRunService
|
||||
|
||||
def update_check_payload
|
||||
{
|
||||
name: @report_name,
|
||||
name: CHECK_NAME,
|
||||
head_sha: @github_data[:sha],
|
||||
status: 'completed',
|
||||
completed_at: Time.now.iso8601,
|
||||
conclusion: @conclusion,
|
||||
output: {
|
||||
title: "#{@report_name} #{@percent}%",
|
||||
title: CHECK_NAME,
|
||||
summary: @summary,
|
||||
annotations: @annotations
|
||||
}
|
||||
|
||||
@ -17,14 +17,13 @@ end
|
||||
sha: ENV['GITHUB_SHA'],
|
||||
token: ENV['INPUT_TOKEN'],
|
||||
owner: ENV['GITHUB_REPOSITORY_OWNER'] || @event_json.dig('repository', 'owner', 'login'),
|
||||
repo: ENV['GITHUB_REPOSITORY_NAME'] || @event_json.dig('repository', 'name'),
|
||||
repo: ENV['GITHUB_REPOSITORY_NAME'] || @event_json.dig('repository', 'name')
|
||||
}
|
||||
|
||||
@coverage_type = ENV['INPUT_TYPE']
|
||||
@report_path = ENV['INPUT_RESULT_PATH']
|
||||
@report_name = ENV['INPUT_REPORT_NAME']
|
||||
@data = { min: ENV['INPUT_MIN_COVERAGE'] }
|
||||
|
||||
@report = CoverageReport.generate(@coverage_type, @report_path, @data)
|
||||
|
||||
GithubCheckRunService.new(@report, @github_data, @report_name, ReportAdapter).run
|
||||
GithubCheckRunService.new(@report, @github_data, ReportAdapter).run
|
||||
|
||||
@ -18,16 +18,16 @@ class ReportAdapter
|
||||
[]
|
||||
end
|
||||
|
||||
def lines_covered_percent(report)
|
||||
@lines_covered_percent ||= report.dig('lines', 'covered_percent')
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def table_head
|
||||
"| Type | covered | minimum |\n| ----- | ------- | ------- |"
|
||||
end
|
||||
|
||||
def lines_covered_percent(report)
|
||||
@lines_covered_percent ||= report.dig('lines', 'covered_percent')
|
||||
end
|
||||
|
||||
def lines_minimum_percent(report)
|
||||
@lines_minimum_percent ||= report.dig('lines', 'minumum_percent')
|
||||
end
|
||||
|
||||
@ -7,8 +7,7 @@ describe GithubCheckRunService do
|
||||
{ 'lines' => { 'covered_percent' => 80, 'minumum_percent' => 80 } }
|
||||
end
|
||||
let(:github_data) { { sha: 'sha', token: 'token', owner: 'owner', repo: 'repository_name' } }
|
||||
let(:report_name) { 'Coverage' }
|
||||
let(:service) { GithubCheckRunService.new(report, github_data, report_name, ReportAdapter) }
|
||||
let(:service) { GithubCheckRunService.new(report, github_data, ReportAdapter) }
|
||||
|
||||
it '#run' do
|
||||
stub_request(:any, 'https://api.github.com/repos/owner/repository_name/check-runs/id')
|
||||
|
||||
Reference in New Issue
Block a user