Skip to content

Commit dfb500d

Browse files
Add ACTIVITY_RUN output
1 parent cce7525 commit dfb500d

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,13 @@ jobs:
348348
349349
### Outputs
350350
351-
The action makes available some data for downstream processing. All outputs are only available when running in PR mode.
351+
The action makes available some data for downstream processing.
352+
353+
| Name | Description |
354+
| --- | --- |
355+
| `ACTIVITY_RUN` | The type of activity that was run. One of `process_pr`, `post_comment`, `save_coverage_data_files`. |
356+
357+
All the following outputs are only available when running in PR mode.
352358

353359
| Name | Description |
354360
| --- | --- |

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ inputs:
111111
Deprecated, see https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/enabling-debug-logging
112112
default: false
113113
outputs:
114+
ACTIVITY_RUN:
115+
description: >
116+
The type of activity that was run. One of `process_pr`, `post_comment`, `save_coverage_data_files`.
114117
COMMENT_FILE_WRITTEN:
115118
description: >
116119
A boolean indicating whether a comment file was written to COMMENT_FILENAME or not.

coverage_comment/main.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,8 @@ def process_pr(
268268
],
269269
)
270270

271-
outputs = coverage.info.as_output(prefix="NEW")
271+
outputs = {"ACTIVITY_RUN": "process_pr"}
272+
outputs |= coverage.info.as_output(prefix="NEW")
272273
outputs |= diff_coverage.as_output(prefix="DIFF")
273274
if previous_coverage:
274275
outputs |= previous_coverage.info.as_output(prefix="REFERENCE")
@@ -370,6 +371,7 @@ def post_comment(
370371
)
371372
log.info("Comment posted in PR")
372373

374+
github.set_output(github_output=config.GITHUB_OUTPUT, ACTIVITY_RUN="post_comment")
373375
return 0
374376

375377

@@ -447,4 +449,8 @@ def save_coverage_data_files(
447449

448450
log.info(log_message)
449451

452+
github.set_output(
453+
github_output=config.GITHUB_OUTPUT, ACTIVITY_RUN="save_coverage_data_files"
454+
)
455+
450456
return 0

tests/integration/test_main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ def get_expected_output(
6666
comment_written: bool, reference_coverage: bool
6767
) -> dict[str, str]:
6868
output = {
69+
"ACTIVITY_RUN": '"process_pr"',
6970
"COMMENT_FILE_WRITTEN": str(comment_written).lower(),
7071
"NEW_COVERED_LINES": "7",
7172
"NEW_NUM_STATEMENTS": "9",

0 commit comments

Comments
 (0)