|
|
@@ -28,6 +28,34 @@ describe('CI workflow', () => {
|
|
|
})
|
|
|
})
|
|
|
|
|
|
+describe('Issue lifecycle workflow', () => {
|
|
|
+ it('uses review signals instead of rerunning when a draft becomes ready', () => {
|
|
|
+ const lifecycle = loadWorkflow('.github/workflows/issue-lifecycle.yml')
|
|
|
+ const lifecyclePullRequest = workflowEvent(lifecycle, 'pull_request')
|
|
|
+ const lifecycleReview = workflowEvent(lifecycle, 'pull_request_review')
|
|
|
+ const policy = loadWorkflow('.github/workflows/issue-policy.yml')
|
|
|
+ const policyPullRequest = workflowEvent(policy, 'pull_request')
|
|
|
+
|
|
|
+ expect(lifecyclePullRequest.types).not.toContain('ready_for_review')
|
|
|
+ expect(lifecyclePullRequest.types).toContain('review_requested')
|
|
|
+ expect(lifecycleReview.types).toContain('submitted')
|
|
|
+ expect(policyPullRequest.types).toContain('ready_for_review')
|
|
|
+ })
|
|
|
+})
|
|
|
+
|
|
|
+function loadWorkflow(path: string): Record<string, unknown> {
|
|
|
+ const workflow: unknown = yaml.load(readFileSync(resolve(root, path), 'utf8'))
|
|
|
+ if (!isRecord(workflow)) throw new TypeError(`${path} must define a workflow`)
|
|
|
+ return workflow
|
|
|
+}
|
|
|
+
|
|
|
+function workflowEvent(workflow: Record<string, unknown>, event: string): Record<string, unknown> {
|
|
|
+ if (!isRecord(workflow.on) || !isRecord(workflow.on[event])) {
|
|
|
+ throw new TypeError(`workflow must define the ${event} event`)
|
|
|
+ }
|
|
|
+ return workflow.on[event]
|
|
|
+}
|
|
|
+
|
|
|
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
|
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
|
}
|