dw-sdlc 0.15.0 → 0.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/pr/decide.js CHANGED
@@ -249,14 +249,18 @@ const ROWS = [
249
249
  }
250
250
  },
251
251
  {
252
- when: (pr) => ciOf(pr).length === 0,
253
- answer: (pr, now, policy) => now - Date.parse(pr.headCommittedAt) <= GRACE_SECONDS * 1000
252
+ // A head whose every check was skipped has run nothing: a draft's are, until `ready` starts the run.
253
+ when: (pr) => ciOf(pr).length === 0 || (!pr.draft && ciOf(pr).every((check) => check.bucket === "skipping")),
254
+ answer: (pr, now, policy) => now - Math.max(Date.parse(pr.headCommittedAt), Date.parse(pr.readyAt ?? pr.headCommittedAt)) <=
255
+ GRACE_SECONDS * 1000
254
256
  ? { status: "wait", action: "wait", actor: "script", reason: "unverified", recheckAfter: 15 }
255
257
  : {
256
258
  status: "park",
257
259
  action: "unverified",
258
260
  actor: "dev",
259
- reason: `no check reported on ${pr.head.slice(0, 7)} within ${GRACE_SECONDS} s of its commit`,
261
+ reason: ciOf(pr).length === 0
262
+ ? `no check reported on ${pr.head.slice(0, 7)} within ${GRACE_SECONDS} s of its commit`
263
+ : `every check on ${pr.head.slice(0, 7)} was skipped, ${GRACE_SECONDS} s after its commit or its ready`,
260
264
  command: devCommand(pr, "merge", policy)
261
265
  }
262
266
  },
package/dist/pr/read.d.ts CHANGED
@@ -39,6 +39,8 @@ export declare function defaultBranch(): string;
39
39
  export declare function now(): number;
40
40
  /** The state of `pr` once more, after an action the script performed on it: the same pull request. */
41
41
  export declare function readAgain(pr: PrState, sized: boolean): PrState;
42
+ /** For a test that runs the command in its own process: each case starts with no compare read. */
43
+ export declare function forgetCompares(): void;
42
44
  /** Whether the head of `after` carries the base `before` read: the compare shows it behind by none. */
43
45
  export declare function carriesBase(before: PrState, after: PrState): boolean;
44
46
  /**
package/dist/pr/read.js CHANGED
@@ -164,6 +164,10 @@ export function readAgain(pr, sized) {
164
164
  * once: a compare of two commits never changes.
165
165
  */
166
166
  const COMPARES = new Map();
167
+ /** For a test that runs the command in its own process: each case starts with no compare read. */
168
+ export function forgetCompares() {
169
+ COMPARES.clear();
170
+ }
167
171
  /** The reply of the compare from `from` to `commit`, read once per process; `what` names it when gh refuses it. */
