From 28bb4cbf01a49072af421bdf05ee2b684055929b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 7 Oct 2025 16:35:36 +0000 Subject: [PATCH 1/3] Initial plan From b047bed9cf2e6fee137949fe6024f4b60a45303a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 7 Oct 2025 16:43:47 +0000 Subject: [PATCH 2/3] Add work item linkage information to job summary and notices Co-authored-by: joshjohanning <19912012+joshjohanning@users.noreply.github.com> --- README.md | 7 +++++++ TESTING.md | 18 ++++++++++++------ __tests__/action.test.sh | 26 ++++++++++++++++++++++++++ action.yml | 6 ++++-- 4 files changed, 49 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index f87ed75..748b555 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,13 @@ Required software installed on runner: - `grep` - `cut` +### Action Output + +The action provides visibility into linked work items through: + +- **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 +- **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 + ## Screenshots ### Failing pull request, including comment back to the pull request showing why it failed diff --git a/TESTING.md b/TESTING.md index 353cc31..ed68e3e 100644 --- a/TESTING.md +++ b/TESTING.md @@ -2,14 +2,14 @@ ## Test Summary -✅ **Bash Tests: 25/25 Passing** +✅ **Bash Tests: 32/32 Passing** ✅ **JavaScript Tests: 3/3 Passing** ## Overview This project has two types of tests: -1. **Bash Script Tests** - Tests for the core action logic in `action.yml` ✅ (25 tests passing) +1. **Bash Script Tests** - Tests for the core action logic in `action.yml` ✅ (32 tests passing) 2. **JavaScript Tests** - Tests for the work item linking logic in `main.js` ✅ (3 tests passing) ## Bash Script Tests @@ -47,9 +47,15 @@ The bash script tests focus on the core validation and automation logic. - Verifying required commands exist (bash, jq, cut, grep, gh) - ✅ **Comment ID Logic** (2 tests) + - Finding existing PR comments by content - Handling non-existent comments +- ✅ **GitHub Actions Annotations** (7 tests) + - Testing notice annotation format for work items + - Testing job summary format for commits and PRs + - Verifying work item information is properly displayed + ### Running Bash Tests ```bash @@ -63,8 +69,8 @@ npm run test:bash ### Bash Test Results ```text -Total Tests: 25 -Passed: 25 +Total Tests: 32 +Passed: 32 All tests passed! ``` @@ -115,10 +121,10 @@ npm test This will run: -1. Bash tests (25 passing) +1. Bash tests (32 passing) 2. JavaScript tests (3 passing) -**Total: 28 tests passing** ✅ +**Total: 35 tests passing** ✅ ## Test Files diff --git a/__tests__/action.test.sh b/__tests__/action.test.sh index 3579332..4a1d385 100755 --- a/__tests__/action.test.sh +++ b/__tests__/action.test.sh @@ -270,6 +270,31 @@ test_comment_id_logic() { fi } +# Test Suite: GitHub Actions Annotations +test_github_annotations() { + echo "" + echo -e "${YELLOW}Testing: GitHub Actions Annotations${NC}" + echo "========================================" + + # Test notice annotation format for work items + WORKITEM_NUMBER="12345" + NOTICE_OUTPUT="::notice title=Work Item Linked::Pull request linked to work item AB#${WORKITEM_NUMBER}" + assert_contains "$NOTICE_OUTPUT" "::notice" "Notice annotation should contain ::notice" + assert_contains "$NOTICE_OUTPUT" "AB#12345" "Notice should include work item number" + assert_contains "$NOTICE_OUTPUT" "title=Work Item Linked" "Notice should have title" + + # Test summary format + PULL_NUMBER="42" + SHORT_COMMIT_SHA="abc123d" + SUMMARY_COMMIT="- Commit ${SHORT_COMMIT_SHA} linked to work item AB#${WORKITEM_NUMBER}" + SUMMARY_PR="- Pull request #${PULL_NUMBER} linked to work item AB#${WORKITEM_NUMBER}" + + assert_contains "$SUMMARY_COMMIT" "Commit abc123d" "Summary should include short commit SHA" + assert_contains "$SUMMARY_COMMIT" "AB#12345" "Summary should include work item" + assert_contains "$SUMMARY_PR" "Pull request #42" "Summary should include PR number" + assert_contains "$SUMMARY_PR" "AB#12345" "Summary should include work item" +} + # Run all tests main() { echo "========================================" @@ -283,6 +308,7 @@ main() { test_short_sha test_env_checks test_comment_id_logic + test_github_annotations # Print summary echo "" diff --git a/action.yml b/action.yml index 291e094..40cbff4 100644 --- a/action.yml +++ b/action.yml @@ -90,6 +90,8 @@ runs: echo "Attempting to link work item ${WORKITEM} to pull request ${PULL_NUMBER}..." 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 echo "...PR linked to work item" + echo "::notice title=Work Item Linked::Commit linked to work item AB#${WORKITEM}" + echo "- Commit ${SHORT_COMMIT_SHA} linked to work item AB#${WORKITEM}" >> $GITHUB_STEP_SUMMARY fi fi done @@ -135,8 +137,8 @@ runs: WORKITEM_NUMBER=${WORKITEM:3} echo "Pull request linked to work item number: $WORKITEM_NUMBER" - # TODO: validate work item? - # TODO: add this as an ::info or to the job summary? + echo "::notice title=Work Item Linked::Pull request linked to work item AB#${WORKITEM_NUMBER}" + echo "- Pull request #${PULL_NUMBER} linked to work item AB#${WORKITEM_NUMBER}" >> $GITHUB_STEP_SUMMARY done fi fi From 072aea1ce194033af48caa8592de16c2be04790a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 7 Oct 2025 16:47:05 +0000 Subject: [PATCH 3/3] Improve work item linkage messages based on code review feedback Co-authored-by: joshjohanning <19912012+joshjohanning@users.noreply.github.com> --- TESTING.md | 14 +++++++------- __tests__/action.test.sh | 7 ++++--- action.yml | 4 ++-- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/TESTING.md b/TESTING.md index ed68e3e..04e6dbd 100644 --- a/TESTING.md +++ b/TESTING.md @@ -2,14 +2,14 @@ ## Test Summary -✅ **Bash Tests: 32/32 Passing** +✅ **Bash Tests: 33/33 Passing** ✅ **JavaScript Tests: 3/3 Passing** ## Overview This project has two types of tests: -1. **Bash Script Tests** - Tests for the core action logic in `action.yml` ✅ (32 tests passing) +1. **Bash Script Tests** - Tests for the core action logic in `action.yml` ✅ (33 tests passing) 2. **JavaScript Tests** - Tests for the work item linking logic in `main.js` ✅ (3 tests passing) ## Bash Script Tests @@ -51,7 +51,7 @@ The bash script tests focus on the core validation and automation logic. - Finding existing PR comments by content - Handling non-existent comments -- ✅ **GitHub Actions Annotations** (7 tests) +- ✅ **GitHub Actions Annotations** (8 tests) - Testing notice annotation format for work items - Testing job summary format for commits and PRs - Verifying work item information is properly displayed @@ -69,8 +69,8 @@ npm run test:bash ### Bash Test Results ```text -Total Tests: 32 -Passed: 32 +Total Tests: 33 +Passed: 33 All tests passed! ``` @@ -121,10 +121,10 @@ npm test This will run: -1. Bash tests (32 passing) +1. Bash tests (33 passing) 2. JavaScript tests (3 passing) -**Total: 35 tests passing** ✅ +**Total: 36 tests passing** ✅ ## Test Files diff --git a/__tests__/action.test.sh b/__tests__/action.test.sh index 4a1d385..6e0ea8a 100755 --- a/__tests__/action.test.sh +++ b/__tests__/action.test.sh @@ -286,11 +286,12 @@ test_github_annotations() { # Test summary format PULL_NUMBER="42" SHORT_COMMIT_SHA="abc123d" - SUMMARY_COMMIT="- Commit ${SHORT_COMMIT_SHA} linked to work item AB#${WORKITEM_NUMBER}" + SUMMARY_COMMIT="- Work item AB#${WORKITEM_NUMBER} (from commit ${SHORT_COMMIT_SHA}) linked to pull request #${PULL_NUMBER}" SUMMARY_PR="- Pull request #${PULL_NUMBER} linked to work item AB#${WORKITEM_NUMBER}" - assert_contains "$SUMMARY_COMMIT" "Commit abc123d" "Summary should include short commit SHA" - assert_contains "$SUMMARY_COMMIT" "AB#12345" "Summary should include work item" + assert_contains "$SUMMARY_COMMIT" "Work item AB#12345" "Summary should include work item" + assert_contains "$SUMMARY_COMMIT" "from commit abc123d" "Summary should include commit SHA" + assert_contains "$SUMMARY_COMMIT" "pull request #42" "Summary should include PR number" assert_contains "$SUMMARY_PR" "Pull request #42" "Summary should include PR number" assert_contains "$SUMMARY_PR" "AB#12345" "Summary should include work item" } diff --git a/action.yml b/action.yml index 40cbff4..6bef00c 100644 --- a/action.yml +++ b/action.yml @@ -90,8 +90,8 @@ runs: echo "Attempting to link work item ${WORKITEM} to pull request ${PULL_NUMBER}..." 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 echo "...PR linked to work item" - echo "::notice title=Work Item Linked::Commit linked to work item AB#${WORKITEM}" - echo "- Commit ${SHORT_COMMIT_SHA} linked to work item AB#${WORKITEM}" >> $GITHUB_STEP_SUMMARY + echo "::notice title=Work Item Linked::Work item AB#${WORKITEM} (from commit ${SHORT_COMMIT_SHA}) linked to pull request #${PULL_NUMBER}" + echo "- Work item AB#${WORKITEM} (from commit ${SHORT_COMMIT_SHA}) linked to pull request #${PULL_NUMBER}" >> $GITHUB_STEP_SUMMARY fi fi done