@contractspec/action.validation 3.7.6 → 3.7.8

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @contractspec/action.validation
2
2
 
3
+ ## 3.7.8
4
+
5
+ ### Patch Changes
6
+
7
+ - 1a44cb6: feat: improve examples to increase coverage of Contracts type
8
+
9
+ ## 3.7.7
10
+
11
+ ### Patch Changes
12
+
13
+ - fix: release
14
+
3
15
  ## 3.7.6
4
16
 
5
17
  ### Patch Changes
@@ -368,14 +380,17 @@
368
380
  feat: Contract layers support (features, examples, app-configs)
369
381
 
370
382
  ### New CLI Commands
383
+
371
384
  - `contractspec list layers` - List all contract layers with filtering
372
385
 
373
386
  ### Enhanced Commands
387
+
374
388
  - `contractspec ci` - New `layers` check category validates features/examples/config
375
389
  - `contractspec doctor` - New `layers` health checks
376
390
  - `contractspec integrity` - Now shows layer statistics
377
391
 
378
392
  ### New APIs
393
+
379
394
  - `discoverLayers()` - Scan workspace for all layer files
380
395
  - `scanExampleSource()` - Parse ExampleSpec from source code
381
396
  - `isExampleFile()` - Check if file is an example spec
package/README.md CHANGED
@@ -1,286 +1,71 @@
1
- # ContractSpec CI GitHub Action
1
+ # @contractspec/action.validation
2
2
 
3
- > Note: This action is now an internal helper. Prefer `packages/apps/action-pr` and `packages/apps/action-drift`.
3
+ Website: https://contractspec.io
4
4
 
5
- Website: https://contractspec.io/
5
+ **ContractSpec GitHub Action for CI/CD integration. Wraps the `contractspec ci` CLI command as a composite action.**
6
6
 
7
- Run ContractSpec validation checks in your CI/CD pipeline with automatic SARIF upload to GitHub Code Scanning.
7
+ ## What It Does
8
8
 
9
- ## Usage
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
- - name: Run ContractSpec CI
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
- ### Validation Mode Inputs
89
-
90
- | Input | Description | Required | Default |
91
- | ------------------- | ---------------------------------------- | -------- | ---------- |
92
- | `mode` | Action mode: `validate` or `impact` | No | `validate` |
93
- | `checks` | Checks to run (comma-separated) or "all" | No | `all` |
94
- | `skip` | Checks to skip (comma-separated) | No | `''` |
95
- | `pattern` | Glob pattern for spec discovery | No | `''` |
96
- | `fail-on-warnings` | Fail the action on warnings | No | `false` |
97
- | `check-handlers` | Include handler implementation checks | No | `false` |
98
- | `check-tests` | Include test coverage checks | No | `false` |
99
- | `upload-sarif` | Upload SARIF to GitHub Code Scanning | No | `true` |
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
- ### Validation Mode Outputs
125
-
126
- | Output | Description |
127
- | ------------ | ------------------------------------------ |
128
- | `success` | Whether all checks passed (`true`/`false`) |
129
- | `errors` | Number of errors found |
130
- | `warnings` | Number of warnings found |
131
- | `sarif-file` | Path to SARIF output file |
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
- ### Skip Doctor Checks in CI
51
+ ## Key Files
248
52
 
249
- ```yaml
250
- - uses: lssm/contractspec-action@v1
251
- with:
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
- ```yaml
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
- ## Using Without the Action
59
+ - `bun run test` — bun test
272
60
 
273
- If you prefer to run ContractSpec directly without the action:
61
+ ## Recent Updates
274
62
 
275
- ```yaml
276
- - uses: oven-sh/setup-bun@v2
277
- - run: bun install
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
- ## License
67
+ ## Notes
285
68
 
286
- MIT
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
- "name": "@contractspec/action.validation",
3
- "version": "3.7.6",
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"
2
+ "name": "@contractspec/action.validation",
3
+ "version": "3.7.8",
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
  }
@@ -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
- 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
- });
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
- 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
- });
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
  });