@boxxy/verifier-wringer 0.2.7 → 0.2.9

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/README.md CHANGED
@@ -29,13 +29,16 @@ The package runs on [Bun](https://bun.sh) 1.3 or newer.
29
29
  - `createWringerVerifier({ forge, gateCheck })` returns a `Verifier`. The app passes its forge and
30
30
  the name of the gate check, such as `verify / gate`.
31
31
  - `readAt(pullRequest, head)` reads the latest run of the gate check at `head`. A passed gate reads
32
- `verified` and a failed gate reads `incomplete`, each with the features of the report.
32
+ `verified` and a failed gate reads `incomplete`, each with the features of the report: one
33
+ `verified` feature for each claim, and none for a failed gate.
33
34
  - A head with no gate check run, or one still running, cancelled or skipped, reads `not-covered`.
34
35
  The adapter then never reads the body. A commit status of the gate's name never counts.
35
- - A finished gate with no report in the body, or a report that does not parse, reads `incomplete`
36
- with no features.
37
- - The adapter does no I/O of its own. It reads the forge, and parses the report with wringer's
38
- `parseReportBlock`.
36
+ - A finished gate with no data comment of version 2 in the body, or one that does not parse, reads
37
+ `incomplete` with no features and a `note` that holds the parser's refusal. A report of version 1,
38
+ from before `bun verify publish` wrote version 2, reads the same, and its note says to run
39
+ `bun verify publish` again.
40
+ - The adapter does no I/O of its own. It reads the forge, and reads the data comment with wringer's
41
+ `parseReportComment`.
39
42
 
40
43
  ## Documentation
41
44
 
@@ -0,0 +1,2 @@
1
+ import type { Report } from '@wringer/core';
2
+ export declare function buildMockWringerComment(report: Report): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boxxy/verifier-wringer",
3
- "version": "0.2.7",
3
+ "version": "0.2.9",
4
4
  "description": "boxxy's verifier on wringer: reads the verify gate check and the report in a pull request",
5
5
  "homepage": "https://github.com/zgeoff/boxxy/tree/main/adapters/verifier-wringer#readme",
6
6
  "bugs": "https://github.com/zgeoff/boxxy/issues",
@@ -30,11 +30,11 @@
30
30
  "typecheck": "tsrs --noEmit"
31
31
  },
32
32
  "dependencies": {
33
- "@boxxy/model": "0.2.7",
34
- "@wringer/core": "0.2.0"
33
+ "@boxxy/model": "0.2.9",
34
+ "@wringer/core": "0.3.1"
35
35
  },
36
36
  "devDependencies": {
37
- "@boxxy/dispatch": "0.2.7",
37
+ "@boxxy/dispatch": "0.2.9",
38
38
  "@faker-js/faker": "10.6.0"
39
39
  },
40
40
  "peerDependencies": {
@@ -1,5 +1,5 @@
1
1
  import type { CheckReading, CommitSha, Verifier, VerifyReading } from '@boxxy/model';
2
- import { parseReportBlock } from '@wringer/core';
2
+ import { parseReportComment } from '@wringer/core';
3
3
  import type { WringerVerifierOptions } from './types.ts';
4
4
 
5
5
  // The `Verifier` port on wringer. The gate check in CI computes the fingerprint, which needs a
@@ -32,23 +32,35 @@ function pickGateState(gate: CheckReading | undefined): 'success' | 'failure' |
32
32
  return gate.state === 'success' || gate.state === 'failure' ? gate.state : null;
33
33
  }
34
34
 
35
+ // A claim in the data comment carries no feature status, because staleness needs the diff that
36
+ // only the gate has. A passed gate reads each claim as `verified`, and a failed gate reads no
37
+ // feature. A comment that does not parse reads `incomplete`, with its refusal as the note.
35
38
  function buildVerifyReading(
36
39
  head: CommitSha,
37
40
  gate: 'success' | 'failure',
38
41
  body: string,
39
42
  ): VerifyReading {
40
- const parsed = parseReportBlock(body);
43
+ const parsed = parseReportComment(body);
41
44
 
42
45
  if (!parsed.ok) {
46
+ const note =
47
+ parsed.reason === 'version-1'
48
+ ? `${parsed.message} Run \`bun verify publish\` again.`
49
+ : parsed.message;
50
+
51
+ return { status: 'incomplete', head, features: [], note };
52
+ }
53
+
54
+ if (gate === 'failure') {
43
55
  return { status: 'incomplete', head, features: [] };
44
56
  }
45
57
 
46
58
  return {
47
- status: gate === 'success' ? 'verified' : 'incomplete',
59
+ status: 'verified',
48
60
  head,
49
- features: parsed.report.features.map((feature) => ({
50
- name: feature.name,
51
- status: feature.status,
61
+ features: parsed.comment.claims.map((claim) => ({
62
+ name: claim.feature,
63
+ status: 'verified',
52
64
  })),
53
65
  };
54
66
  }
@@ -0,0 +1,7 @@
1
+ import type { Report } from '@wringer/core';
2
+ import { renderReportComment, toReportComment } from '@wringer/core';
3
+
4
+ // The data comment that `bun verify publish` writes into a pull request body for the report.
5
+ export function buildMockWringerComment(report: Report): string {
6
+ return renderReportComment(toReportComment(report, 'boxxy-verify'));
7
+ }
@@ -8,10 +8,9 @@ interface MockWringerReportInput {
8
8
  // A wringer report against `origin/main` at a random fingerprint. A `verified` or `stale` feature
9
9
  // carries a verdict, and only an `unchanged` feature is unchanged.
10
10
  export function buildMockWringerReport(input: MockWringerReportInput): Report {
11
- const fingerprint = faker.string.hexadecimal({ length: 16, casing: 'lower', prefix: '' });
11
+ const fingerprint = faker.string.hexadecimal({ length: 40, casing: 'lower', prefix: '' });
12
12
 
13
13
  return {
14
- version: 1,
15
14
  base: 'origin/main',
16
15
  fingerprint,
17
16
  complete: input.features.every(
@@ -25,12 +24,15 @@ export function buildMockWringerReport(input: MockWringerReportInput): Report {
25
24
  feature.status === 'verified' || feature.status === 'stale'
26
25
  ? {
27
26
  feature: feature.name,
28
- fingerprint:
27
+ fingerprint,
28
+ featureFingerprint:
29
29
  feature.status === 'verified'
30
30
  ? fingerprint
31
- : faker.string.hexadecimal({ length: 16, casing: 'lower', prefix: '' }),
31
+ : faker.string.hexadecimal({ length: 40, casing: 'lower', prefix: '' }),
32
32
  run: `run-${faker.string.alphanumeric(8)}`,
33
33
  at: faker.date.recent().toISOString(),
34
+ target: { name: 'local', evidence: 'local' as const },
35
+ pin: { kind: 'local' as const },
34
36
  evidence: [],
35
37
  }
36
38
  : null,