Skip to content

Commit

Permalink
feat: add group to isolate coverage comments
Browse files Browse the repository at this point in the history
  • Loading branch information
HolyNoodle committed Sep 25, 2023
1 parent 410c7f0 commit 9630cdc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ inputs:
description: 'Base branch to compare current branch to'
required: false
default: 'main'
group:
description: 'Group will help isolate actions comments'
required: false
default: ''
projects:
description: 'List of <project_name>:<project_root_dir>'
required: true
Expand Down
3 changes: 2 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { postMessage } from './postMessage'
export async function run(): Promise<void> {
try {
const baseBranch = core.getInput('base') || 'main'
const group = core.getInput('group')
const commands = core.getInput('commands').split('\n')
const github_token = core.getInput('token')
const projects = core
Expand All @@ -37,7 +38,7 @@ export async function run(): Promise<void> {

core.debug(`Computed coverage:\n${JSON.stringify(summaries)}`)

await postMessage(github_token, summaries)
await postMessage(github_token, summaries, group)
} catch (error) {
// Fail the workflow run if an error occurs
if (error instanceof Error) core.setFailed(error.message)
Expand Down
11 changes: 9 additions & 2 deletions src/postMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@ import { ProjectSummary } from './coverage'
import { formatChangedCoverage, formatCoverageDetails } from './utils/format'
import { sendMessage } from './utils/github'

const messageStart = ':ramen: Noodly Coverage! :ramen:\n'
const messageStartCreator = (group: string) =>
`:ramen: Noodly Coverage${group === '' ? '' : ` for ${group}`}! :ramen:\n`

export async function postMessage(token: string, summaries: ProjectSummary[]) {
export async function postMessage(
token: string,
summaries: ProjectSummary[],
group: string
) {
const messageStart = messageStartCreator(group)

core.info('Formatting message')
try {
const body = `${messageStart}
Expand Down

0 comments on commit 9630cdc

Please sign in to comment.