Skip to content

Extract shared comment logic; add Azure DevOps adapter#3

Open
tupe12334 wants to merge 1 commit into
mainfrom
fix/issue-1-azure-devops-support
Open

Extract shared comment logic; add Azure DevOps adapter#3
tupe12334 wants to merge 1 commit into
mainfrom
fix/issue-1-azure-devops-support

Conversation

@tupe12334

Copy link
Copy Markdown
Member

Summary

Implements the refactor + adapter part of #1:

  • Extracts the platform-agnostic comment body into src/comment.mjs (buildCommentBody({ owner, repo, issue })), matching the issue's proposed shared module.
  • Moves the GitHub Actions logic into src/github/index.mjs. Behavior is unchanged — it still guards on issues.opened, reads the same context, and posts via Octokit the same way. dist/index.mjs was rebuilt from the new entrypoint (ncc build src/github/index.mjs) and action.yml still points at dist/index.mjs, so the published action's behavior is identical.
  • Adds src/azure/index.mjs, an Azure DevOps adapter that posts to the Work Item Comments REST API using PAT auth (Basic auth, empty username), reusing buildCommentBody from the shared module. Includes unit tests with a mocked fetch.
  • Adds node --test-based unit tests (Node's built-in test runner — no new dependency) for comment.mjs and the Azure adapter's HTTP call, plus a test script in package.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:

  • Trigger wiring: Azure DevOps pipelines don't natively fire on "work item created" the way GitHub Actions fires on 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 new action.yml/pipeline task, a build step, or CI here.
  • Auth: implemented PAT (Basic auth) only, as the simplest option per the ADO REST API docs. Service-connection auth (OAuth/token exchange) is not implemented — no consumer for it yet.
  • Whether the Azure adapter ships as a separate GitHub Action/repo or a new entry point in this repo — left as-is (new entry point in this repo, unwired) pending a decision.

Test plan

  • pnpm test — all unit tests pass (comment.mjs, azure/index.mjs)
  • pnpm lint — clean
  • pnpm build — regenerates dist/index.mjs from the new src/github/index.mjs entrypoint; diffed the output to confirm the GitHub adapter logic is unchanged, just re-composed through comment.mjs

Relates to #1

This pull request was opened by the Open issues → fix PRs (owned repos + my orgs) routine of moadim.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant