@contractspec/action.validation 3.7.6 → 3.7.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/CHANGELOG.md +21 -0
- package/README.md +43 -258
- package/package.json +25 -25
- package/tests/action.test.js +12 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @contractspec/action.validation
|
|
2
2
|
|
|
3
|
+
## 3.7.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fix: release
|
|
8
|
+
|
|
9
|
+
## 3.7.8
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 1a44cb6: feat: improve examples to increase coverage of Contracts type
|
|
14
|
+
|
|
15
|
+
## 3.7.7
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- fix: release
|
|
20
|
+
|
|
3
21
|
## 3.7.6
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -368,14 +386,17 @@
|
|
|
368
386
|
feat: Contract layers support (features, examples, app-configs)
|
|
369
387
|
|
|
370
388
|
### New CLI Commands
|
|
389
|
+
|
|
371
390
|
- `contractspec list layers` - List all contract layers with filtering
|
|
372
391
|
|
|
373
392
|
### Enhanced Commands
|
|
393
|
+
|
|
374
394
|
- `contractspec ci` - New `layers` check category validates features/examples/config
|
|
375
395
|
- `contractspec doctor` - New `layers` health checks
|
|
376
396
|
- `contractspec integrity` - Now shows layer statistics
|
|
377
397
|
|
|
378
398
|
### New APIs
|
|
399
|
+
|
|
379
400
|
- `discoverLayers()` - Scan workspace for all layer files
|
|
380
401
|
- `scanExampleSource()` - Parse ExampleSpec from source code
|
|
381
402
|
- `isExampleFile()` - Check if file is an example spec
|
package/README.md
CHANGED
|
@@ -1,286 +1,71 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @contractspec/action.validation
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Website: https://contractspec.io
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**ContractSpec GitHub Action for CI/CD integration. Wraps the `contractspec ci` CLI command as a composite action.**
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## What It Does
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
### Basic Usage
|
|
12
|
-
|
|
13
|
-
```yaml
|
|
14
|
-
name: ContractSpec CI
|
|
15
|
-
|
|
16
|
-
on: [push, pull_request]
|
|
17
|
-
|
|
18
|
-
jobs:
|
|
19
|
-
contractspec:
|
|
20
|
-
runs-on: ubuntu-latest
|
|
21
|
-
steps:
|
|
22
|
-
- uses: actions/checkout@v4
|
|
9
|
+
- **Layer**: app (GitHub Action)
|
|
10
|
+
- **Consumers**: external CI/CD pipelines via `lssm/contractspec-action@v1`
|
|
23
11
|
|
|
24
|
-
|
|
25
|
-
uses: lssm/contractspec-action@v1
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
### Full Configuration
|
|
12
|
+
## Usage
|
|
29
13
|
|
|
30
14
|
```yaml
|
|
31
15
|
name: ContractSpec CI
|
|
32
|
-
|
|
33
|
-
on:
|
|
34
|
-
push:
|
|
35
|
-
branches: [main]
|
|
36
|
-
pull_request:
|
|
37
|
-
|
|
16
|
+
on: pull_request
|
|
38
17
|
jobs:
|
|
39
18
|
contractspec:
|
|
40
19
|
runs-on: ubuntu-latest
|
|
41
|
-
permissions:
|
|
42
|
-
contents: read
|
|
43
|
-
security-events: write # Required for SARIF upload
|
|
44
20
|
steps:
|
|
45
21
|
- uses: actions/checkout@v4
|
|
46
|
-
|
|
47
|
-
- name: Run ContractSpec CI
|
|
48
|
-
id: contractspec
|
|
49
|
-
uses: lssm/contractspec-action@v1
|
|
50
|
-
with:
|
|
51
|
-
# Run specific checks (default: all)
|
|
52
|
-
checks: 'structure,integrity,deps'
|
|
53
|
-
|
|
54
|
-
# Skip specific checks
|
|
55
|
-
skip: 'doctor'
|
|
56
|
-
|
|
57
|
-
# Glob pattern for spec discovery
|
|
58
|
-
pattern: 'src/**/*.contracts.ts'
|
|
59
|
-
|
|
60
|
-
# Fail on warnings (default: false)
|
|
61
|
-
fail-on-warnings: false
|
|
62
|
-
|
|
63
|
-
# Include handler checks (default: false)
|
|
64
|
-
check-handlers: true
|
|
65
|
-
|
|
66
|
-
# Include test checks (default: false)
|
|
67
|
-
check-tests: true
|
|
68
|
-
|
|
69
|
-
# Upload SARIF to GitHub Code Scanning (default: true)
|
|
70
|
-
upload-sarif: true
|
|
71
|
-
|
|
72
|
-
# Working directory (default: .)
|
|
73
|
-
working-directory: '.'
|
|
74
|
-
|
|
75
|
-
# Bun version (default: latest)
|
|
76
|
-
bun-version: 'latest'
|
|
77
|
-
|
|
78
|
-
- name: Check results
|
|
79
|
-
if: always()
|
|
80
|
-
run: |
|
|
81
|
-
echo "Success: ${{ steps.contractspec.outputs.success }}"
|
|
82
|
-
echo "Errors: ${{ steps.contractspec.outputs.errors }}"
|
|
83
|
-
echo "Warnings: ${{ steps.contractspec.outputs.warnings }}"
|
|
22
|
+
- uses: lssm-tech/contractspec/packages/apps/action-validation@main
|
|
84
23
|
```
|
|
85
24
|
|
|
86
25
|
## Inputs
|
|
87
26
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
| `working-directory` | Working directory for running checks | No | `.` |
|
|
101
|
-
| `bun-version` | Bun version to use | No | `latest` |
|
|
102
|
-
|
|
103
|
-
### Impact Detection Inputs
|
|
104
|
-
|
|
105
|
-
| Input | Description | Required | Default |
|
|
106
|
-
| ------------------ | -------------------------------------------------- | -------- | --------------------- |
|
|
107
|
-
| `mode` | Set to `impact` for breaking change detection | No | `validate` |
|
|
108
|
-
| `baseline` | Git ref to compare against (auto-detected from PR) | No | `''` |
|
|
109
|
-
| `pr-comment` | Post impact results as PR comment | No | `true` |
|
|
110
|
-
| `fail-on-breaking` | Fail action if breaking changes detected | No | `true` |
|
|
111
|
-
| `github-token` | GitHub token for PR comments and check runs | No | `${{ github.token }}` |
|
|
112
|
-
|
|
113
|
-
### Available Checks
|
|
114
|
-
|
|
115
|
-
- `structure` - Validate spec structure (meta, io, policy fields)
|
|
116
|
-
- `integrity` - Find orphaned specs and broken references
|
|
117
|
-
- `deps` - Detect circular dependencies and missing refs
|
|
118
|
-
- `doctor` - Check installation health
|
|
119
|
-
- `handlers` - Verify handler implementations exist
|
|
120
|
-
- `tests` - Verify test files exist
|
|
27
|
+
- `checks` (default: `all`) — Checks to run (comma-separated: structure,integrity,deps,doctor,handlers,tests) or "all"
|
|
28
|
+
- `skip` — Checks to skip (comma-separated)
|
|
29
|
+
- `pattern` — Glob pattern for spec discovery
|
|
30
|
+
- `fail-on-warnings` (default: `false`) — Fail the action on warnings (not just errors)
|
|
31
|
+
- `check-handlers` (default: `false`) — Include handler implementation checks
|
|
32
|
+
- `check-tests` (default: `false`) — Include test coverage checks
|
|
33
|
+
- `upload-sarif` (default: `true`) — Upload SARIF results to GitHub Code Scanning
|
|
34
|
+
- `working-directory` (default: `.`) — Working directory for running checks
|
|
35
|
+
- `bun-version` (default: `latest`) — Bun version to use
|
|
36
|
+
- `mode` (default: `validate`) — Action mode: "validate" (run checks) or "impact" (detect breaking changes)
|
|
37
|
+
- `baseline` — Git ref to compare against for impact detection (default: base branch from PR context)
|
|
38
|
+
- `pr-comment` (default: `true`) — Post impact results as PR comment
|
|
121
39
|
|
|
122
40
|
## Outputs
|
|
123
41
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
| `json-file` | Path to JSON output file |
|
|
133
|
-
|
|
134
|
-
### Impact Detection Outputs
|
|
135
|
-
|
|
136
|
-
| Output | Description |
|
|
137
|
-
| -------------------- | --------------------------------------------------------- |
|
|
138
|
-
| `impact-status` | Impact status: `no-impact`, `non-breaking`, or `breaking` |
|
|
139
|
-
| `breaking-count` | Number of breaking changes detected |
|
|
140
|
-
| `non-breaking-count` | Number of non-breaking changes detected |
|
|
141
|
-
|
|
142
|
-
## Impact Detection
|
|
143
|
-
|
|
144
|
-
The action can detect breaking and non-breaking contract changes on PRs, providing:
|
|
145
|
-
|
|
146
|
-
- **✅ No contract impact** - No changes to contracts
|
|
147
|
-
- **⚠️ Contract changed (non-breaking)** - Safe additions or optional field changes
|
|
148
|
-
- **❌ Breaking change detected** - Removals, type changes, or required field additions
|
|
149
|
-
|
|
150
|
-
### PR Comment Output
|
|
151
|
-
|
|
152
|
-
When `pr-comment: true`, the action posts a comment like:
|
|
153
|
-
|
|
154
|
-
```markdown
|
|
155
|
-
## 📋 ContractSpec Impact Analysis
|
|
156
|
-
|
|
157
|
-
❌ **Breaking changes detected**
|
|
158
|
-
|
|
159
|
-
### Summary
|
|
160
|
-
|
|
161
|
-
| Type | Count |
|
|
162
|
-
| --------------- | ----- |
|
|
163
|
-
| 🔴 Breaking | 2 |
|
|
164
|
-
| 🟡 Non-breaking | 3 |
|
|
165
|
-
|
|
166
|
-
### 🔴 Breaking Changes
|
|
167
|
-
|
|
168
|
-
- **orders.create**: Required field 'userId' was removed
|
|
169
|
-
- **orders.get**: Response type changed from 'object' to 'array'
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
## GitHub Code Scanning Integration
|
|
173
|
-
|
|
174
|
-
When `upload-sarif: true` (default), the action uploads SARIF results to GitHub Code Scanning. This provides:
|
|
175
|
-
|
|
176
|
-
- **Inline annotations** on pull requests showing issues at the exact location
|
|
177
|
-
- **Security tab integration** for tracking issues over time
|
|
178
|
-
- **Code scanning alerts** for new issues
|
|
179
|
-
|
|
180
|
-
To enable this feature, ensure your workflow has the `security-events: write` permission:
|
|
181
|
-
|
|
182
|
-
```yaml
|
|
183
|
-
permissions:
|
|
184
|
-
contents: read
|
|
185
|
-
security-events: write
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
## Exit Codes
|
|
189
|
-
|
|
190
|
-
| Code | Description |
|
|
191
|
-
| ---- | ---------------------------------------------------------------- |
|
|
192
|
-
| `0` | All checks passed |
|
|
193
|
-
| `1` | Errors found (or breaking changes with `fail-on-breaking: true`) |
|
|
194
|
-
| `2` | Warnings found (with `fail-on-warnings: true`) |
|
|
195
|
-
|
|
196
|
-
## Examples
|
|
197
|
-
|
|
198
|
-
### Validate on Push and PR
|
|
199
|
-
|
|
200
|
-
```yaml
|
|
201
|
-
name: Validate Contracts
|
|
202
|
-
|
|
203
|
-
on: [push, pull_request]
|
|
204
|
-
|
|
205
|
-
jobs:
|
|
206
|
-
validate:
|
|
207
|
-
runs-on: ubuntu-latest
|
|
208
|
-
steps:
|
|
209
|
-
- uses: actions/checkout@v4
|
|
210
|
-
- uses: lssm-tech/contractspec@action-v1
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
### Impact Detection on PRs
|
|
214
|
-
|
|
215
|
-
```yaml
|
|
216
|
-
name: Contract Impact
|
|
217
|
-
|
|
218
|
-
on: pull_request
|
|
219
|
-
|
|
220
|
-
jobs:
|
|
221
|
-
impact:
|
|
222
|
-
runs-on: ubuntu-latest
|
|
223
|
-
permissions:
|
|
224
|
-
contents: read
|
|
225
|
-
pull-requests: write
|
|
226
|
-
steps:
|
|
227
|
-
- uses: actions/checkout@v4
|
|
228
|
-
with:
|
|
229
|
-
fetch-depth: 0 # Required for git history comparison
|
|
230
|
-
|
|
231
|
-
- uses: lssm-tech/contractspec@action-v1
|
|
232
|
-
with:
|
|
233
|
-
mode: impact
|
|
234
|
-
pr-comment: 'true'
|
|
235
|
-
fail-on-breaking: 'true'
|
|
236
|
-
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
237
|
-
```
|
|
238
|
-
|
|
239
|
-
### Strict Mode (Fail on Warnings)
|
|
240
|
-
|
|
241
|
-
```yaml
|
|
242
|
-
- uses: lssm/contractspec-action@v1
|
|
243
|
-
with:
|
|
244
|
-
fail-on-warnings: true
|
|
245
|
-
```
|
|
42
|
+
- `success` — Whether all checks passed
|
|
43
|
+
- `errors` — Number of errors found
|
|
44
|
+
- `warnings` — Number of warnings found
|
|
45
|
+
- `sarif-file` — Path to SARIF output file (if uploaded)
|
|
46
|
+
- `json-file` — Path to JSON output file
|
|
47
|
+
- `impact-status` — Impact status: "no-impact" | "non-breaking" | "breaking"
|
|
48
|
+
- `breaking-count` — Number of breaking changes detected
|
|
49
|
+
- `non-breaking-count` — Number of non-breaking changes detected
|
|
246
50
|
|
|
247
|
-
|
|
51
|
+
## Key Files
|
|
248
52
|
|
|
249
|
-
|
|
250
|
-
-
|
|
251
|
-
|
|
252
|
-
skip: 'doctor'
|
|
253
|
-
```
|
|
254
|
-
|
|
255
|
-
### Monorepo with Multiple Packages
|
|
53
|
+
- `action.yml` — GitHub Action definition (composite action)
|
|
54
|
+
- `README.md` — Usage documentation
|
|
55
|
+
- `package.json` — Package metadata (private, not published to npm)
|
|
256
56
|
|
|
257
|
-
|
|
258
|
-
jobs:
|
|
259
|
-
contractspec:
|
|
260
|
-
runs-on: ubuntu-latest
|
|
261
|
-
strategy:
|
|
262
|
-
matrix:
|
|
263
|
-
package: [api, web, shared]
|
|
264
|
-
steps:
|
|
265
|
-
- uses: actions/checkout@v4
|
|
266
|
-
- uses: lssm/contractspec-action@v1
|
|
267
|
-
with:
|
|
268
|
-
working-directory: packages/${{ matrix.package }}
|
|
269
|
-
```
|
|
57
|
+
## Local Commands
|
|
270
58
|
|
|
271
|
-
|
|
59
|
+
- `bun run test` — bun test
|
|
272
60
|
|
|
273
|
-
|
|
61
|
+
## Recent Updates
|
|
274
62
|
|
|
275
|
-
|
|
276
|
-
-
|
|
277
|
-
-
|
|
278
|
-
- run: bunx contractspec ci --format sarif --output results.sarif
|
|
279
|
-
- uses: github/codeql-action/upload-sarif@v4
|
|
280
|
-
with:
|
|
281
|
-
sarif_file: results.sarif
|
|
282
|
-
```
|
|
63
|
+
- Replace eslint+prettier by biomejs to optimize speed
|
|
64
|
+
- Stability
|
|
65
|
+
- PublishConfig not supported by bun
|
|
283
66
|
|
|
284
|
-
##
|
|
67
|
+
## Notes
|
|
285
68
|
|
|
286
|
-
|
|
69
|
+
- All input/output changes must be reflected in both `action.yml` and `README.md`.
|
|
70
|
+
- The action is versioned with tags on the repository — breaking input changes require a major version bump.
|
|
71
|
+
- Test locally using `act` or by referencing the local action: `uses: ./packages/apps/action-validation`.
|
package/package.json
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
2
|
+
"name": "@contractspec/action.validation",
|
|
3
|
+
"version": "3.7.9",
|
|
4
|
+
"description": "GitHub Action for running ContractSpec CI checks",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/lssm-tech/contractspec.git",
|
|
8
|
+
"directory": "packages/apps/action-validation"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"github-action",
|
|
12
|
+
"contractspec",
|
|
13
|
+
"ci",
|
|
14
|
+
"validation",
|
|
15
|
+
"contracts"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"test": "bun test"
|
|
19
|
+
},
|
|
20
|
+
"author": "LSSM",
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"registry": "https://registry.npmjs.org/",
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"homepage": "https://contractspec.io"
|
|
27
27
|
}
|
package/tests/action.test.js
CHANGED
|
@@ -6,17 +6,17 @@ const actionPath = join(import.meta.dir, '..', 'action.yml');
|
|
|
6
6
|
const actionYaml = readFileSync(actionPath, 'utf8');
|
|
7
7
|
|
|
8
8
|
describe('action.validation metadata', () => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
it('declares the composite action entrypoint and outputs', () => {
|
|
10
|
+
expect(actionYaml).toContain("name: 'ContractSpec CI'");
|
|
11
|
+
expect(actionYaml).toContain("using: 'composite'");
|
|
12
|
+
expect(actionYaml).toContain('success:');
|
|
13
|
+
expect(actionYaml).toContain('errors:');
|
|
14
|
+
expect(actionYaml).toContain('warnings:');
|
|
15
|
+
});
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
it('runs machine-readable CI output and uploads artifacts', () => {
|
|
18
|
+
expect(actionYaml).toContain('bunx contractspec ci --format json');
|
|
19
|
+
expect(actionYaml).toContain('results.json');
|
|
20
|
+
expect(actionYaml).toContain('results.sarif');
|
|
21
|
+
});
|
|
22
22
|
});
|