Extract shared comment logic; add Azure DevOps adapter#3
Open
tupe12334 wants to merge 1 commit into
Open
Conversation
Splits the GitHub-only src/index.mjs into a platform-agnostic src/comment.mjs (buildCommentBody) and a src/github/index.mjs adapter that behaves identically to the previous entrypoint (dist/index.mjs rebuilt, no behavior change). Adds src/azure/index.mjs, an Azure DevOps adapter that posts to the Work Item Comments REST API using PAT (Basic auth), following the same buildCommentBody interface as the GitHub adapter. Not included (left for follow-up, per open questions in the issue): - Wiring the Azure adapter into an action.yml / pipeline task, since ADO pipelines don't natively trigger on "work item created" the way GitHub Actions triggers on "issues.opened" - that needs a service hook or a dedicated task definition, which is a separate design decision. - Service-connection auth as an alternative to PAT. Adds node:test-based unit tests for the shared builder and the new adapter's HTTP call (mocked fetch), plus a test script in package.json.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the refactor + adapter part of #1:
src/comment.mjs(buildCommentBody({ owner, repo, issue })), matching the issue's proposed shared module.src/github/index.mjs. Behavior is unchanged — it still guards onissues.opened, reads the same context, and posts via Octokit the same way.dist/index.mjswas rebuilt from the new entrypoint (ncc build src/github/index.mjs) andaction.ymlstill points atdist/index.mjs, so the published action's behavior is identical.src/azure/index.mjs, an Azure DevOps adapter that posts to the Work Item Comments REST API using PAT auth (Basic auth, empty username), reusingbuildCommentBodyfrom the shared module. Includes unit tests with a mockedfetch.node --test-based unit tests (Node's built-in test runner — no new dependency) forcomment.mjsand the Azure adapter's HTTP call, plus atestscript inpackage.json.Deliberately left out (follow-up)
The issue itself flags several open design questions that this PR does not resolve, since they need a decision rather than a default:
issues.opened— that needs either a service hook (webhook) or a dedicated pipeline task definition. The adapter is written to be called once those env vars (AZURE_DEVOPS_ORG,SYSTEM_TEAMPROJECT,WORKITEM_ID,AZURE_DEVOPS_TOKEN,BUILD_REPOSITORY_NAME) are populated by whatever trigger mechanism is chosen, but it is not wired into a newaction.yml/pipeline task, a build step, or CI here.Test plan
pnpm test— all unit tests pass (comment.mjs,azure/index.mjs)pnpm lint— cleanpnpm build— regeneratesdist/index.mjsfrom the newsrc/github/index.mjsentrypoint; diffed the output to confirm the GitHub adapter logic is unchanged, just re-composed throughcomment.mjsRelates to #1
This pull request was opened by the Open issues → fix PRs (owned repos + my orgs) routine of moadim.