Skip to content
This repository has been archived by the owner on Apr 25, 2024. It is now read-only.

Commit

Permalink
Merge pull request #26 from aki77/1.5.0
Browse files Browse the repository at this point in the history
1.5.0
  • Loading branch information
aki77 authored Jun 24, 2022
2 parents c100e8a + 4797bf8 commit a06b28c
Show file tree
Hide file tree
Showing 7 changed files with 2,200 additions and 1,608 deletions.
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ A GitHub Action that report simplecov coverage.

![Demo](https://i.gyazo.com/c4e572c91fe8048c95392ea3ddce79f5.png)

## Usage:

The action works only with `pull_request` event.

### Inputs

- `token` - The GITHUB_TOKEN secret.
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ inputs:
description: "Github token"
required: true
runs:
using: "node12"
using: "node16"
main: "dist/index.js"
2,787 changes: 1,657 additions & 1,130 deletions dist/index.js

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "simplecov-report",
"version": "1.4.1",
"version": "1.5.0",
"private": true,
"description": "Simplecov Report",
"main": "lib/main.js",
Expand Down Expand Up @@ -33,7 +33,7 @@
"devDependencies": {
"@types/jest": "^27.0.2",
"@types/markdown-table": "^3.0.0",
"@types/node": "^12.12.38",
"@types/node": "^16",
"@typescript-eslint/parser": "^5.16.0",
"@zeit/ncc": "^0.22.3",
"eslint": "^8.12.0",
Expand All @@ -46,5 +46,9 @@
"prettier": "^2.1.2",
"ts-jest": "^27.0.5",
"typescript": "^4.0.3"
},
"volta": {
"node": "16.15.1",
"yarn": "1.22.19"
}
}
6 changes: 0 additions & 6 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import path from 'path'
import * as core from '@actions/core'
import * as github from '@actions/github'
import {report} from './report'

interface Result {
Expand All @@ -12,11 +11,6 @@ interface Result {

async function run(): Promise<void> {
try {
if (!github.context.issue.number) {
core.warning('Cannot find the PR id.')
return
}

const failedThreshold: number = Number.parseInt(core.getInput('failedThreshold'), 10)
core.debug(`failedThreshold ${failedThreshold}`)

Expand Down
31 changes: 20 additions & 11 deletions src/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,26 @@ export async function report(coveredPercent: number, failedThreshold: number): P
])

const pullRequestId = github.context.issue.number
if (!pullRequestId) {
throw new Error('Cannot find the PR id.')
if (pullRequestId) {
await replaceComment({
token: core.getInput('token', {required: true}),
owner: github.context.repo.owner,
repo: github.context.repo.repo,
issue_number: pullRequestId,
body: `## Simplecov Report
${summaryTable}
`
})
}

await replaceComment({
token: core.getInput('token', {required: true}),
owner: github.context.repo.owner,
repo: github.context.repo.repo,
issue_number: pullRequestId,
body: `## Simplecov Report
${summaryTable}
`
})
await core.summary
.addHeading('Simplecov Report')
.addTable([
[
{data: 'Covered', header: true},
{data: 'Threshold', header: true}
],
[`${coveredPercent}%`, `${failedThreshold}%`]
])
.write()
}
Loading

0 comments on commit a06b28c

Please sign in to comment.