Skip to content

Commit b047bed

Browse files
Add work item linkage information to job summary and notices
Co-authored-by: joshjohanning <19912012+joshjohanning@users.noreply.github.com>
1 parent 28bb4cb commit b047bed

File tree

4 files changed

+49
-8
lines changed

4 files changed

+49
-8
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ Required software installed on runner:
6767
- `grep`
6868
- `cut`
6969

70+
### Action Output
71+
72+
The action provides visibility into linked work items through:
73+
74+
- **GitHub Actions Notices**: Work item links are displayed as notice annotations in the workflow run, making it easy to see which work items are linked
75+
- **Job Summary**: A summary of all linked work items is added to the workflow run's job summary page, providing a quick reference of work items associated with the PR
76+
7077
## Screenshots
7178

7279
### Failing pull request, including comment back to the pull request showing why it failed

TESTING.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
## Test Summary
44

5-
**Bash Tests: 25/25 Passing**
5+
**Bash Tests: 32/32 Passing**
66
**JavaScript Tests: 3/3 Passing**
77

88
## Overview
99

1010
This project has two types of tests:
1111

12-
1. **Bash Script Tests** - Tests for the core action logic in `action.yml` ✅ (25 tests passing)
12+
1. **Bash Script Tests** - Tests for the core action logic in `action.yml` ✅ (32 tests passing)
1313
2. **JavaScript Tests** - Tests for the work item linking logic in `main.js` ✅ (3 tests passing)
1414

1515
## Bash Script Tests
@@ -47,9 +47,15 @@ The bash script tests focus on the core validation and automation logic.
4747
- Verifying required commands exist (bash, jq, cut, grep, gh)
4848

4949
-**Comment ID Logic** (2 tests)
50+
5051
- Finding existing PR comments by content
5152
- Handling non-existent comments
5253

54+
-**GitHub Actions Annotations** (7 tests)
55+
- Testing notice annotation format for work items
56+
- Testing job summary format for commits and PRs
57+
- Verifying work item information is properly displayed
58+
5359
### Running Bash Tests
5460

5561
```bash
@@ -63,8 +69,8 @@ npm run test:bash
6369
### Bash Test Results
6470

6571
```text
66-
Total Tests: 25
67-
Passed: 25
72+
Total Tests: 32
73+
Passed: 32
6874
All tests passed!
6975
```
7076

@@ -115,10 +121,10 @@ npm test
115121

116122
This will run:
117123

118-
1. Bash tests (25 passing)
124+
1. Bash tests (32 passing)
119125
2. JavaScript tests (3 passing)
120126

121-
**Total: 28 tests passing**
127+
**Total: 35 tests passing**
122128

123129
## Test Files
124130

__tests__/action.test.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,31 @@ test_comment_id_logic() {
270270
fi
271271
}
272272

273+
# Test Suite: GitHub Actions Annotations
274+
test_github_annotations() {
275+
echo ""
276+
echo -e "${YELLOW}Testing: GitHub Actions Annotations${NC}"
277+
echo "========================================"
278+
279+
# Test notice annotation format for work items
280+
WORKITEM_NUMBER="12345"
281+
NOTICE_OUTPUT="::notice title=Work Item Linked::Pull request linked to work item AB#${WORKITEM_NUMBER}"
282+
assert_contains "$NOTICE_OUTPUT" "::notice" "Notice annotation should contain ::notice"
283+
assert_contains "$NOTICE_OUTPUT" "AB#12345" "Notice should include work item number"
284+
assert_contains "$NOTICE_OUTPUT" "title=Work Item Linked" "Notice should have title"
285+
286+
# Test summary format
287+
PULL_NUMBER="42"
288+
SHORT_COMMIT_SHA="abc123d"
289+
SUMMARY_COMMIT="- Commit ${SHORT_COMMIT_SHA} linked to work item AB#${WORKITEM_NUMBER}"
290+
SUMMARY_PR="- Pull request #${PULL_NUMBER} linked to work item AB#${WORKITEM_NUMBER}"
291+
292+
assert_contains "$SUMMARY_COMMIT" "Commit abc123d" "Summary should include short commit SHA"
293+
assert_contains "$SUMMARY_COMMIT" "AB#12345" "Summary should include work item"
294+
assert_contains "$SUMMARY_PR" "Pull request #42" "Summary should include PR number"
295+
assert_contains "$SUMMARY_PR" "AB#12345" "Summary should include work item"
296+
}
297+
273298
# Run all tests
274299
main() {
275300
echo "========================================"
@@ -283,6 +308,7 @@ main() {
283308
test_short_sha
284309
test_env_checks
285310
test_comment_id_logic
311+
test_github_annotations
286312

287313
# Print summary
288314
echo ""

action.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ runs:
9090
echo "Attempting to link work item ${WORKITEM} to pull request ${PULL_NUMBER}..."
9191
REPO_TOKEN=${{ inputs.github-token }} AZURE_DEVOPS_ORG=${{ inputs.azure-devops-organization }} AZURE_DEVOPS_PAT=${{ inputs.azure-devops-token }} WORKITEMID=$WORKITEM PULLREQUESTID=${{ github.event.number }} REPO=${{ github.repository }} node $main
9292
echo "...PR linked to work item"
93+
echo "::notice title=Work Item Linked::Commit linked to work item AB#${WORKITEM}"
94+
echo "- Commit ${SHORT_COMMIT_SHA} linked to work item AB#${WORKITEM}" >> $GITHUB_STEP_SUMMARY
9395
fi
9496
fi
9597
done
@@ -135,8 +137,8 @@ runs:
135137
WORKITEM_NUMBER=${WORKITEM:3}
136138
137139
echo "Pull request linked to work item number: $WORKITEM_NUMBER"
138-
# TODO: validate work item?
139-
# TODO: add this as an ::info or to the job summary?
140+
echo "::notice title=Work Item Linked::Pull request linked to work item AB#${WORKITEM_NUMBER}"
141+
echo "- Pull request #${PULL_NUMBER} linked to work item AB#${WORKITEM_NUMBER}" >> $GITHUB_STEP_SUMMARY
140142
done
141143
fi
142144
fi

0 commit comments

Comments
 (0)