168
172
  function compared(pr, from, commit, what) {
169
173
  const key = `${pr.repo} ${from}...${commit}`;
@@ -10,7 +10,7 @@ export declare const MARK_STATE = "failure";
10
10
  export declare const READ_MARK = "read, findings open";
11
11
  /** How the description of the success the dev's `--accept` posts reads: the head, taken with its Findings open. */
12
12
  export declare const ACCEPTED = "accepted by the dev, findings open";
13
- export declare const QUERY = "query($owner: String!, $name: String!, $number: Int!) {\n repository(owner: $owner, name: $name) {\n pullRequest(number: $number) {\n url number state isDraft mergeable mergeStateStatus reviewDecision headRefOid headRefName baseRefName baseRefOid\n baseRef { target { oid } } viewerDidAuthor mergeCommit { oid }\n latestReviews(first: 100) { nodes { state author { login } commit { oid } } }\n reviewThreads(first: 100) { pageInfo { hasNextPage } nodes { id isResolved isOutdated path line\n comments(first: 1) { nodes { author { login } body } }\n latest: comments(last: 1) { nodes { viewerDidAuthor } } } }\n commits(last: 1) { nodes { commit { committedDate statusCheckRollup {\n contexts(first: 50) { pageInfo { hasNextPage } nodes {\n ... on CheckRun { name status conclusion detailsUrl startedAt isRequired(pullRequestNumber: $number) }\n ... on StatusContext { context state targetUrl createdAt isRequired(pullRequestNumber: $number) } } } } } } }\n history: commits(last: 100) { nodes { commit { oid parents { totalCount } status { context(name: \"dw-sdlc/review\") { state description } } } } }\n }\n }\n}";
13
+ export declare const QUERY = "query($owner: String!, $name: String!, $number: Int!) {\n repository(owner: $owner, name: $name) {\n pullRequest(number: $number) {\n url number state isDraft mergeable mergeStateStatus reviewDecision headRefOid headRefName baseRefName baseRefOid\n baseRef { target { oid } } viewerDidAuthor mergeCommit { oid }\n ready: timelineItems(last: 1, itemTypes: [READY_FOR_REVIEW_EVENT]) { nodes { ... on ReadyForReviewEvent { createdAt } } }\n latestReviews(first: 100) { nodes { state author { login } commit { oid } } }\n reviewThreads(first: 100) { pageInfo { hasNextPage } nodes { id isResolved isOutdated path line\n comments(first: 1) { nodes { author { login } body } }\n latest: comments(last: 1) { nodes { viewerDidAuthor } } } }\n commits(last: 1) { nodes { commit { committedDate statusCheckRollup {\n contexts(first: 50) { pageInfo { hasNextPage } nodes {\n ... on CheckRun { name status conclusion detailsUrl startedAt isRequired(pullRequestNumber: $number) }\n ... on StatusContext { context state targetUrl createdAt isRequired(pullRequestNumber: $number) } } } } } } }\n history: commits(last: 100) { nodes { commit { oid parents { totalCount } status { context(name: \"dw-sdlc/review\") { state description } } } } }\n }\n }\n}";
14
14
  export type Bucket = "pass" | "fail" | "pending" | "skipping";
15
15
  export type CiCheck = {
16
16
  name: string;
@@ -51,6 +51,8 @@ export type PrState = {
51
51
  viewerDidAuthor: boolean;
52
52
  head: string;
53
53
  headCommittedAt: string;
54
+ /** When the pull request last left draft; null when it never was one. */
55
+ readyAt: string | null;
54
56
  branch: string;
55
57
  base: string;
56
58
  /**
package/dist/pr/state.js CHANGED
@@ -20,6 +20,7 @@ export const QUERY = `query($owner: String!, $name: String!, $number: Int!) {
20
20
  pullRequest(number: $number) {
21
21
  url number state isDraft mergeable mergeStateStatus reviewDecision headRefOid headRefName baseRefName baseRefOid
22
22
  baseRef { target { oid } } viewerDidAuthor mergeCommit { oid }
23
+ ready: timelineItems(last: 1, itemTypes: [READY_FOR_REVIEW_EVENT]) { nodes { ... on ReadyForReviewEvent { createdAt } } }
23
24
  latestReviews(first: 100) { nodes { state author { login } commit { oid } } }
24
25
  reviewThreads(first: ${THREADS_READ}) { pageInfo { hasNextPage } nodes { id isResolved isOutdated path line
25
26
  comments(first: 1) { nodes { author { login } body } }
@@ -302,6 +303,7 @@ export function parsePr(reply, repo) {
302
303
  const head = string(pr, "headRefOid");
303
304
  const baseRef = childOrNull(pr, "baseRef");
304
305
  const history = historyOf(pr);
306
+ const [ready] = nodes(pr, "ready");
305
307
  return {
306
308
  url: string(pr, "url"),
307
309
  repo,
@@ -314,6 +316,7 @@ export function parsePr(reply, repo) {
314
316
  viewerDidAuthor: boolean(pr, "viewerDidAuthor"),
315
317
  head,
316
318
  headCommittedAt: time(commit, "committedDate"),
319
+ readyAt: ready === undefined ? null : time(ready, "createdAt"),
317
320
  branch: string(pr, "headRefName"),
318
321
  base: string(pr, "baseRefName"),
319
322
  baseOid: baseRef === null ? string(pr, "baseRefOid") : string(child(baseRef, "target"), "oid"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dw-sdlc",
3
- "version": "0.15.0",
3
+ "version": "0.15.1",
4
4
  "description": "The Gate and the agentic config of a repository: the dw-sdlc bin with the Gate, the setup, the doctor, the config check, the Sync and setup of References, and the Ship script that drives a pull request to merged; the resolver of the config's layers, its JSON Schema and the validator that reads it.",
5
5
  "license": "MIT",
6
6
  "repository": {