Skip to content

Commit

Permalink
feat: improve notify_issue to be able to choose when the comment is c…
Browse files Browse the repository at this point in the history
…reated
  • Loading branch information
LouisBrunner committed Dec 6, 2024
1 parent 9f8375d commit 6abb13b
Show file tree
Hide file tree
Showing 8 changed files with 239 additions and 178 deletions.
110 changes: 72 additions & 38 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

## Defaults
test_defaults_deleted:
name: 'Defaults (deleted, fails)'
name: "Defaults (deleted, fails)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -19,7 +19,7 @@ jobs:
new: fixtures/file2_deleted.txt

test_defaults_same:
name: 'Defaults (same, works)'
name: "Defaults (same, works)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -30,7 +30,7 @@ jobs:
new: fixtures/file3_same.txt

test_defaults_added:
name: 'Defaults (added, fails)'
name: "Defaults (added, fails)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -41,7 +41,7 @@ jobs:
new: fixtures/file4_added.txt

test_defaults_mixed:
name: 'Defaults (mixed, fails)'
name: "Defaults (mixed, fails)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -52,7 +52,7 @@ jobs:
new: fixtures/file5_mixed.txt

test_defaults_mixed_added:
name: 'Defaults (mixed-better, fails)'
name: "Defaults (mixed-better, fails)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -63,7 +63,7 @@ jobs:
new: fixtures/file6_mixed_added.txt

test_defaults_mixed_deleted:
name: 'Defaults (mixed_delet, fails)'
name: "Defaults (mixed_delet, fails)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -75,7 +75,7 @@ jobs:

## Strict
test_strict_deleted:
name: 'Strict (deleted, fails)'
name: "Strict (deleted, fails)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -88,7 +88,7 @@ jobs:
tolerance: same

test_strict_same:
name: 'Strict (same, works)'
name: "Strict (same, works)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -101,7 +101,7 @@ jobs:
tolerance: same

test_strict_added:
name: 'Strict (added, fails)'
name: "Strict (added, fails)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -114,7 +114,7 @@ jobs:
tolerance: same

test_strict_mixed:
name: 'Strict (mixed, fails)'
name: "Strict (mixed, fails)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -127,7 +127,7 @@ jobs:
tolerance: same

test_strict_mixed_added:
name: 'Strict (mixed-better, fails)'
name: "Strict (mixed-better, fails)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -140,7 +140,7 @@ jobs:
tolerance: same

test_strict_mixed_deleted:
name: 'Strict (mixed-worse, fails)'
name: "Strict (mixed-worse, fails)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -154,7 +154,7 @@ jobs:

## Additions
test_additions_deleted:
name: 'Additions (deleted, fails)'
name: "Additions (deleted, fails)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -167,7 +167,7 @@ jobs:
tolerance: better

test_additions_same:
name: 'Additions (same, fails)'
name: "Additions (same, fails)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -180,7 +180,7 @@ jobs:
tolerance: better

test_additions_added:
name: 'Additions (added, works)'
name: "Additions (added, works)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -193,7 +193,7 @@ jobs:
tolerance: better

test_additions_mixed:
name: 'Additions (mixed, fails)'
name: "Additions (mixed, fails)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -206,7 +206,7 @@ jobs:
tolerance: better

test_additions_mixed_added:
name: 'Additions (mixed-better, fails)'
name: "Additions (mixed-better, fails)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -219,7 +219,7 @@ jobs:
tolerance: better

test_additions_mixed_deleted:
name: 'Additions (mixed-worse, fails)'
name: "Additions (mixed-worse, fails)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -233,7 +233,7 @@ jobs:

## Deletions
test_deletions_deleted:
name: 'Deletions (deleted, works)'
name: "Deletions (deleted, works)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -246,7 +246,7 @@ jobs:
tolerance: better

test_deletions_same:
name: 'Deletions (same, fails)'
name: "Deletions (same, fails)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -259,7 +259,7 @@ jobs:
tolerance: better

test_deletions_added:
name: 'Deletions (added, fails)'
name: "Deletions (added, fails)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -272,7 +272,7 @@ jobs:
tolerance: better

test_deletions_mixed:
name: 'Deletions (mixed, fails)'
name: "Deletions (mixed, fails)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -285,7 +285,7 @@ jobs:
tolerance: better

test_deletions_mixed_added:
name: 'Deletions (mixed-better, fails)'
name: "Deletions (mixed-better, fails)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -298,7 +298,7 @@ jobs:
tolerance: better

test_deletions_mixed_deleted:
name: 'Deletions (mixed-worse, fails)'
name: "Deletions (mixed-worse, fails)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -312,7 +312,7 @@ jobs:

# Tolerance (Additions)
test_tolerance_deleted:
name: 'Tolerance (deleted, works)'
name: "Tolerance (deleted, works)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -325,7 +325,7 @@ jobs:
tolerance: worse

test_tolerance_same:
name: 'Tolerance (same, works)'
name: "Tolerance (same, works)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -338,7 +338,7 @@ jobs:
tolerance: same

test_tolerance_added:
name: 'Tolerance (added, works)'
name: "Tolerance (added, works)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -351,7 +351,7 @@ jobs:
tolerance: better

test_tolerance_mixed:
name: 'Tolerance (mixed, works)'
name: "Tolerance (mixed, works)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -364,7 +364,7 @@ jobs:
tolerance: mixed

test_tolerance_mixed_added:
name: 'Tolerance (mixed-better, works)'
name: "Tolerance (mixed-better, works)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -377,7 +377,7 @@ jobs:
tolerance: mixed-better

test_tolerance_mixed_deleted:
name: 'Tolerance (mixed-worse, works)'
name: "Tolerance (mixed-worse, works)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -391,7 +391,7 @@ jobs:

# Outputs
test_output_file:
name: 'Output (file, works)'
name: "Output (file, works)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -406,7 +406,7 @@ jobs:
- run: cat out.txt

test_output_notifs_good:
name: 'Output (notif, works)'
name: "Output (notif, works)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -422,7 +422,7 @@ jobs:
notify_check: true

test_output_notifs_bad:
name: 'Output (notif, fails)'
name: "Output (notif, fails)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -434,11 +434,11 @@ jobs:
mode: addition
token: ${{ secrets.GITHUB_TOKEN }}
title: Fails
notify_issue: true
notify_issue: "always"
notify_check: true

test_output_sticky_notifs_good:
name: 'Output (sticky notif, works)'
name: "Output (sticky notif, works)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -450,12 +450,12 @@ jobs:
mode: addition
token: ${{ secrets.GITHUB_TOKEN }}
title: Works (sticky)
notify_issue: true
notify_issue: "success"
notify_check: true
sticky_comment: true

test_output_sticky_notifs_bad:
name: 'Output (sticky notif, fails)'
name: "Output (sticky notif, fails)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -467,6 +467,40 @@ jobs:
mode: addition
token: ${{ secrets.GITHUB_TOKEN }}
title: Fails (sticky)
notify_issue: true
notify_issue: "failure"
notify_check: true
sticky_comment: true

test_output_no_notifs_good:
name: "Output (quiet notif, works)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Should work
uses: ./
with:
old: fixtures/file1_basic.txt
new: fixtures/file4_added.txt
mode: addition
token: ${{ secrets.GITHUB_TOKEN }}
title: Works (quiet)
notify_issue: "failure"
notify_check: true
sticky_comment: true

test_output_no_notifs_bad:
name: "Output (quiet notif, fails)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Should fail
uses: ./
with:
old: fixtures/file1_basic.txt
new: fixtures/file2_deleted.txt
mode: addition
token: ${{ secrets.GITHUB_TOKEN }}
title: Fails (quiet)
notify_issue: "success"
notify_check: true
sticky_comment: true
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,13 @@ _Optional_ Will create a [GitHub Check Run](https://developer.github.com/v3/chec

### `notify_issue`

_Optional_ Will create a comment in the linked issue if `'true'` is specified, **requires** `token` to be given as well
_Optional_ Will create a comment in the linked issue if specified, **requires** `token` to be given as well.

Possible values:

- `always` / `true`: will always create a comment (note: `true` is deprecated in favor of `always`)
- `failure`: will only create a comment if the check fails
- `success`: will only create a comment if the check passes

### `sticky_comment`

Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

Loading

0 comments on commit 6abb13b

Please sign in to comment.