@contractspec/action.pr 0.9.0
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/.contractspec-ci/contracts.json +3 -0
- package/.contractspec-ci/drift-files.txt +0 -0
- package/CHANGELOG.md +120 -0
- package/LICENSE +21 -0
- package/README.md +50 -0
- package/action.yml +288 -0
- package/package.json +35 -0
|
File without changes
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- fix: publish with bun
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @contractspec/bundle.workspace@1.60.0
|
|
13
|
+
- @contractspec/lib.contracts@1.60.0
|
|
14
|
+
|
|
15
|
+
## 0.8.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- 1a0cf44: fix: publishConfig not supported by bun
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Updated dependencies [1a0cf44]
|
|
24
|
+
- @contractspec/bundle.workspace@1.59.0
|
|
25
|
+
- @contractspec/lib.contracts@1.59.0
|
|
26
|
+
|
|
27
|
+
## 0.7.0
|
|
28
|
+
|
|
29
|
+
### Minor Changes
|
|
30
|
+
|
|
31
|
+
- d1f0fd0: chore: Migrate non-app package builds from tsdown to shared Bun tooling, add `@contractspec/tool.bun`, and standardize `prebuild`/`build`/`typecheck` with platform-aware exports and `tsc` declaration emission into `dist`.
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- Updated dependencies [d1f0fd0]
|
|
36
|
+
- Updated dependencies [4355a9e]
|
|
37
|
+
- @contractspec/bundle.workspace@1.58.0
|
|
38
|
+
- @contractspec/lib.contracts@1.58.0
|
|
39
|
+
|
|
40
|
+
## 0.6.0
|
|
41
|
+
|
|
42
|
+
### Minor Changes
|
|
43
|
+
|
|
44
|
+
- 11a5a05: feat: improve product intent
|
|
45
|
+
|
|
46
|
+
### Patch Changes
|
|
47
|
+
|
|
48
|
+
- Updated dependencies [8ecf3c1]
|
|
49
|
+
- Updated dependencies [47c48c2]
|
|
50
|
+
- Updated dependencies [a119963]
|
|
51
|
+
- Updated dependencies [4651e06]
|
|
52
|
+
- Updated dependencies [ad9d10a]
|
|
53
|
+
- Updated dependencies [11a5a05]
|
|
54
|
+
- @contractspec/lib.contracts@1.57.0
|
|
55
|
+
- @contractspec/bundle.workspace@1.57.0
|
|
56
|
+
|
|
57
|
+
## 0.5.1
|
|
58
|
+
|
|
59
|
+
### Patch Changes
|
|
60
|
+
|
|
61
|
+
- fix: improve publish config
|
|
62
|
+
- Updated dependencies
|
|
63
|
+
- @contractspec/bundle.workspace@1.56.1
|
|
64
|
+
- @contractspec/lib.contracts@1.56.1
|
|
65
|
+
|
|
66
|
+
## 0.5.0
|
|
67
|
+
|
|
68
|
+
### Minor Changes
|
|
69
|
+
|
|
70
|
+
- fix: release
|
|
71
|
+
|
|
72
|
+
### Patch Changes
|
|
73
|
+
|
|
74
|
+
- Updated dependencies
|
|
75
|
+
- @contractspec/bundle.workspace@1.56.0
|
|
76
|
+
- @contractspec/lib.contracts@1.56.0
|
|
77
|
+
|
|
78
|
+
## 0.4.0
|
|
79
|
+
|
|
80
|
+
### Minor Changes
|
|
81
|
+
|
|
82
|
+
- fix: unpublished packages
|
|
83
|
+
|
|
84
|
+
### Patch Changes
|
|
85
|
+
|
|
86
|
+
- Updated dependencies
|
|
87
|
+
- @contractspec/bundle.workspace@1.55.0
|
|
88
|
+
- @contractspec/lib.contracts@1.55.0
|
|
89
|
+
|
|
90
|
+
## 0.3.0
|
|
91
|
+
|
|
92
|
+
### Minor Changes
|
|
93
|
+
|
|
94
|
+
- ec5e95c: chore: upgrade dependencies
|
|
95
|
+
|
|
96
|
+
### Patch Changes
|
|
97
|
+
|
|
98
|
+
- Updated dependencies [ec5e95c]
|
|
99
|
+
- @contractspec/lib.contracts@1.54.0
|
|
100
|
+
- @contractspec/bundle.workspace@1.54.0
|
|
101
|
+
|
|
102
|
+
## 0.2.0
|
|
103
|
+
|
|
104
|
+
### Minor Changes
|
|
105
|
+
|
|
106
|
+
- 89d3402: Add new ContractSpec PR and drift actions as the primary automation entrypoints.
|
|
107
|
+
- f4180d4: fix: performance improvement
|
|
108
|
+
- 64d84e1: Add contract-level verification table to impact reports. Defines query and data view contracts for per-contract drift status, surfaces covered, and last verified commit. Reports render the table when contracts data is present; backward compatible when absent.
|
|
109
|
+
|
|
110
|
+
### Patch Changes
|
|
111
|
+
|
|
112
|
+
- Updated dependencies [5b371b1]
|
|
113
|
+
- Updated dependencies [f4180d4]
|
|
114
|
+
- Updated dependencies [64d84e1]
|
|
115
|
+
- @contractspec/lib.contracts@1.53.0
|
|
116
|
+
- @contractspec/bundle.workspace@1.53.0
|
|
117
|
+
|
|
118
|
+
## 0.1.0
|
|
119
|
+
|
|
120
|
+
- Initial release.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Chaman Ventures, SASU
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# ContractSpec PR Action
|
|
2
|
+
|
|
3
|
+
Run ContractSpec PR checks (view, impact, validation, drift) with a reusable GitHub Action.
|
|
4
|
+
|
|
5
|
+
Website: https://contractspec.io/
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```yaml
|
|
10
|
+
name: ContractSpec PR
|
|
11
|
+
|
|
12
|
+
on: pull_request
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
contractspec:
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
permissions:
|
|
18
|
+
contents: read
|
|
19
|
+
pull-requests: write
|
|
20
|
+
steps:
|
|
21
|
+
- uses: actions/checkout@v4
|
|
22
|
+
|
|
23
|
+
- name: ContractSpec PR checks
|
|
24
|
+
uses: lssm-tech/contractspec/packages/apps/action-pr@main
|
|
25
|
+
with:
|
|
26
|
+
generate-command: 'bun contractspec generate'
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Inputs
|
|
30
|
+
|
|
31
|
+
| Input | Description | Default |
|
|
32
|
+
| ------------------- | ----------------------------------- | --------------------- |
|
|
33
|
+
| `package-manager` | `bun`, `npm`, `pnpm`, `yarn` | `bun` |
|
|
34
|
+
| `working-directory` | Repo root or package path | `.` |
|
|
35
|
+
| `report-mode` | `summary`, `comment`, `both`, `off` | `summary` |
|
|
36
|
+
| `enable-drift` | Run generate + drift check | `true` |
|
|
37
|
+
| `fail-on` | `breaking`, `drift`, `any`, `never` | `any` |
|
|
38
|
+
| `generate-command` | Command to regenerate artifacts | empty |
|
|
39
|
+
| `validate-command` | Validation command override | empty |
|
|
40
|
+
| `contracts-dir` | Directory for contract changes | empty |
|
|
41
|
+
| `contracts-glob` | Glob for contract changes | empty |
|
|
42
|
+
| `token` | GitHub token for PR comments | `${{ github.token }}` |
|
|
43
|
+
|
|
44
|
+
## Outputs
|
|
45
|
+
|
|
46
|
+
| Output | Description |
|
|
47
|
+
| -------------------------- | -------------------------------------- |
|
|
48
|
+
| `drift-detected` | Whether drift was detected |
|
|
49
|
+
| `breaking-change-detected` | Whether breaking changes were detected |
|
|
50
|
+
| `validation-failed` | Whether validation failed |
|
package/action.yml
ADDED
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
name: 'ContractSpec PR'
|
|
2
|
+
description: 'Run ContractSpec PR checks (view, impact, validation, drift)'
|
|
3
|
+
author: 'LSSM'
|
|
4
|
+
branding:
|
|
5
|
+
icon: 'check-circle'
|
|
6
|
+
color: 'blue'
|
|
7
|
+
|
|
8
|
+
inputs:
|
|
9
|
+
package-manager:
|
|
10
|
+
description: 'Package manager to use (bun|npm|pnpm|yarn)'
|
|
11
|
+
required: false
|
|
12
|
+
default: 'bun'
|
|
13
|
+
working-directory:
|
|
14
|
+
description: 'Working directory for running commands'
|
|
15
|
+
required: false
|
|
16
|
+
default: '.'
|
|
17
|
+
report-mode:
|
|
18
|
+
description: 'Report output mode (summary|comment|both|off)'
|
|
19
|
+
required: false
|
|
20
|
+
default: 'summary'
|
|
21
|
+
enable-drift:
|
|
22
|
+
description: 'Run drift detection after generate'
|
|
23
|
+
required: false
|
|
24
|
+
default: 'true'
|
|
25
|
+
fail-on:
|
|
26
|
+
description: 'Fail on breaking, drift, any, or never'
|
|
27
|
+
required: false
|
|
28
|
+
default: 'any'
|
|
29
|
+
generate-command:
|
|
30
|
+
description: 'Command to regenerate artifacts (required when enable-drift=true)'
|
|
31
|
+
required: false
|
|
32
|
+
default: 'bun contractspec generate'
|
|
33
|
+
validate-command:
|
|
34
|
+
description: 'Override validation command'
|
|
35
|
+
required: false
|
|
36
|
+
default: ''
|
|
37
|
+
contracts-dir:
|
|
38
|
+
description: 'Directory containing contract specs'
|
|
39
|
+
required: false
|
|
40
|
+
default: ''
|
|
41
|
+
contracts-glob:
|
|
42
|
+
description: 'Glob pattern for contract specs'
|
|
43
|
+
required: false
|
|
44
|
+
default: ''
|
|
45
|
+
token:
|
|
46
|
+
description: 'GitHub token for PR comments'
|
|
47
|
+
required: false
|
|
48
|
+
default: '${{ github.token }}'
|
|
49
|
+
|
|
50
|
+
outputs:
|
|
51
|
+
drift-detected:
|
|
52
|
+
description: 'Whether drift was detected'
|
|
53
|
+
value: ${{ steps.result.outputs.drift_detected }}
|
|
54
|
+
breaking-change-detected:
|
|
55
|
+
description: 'Whether breaking changes were detected'
|
|
56
|
+
value: ${{ steps.result.outputs.breaking_change_detected }}
|
|
57
|
+
validation-failed:
|
|
58
|
+
description: 'Whether validation failed'
|
|
59
|
+
value: ${{ steps.result.outputs.validation_failed }}
|
|
60
|
+
|
|
61
|
+
runs:
|
|
62
|
+
using: 'composite'
|
|
63
|
+
steps:
|
|
64
|
+
- name: Set action defaults
|
|
65
|
+
shell: bash
|
|
66
|
+
run: |
|
|
67
|
+
echo "PACKAGE_MANAGER=${{ inputs.package-manager }}" >> $GITHUB_ENV
|
|
68
|
+
echo "WORKING_DIRECTORY=${{ inputs.working-directory }}" >> $GITHUB_ENV
|
|
69
|
+
echo "REPORT_MODE=${{ inputs.report-mode }}" >> $GITHUB_ENV
|
|
70
|
+
echo "ENABLE_DRIFT=${{ inputs.enable-drift }}" >> $GITHUB_ENV
|
|
71
|
+
echo "FAIL_ON=${{ inputs.fail-on }}" >> $GITHUB_ENV
|
|
72
|
+
echo "GENERATE_COMMAND=${{ inputs.generate-command }}" >> $GITHUB_ENV
|
|
73
|
+
echo "VALIDATE_COMMAND=${{ inputs.validate-command }}" >> $GITHUB_ENV
|
|
74
|
+
echo "CONTRACTS_DIR=${{ inputs.contracts-dir }}" >> $GITHUB_ENV
|
|
75
|
+
echo "CONTRACTS_GLOB=${{ inputs.contracts-glob }}" >> $GITHUB_ENV
|
|
76
|
+
echo "COMMENT_TOKEN=${{ inputs.token }}" >> $GITHUB_ENV
|
|
77
|
+
echo "TURBO_TELEMETRY_DISABLED=1" >> $GITHUB_ENV
|
|
78
|
+
echo "DO_NOT_TRACK=1" >> $GITHUB_ENV
|
|
79
|
+
# Pass through Turbo env vars if present in the calling workflow environment
|
|
80
|
+
if [ -n "$TURBO_TOKEN" ]; then echo "TURBO_TOKEN=$TURBO_TOKEN" >> $GITHUB_ENV; fi
|
|
81
|
+
if [ -n "$TURBO_TEAM" ]; then echo "TURBO_TEAM=$TURBO_TEAM" >> $GITHUB_ENV; fi
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
- name: Setup Bun
|
|
85
|
+
uses: oven-sh/setup-bun@v2
|
|
86
|
+
with:
|
|
87
|
+
bun-version: '1.3.8'
|
|
88
|
+
|
|
89
|
+
- name: Setup Node
|
|
90
|
+
if: env.PACKAGE_MANAGER != 'bun'
|
|
91
|
+
uses: actions/setup-node@v4
|
|
92
|
+
with:
|
|
93
|
+
node-version: '20'
|
|
94
|
+
|
|
95
|
+
- name: Configure ContractSpec command
|
|
96
|
+
shell: bash
|
|
97
|
+
run: |
|
|
98
|
+
case "$PACKAGE_MANAGER" in
|
|
99
|
+
bun)
|
|
100
|
+
echo "CONTRACTSPEC_CMD=bunx contractspec" >> $GITHUB_ENV
|
|
101
|
+
;;
|
|
102
|
+
npm)
|
|
103
|
+
echo "CONTRACTSPEC_CMD=npx contractspec" >> $GITHUB_ENV
|
|
104
|
+
;;
|
|
105
|
+
pnpm)
|
|
106
|
+
echo "CONTRACTSPEC_CMD=pnpm dlx contractspec" >> $GITHUB_ENV
|
|
107
|
+
;;
|
|
108
|
+
yarn)
|
|
109
|
+
echo "CONTRACTSPEC_CMD=yarn dlx contractspec" >> $GITHUB_ENV
|
|
110
|
+
;;
|
|
111
|
+
*)
|
|
112
|
+
echo "::error::Unsupported package-manager: $PACKAGE_MANAGER"
|
|
113
|
+
exit 1
|
|
114
|
+
;;
|
|
115
|
+
esac
|
|
116
|
+
|
|
117
|
+
- name: Install dependencies
|
|
118
|
+
shell: bash
|
|
119
|
+
working-directory: ${{ env.WORKING_DIRECTORY }}
|
|
120
|
+
run: |
|
|
121
|
+
case "$PACKAGE_MANAGER" in
|
|
122
|
+
bun)
|
|
123
|
+
if [ -f "bun.lock" ] || [ -f "bun.lockb" ]; then
|
|
124
|
+
bun install --frozen-lockfile
|
|
125
|
+
else
|
|
126
|
+
bun install
|
|
127
|
+
fi
|
|
128
|
+
;;
|
|
129
|
+
npm)
|
|
130
|
+
if [ -f "package-lock.json" ]; then
|
|
131
|
+
npm ci
|
|
132
|
+
else
|
|
133
|
+
npm install
|
|
134
|
+
fi
|
|
135
|
+
;;
|
|
136
|
+
pnpm)
|
|
137
|
+
corepack enable
|
|
138
|
+
pnpm install --frozen-lockfile
|
|
139
|
+
;;
|
|
140
|
+
yarn)
|
|
141
|
+
corepack enable
|
|
142
|
+
yarn install --frozen-lockfile
|
|
143
|
+
;;
|
|
144
|
+
esac
|
|
145
|
+
|
|
146
|
+
- name: Build local ContractSpec CLI (if present)
|
|
147
|
+
if: env.PACKAGE_MANAGER == 'bun'
|
|
148
|
+
shell: bash
|
|
149
|
+
working-directory: ${{ env.WORKING_DIRECTORY }}
|
|
150
|
+
run: |
|
|
151
|
+
if [ -f "packages/apps/cli-contractspec/package.json" ]; then
|
|
152
|
+
bun run build --filter=@contractspec/app.cli-contractspec
|
|
153
|
+
fi
|
|
154
|
+
env:
|
|
155
|
+
TURBO_TOKEN: ${{ env.TURBO_TOKEN }}
|
|
156
|
+
TURBO_TEAM: ${{ env.TURBO_TEAM }}
|
|
157
|
+
|
|
158
|
+
- name: Collect contract changes
|
|
159
|
+
id: changes
|
|
160
|
+
shell: bash
|
|
161
|
+
working-directory: ${{ env.WORKING_DIRECTORY }}
|
|
162
|
+
run: |
|
|
163
|
+
mkdir -p .contractspec-ci
|
|
164
|
+
BASELINE="${{ github.base_ref }}"
|
|
165
|
+
if [ -n "$BASELINE" ]; then
|
|
166
|
+
git fetch origin "$BASELINE" --depth=1 || true
|
|
167
|
+
BASELINE="origin/$BASELINE"
|
|
168
|
+
else
|
|
169
|
+
BASELINE="HEAD~1"
|
|
170
|
+
fi
|
|
171
|
+
echo "BASELINE=$BASELINE" >> $GITHUB_ENV
|
|
172
|
+
git diff --name-only "$BASELINE"...HEAD > .contractspec-ci/changed-files.txt
|
|
173
|
+
$CONTRACTSPEC_CMD action-pr collect-changes
|
|
174
|
+
|
|
175
|
+
- name: Generate contract view
|
|
176
|
+
shell: bash
|
|
177
|
+
working-directory: ${{ env.WORKING_DIRECTORY }}
|
|
178
|
+
run: |
|
|
179
|
+
set +e
|
|
180
|
+
$CONTRACTSPEC_CMD view --audience product --baseline "$BASELINE" > .contractspec-ci/product-view.md
|
|
181
|
+
VIEW_EXIT=$?
|
|
182
|
+
set -e
|
|
183
|
+
if [ $VIEW_EXIT -ne 0 ]; then
|
|
184
|
+
echo "Contract view failed (exit $VIEW_EXIT)." > .contractspec-ci/product-view.md
|
|
185
|
+
fi
|
|
186
|
+
|
|
187
|
+
- name: Run impact analysis
|
|
188
|
+
shell: bash
|
|
189
|
+
working-directory: ${{ env.WORKING_DIRECTORY }}
|
|
190
|
+
run: |
|
|
191
|
+
set +e
|
|
192
|
+
$CONTRACTSPEC_CMD impact --baseline "$BASELINE" --format json > .contractspec-ci/impact.json
|
|
193
|
+
IMPACT_EXIT=$?
|
|
194
|
+
set -e
|
|
195
|
+
if [ $IMPACT_EXIT -ne 0 ]; then
|
|
196
|
+
echo "{}" > .contractspec-ci/impact.json
|
|
197
|
+
fi
|
|
198
|
+
|
|
199
|
+
- name: Validate contracts
|
|
200
|
+
id: validate
|
|
201
|
+
shell: bash
|
|
202
|
+
working-directory: ${{ env.WORKING_DIRECTORY }}
|
|
203
|
+
run: |
|
|
204
|
+
set +e
|
|
205
|
+
if [ -n "$VALIDATE_COMMAND" ]; then
|
|
206
|
+
bash -lc "$VALIDATE_COMMAND" 2>&1 | tee .contractspec-ci/validation.txt
|
|
207
|
+
else
|
|
208
|
+
$CONTRACTSPEC_CMD validate 2>&1 | tee .contractspec-ci/validation.txt
|
|
209
|
+
fi
|
|
210
|
+
VALIDATION_EXIT=${PIPESTATUS[0]}
|
|
211
|
+
set -e
|
|
212
|
+
if [ $VALIDATION_EXIT -eq 0 ]; then
|
|
213
|
+
echo "VALIDATION_STATUS=pass" >> $GITHUB_ENV
|
|
214
|
+
echo "VALIDATION_FAILED=false" >> $GITHUB_ENV
|
|
215
|
+
else
|
|
216
|
+
echo "VALIDATION_STATUS=fail" >> $GITHUB_ENV
|
|
217
|
+
echo "VALIDATION_FAILED=true" >> $GITHUB_ENV
|
|
218
|
+
fi
|
|
219
|
+
|
|
220
|
+
- name: Run generate command
|
|
221
|
+
if: env.ENABLE_DRIFT == 'true'
|
|
222
|
+
shell: bash
|
|
223
|
+
working-directory: ${{ env.WORKING_DIRECTORY }}
|
|
224
|
+
run: |
|
|
225
|
+
if [ -z "$GENERATE_COMMAND" ]; then
|
|
226
|
+
echo "::error::generate-command is required when enable-drift=true"
|
|
227
|
+
exit 1
|
|
228
|
+
fi
|
|
229
|
+
bash -lc "$GENERATE_COMMAND"
|
|
230
|
+
|
|
231
|
+
- name: Check drift
|
|
232
|
+
if: env.ENABLE_DRIFT == 'true'
|
|
233
|
+
shell: bash
|
|
234
|
+
working-directory: ${{ env.WORKING_DIRECTORY }}
|
|
235
|
+
run: |
|
|
236
|
+
git status --porcelain > .contractspec-ci/drift-status.txt
|
|
237
|
+
$CONTRACTSPEC_CMD action-pr check-drift
|
|
238
|
+
|
|
239
|
+
- name: Mark drift as skipped
|
|
240
|
+
if: env.ENABLE_DRIFT != 'true'
|
|
241
|
+
shell: bash
|
|
242
|
+
run: |
|
|
243
|
+
echo "DRIFT_STATUS=skipped" >> $GITHUB_ENV
|
|
244
|
+
echo "DRIFT_DETECTED=false" >> $GITHUB_ENV
|
|
245
|
+
|
|
246
|
+
- name: Build report data
|
|
247
|
+
shell: bash
|
|
248
|
+
working-directory: ${{ env.WORKING_DIRECTORY }}
|
|
249
|
+
run: |
|
|
250
|
+
# Collect contract verification status
|
|
251
|
+
echo "Collecting contract verification status..."
|
|
252
|
+
$CONTRACTSPEC_CMD action-pr get-contract-status
|
|
253
|
+
|
|
254
|
+
# Build report data
|
|
255
|
+
$CONTRACTSPEC_CMD action-pr build-report-data
|
|
256
|
+
|
|
257
|
+
- name: Generate report
|
|
258
|
+
shell: bash
|
|
259
|
+
working-directory: ${{ env.WORKING_DIRECTORY }}
|
|
260
|
+
run: |
|
|
261
|
+
$CONTRACTSPEC_CMD action-pr generate-report
|
|
262
|
+
|
|
263
|
+
- name: Comment on PR
|
|
264
|
+
if: ${{ github.event.pull_request && (inputs.report-mode == 'comment' || inputs.report-mode == 'both') && !github.event.pull_request.head.repo.fork }}
|
|
265
|
+
uses: actions/github-script@v7
|
|
266
|
+
with:
|
|
267
|
+
github-token: ${{ env.COMMENT_TOKEN }}
|
|
268
|
+
script: |
|
|
269
|
+
const fs = require("fs");
|
|
270
|
+
const path = `${process.env.WORKING_DIRECTORY}/.contractspec-ci/report.md`;
|
|
271
|
+
const report = fs.readFileSync(path, "utf8");
|
|
272
|
+
const runUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
|
|
273
|
+
const header = `## ContractSpec Report (run ${context.runId})`;
|
|
274
|
+
const body = `${header}\n${runUrl}\n\n${report}`;
|
|
275
|
+
|
|
276
|
+
await github.rest.issues.createComment({
|
|
277
|
+
owner: context.repo.owner,
|
|
278
|
+
repo: context.repo.repo,
|
|
279
|
+
issue_number: context.issue.number,
|
|
280
|
+
body,
|
|
281
|
+
});
|
|
282
|
+
continue-on-error: true
|
|
283
|
+
|
|
284
|
+
- name: Finalize results
|
|
285
|
+
id: result
|
|
286
|
+
shell: bash
|
|
287
|
+
run: |
|
|
288
|
+
$CONTRACTSPEC_CMD action-pr finalize
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@contractspec/action.pr",
|
|
3
|
+
"version": "0.9.0",
|
|
4
|
+
"description": "GitHub Action for ContractSpec PR checks",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/lssm-tech/contractspec.git",
|
|
8
|
+
"directory": "packages/apps/action-pr"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"github-action",
|
|
12
|
+
"contractspec",
|
|
13
|
+
"pr",
|
|
14
|
+
"drift",
|
|
15
|
+
"validation"
|
|
16
|
+
],
|
|
17
|
+
"author": "LSSM",
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@contractspec/lib.contracts": "1.60.0",
|
|
21
|
+
"@contractspec/bundle.workspace": "1.60.0"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@contractspec/tool.typescript": "1.60.0",
|
|
25
|
+
"@types/bun": "^1.3.8",
|
|
26
|
+
"@types/node": "^25.2.1",
|
|
27
|
+
"eslint": "^9.39.2",
|
|
28
|
+
"typescript": "^5.9.3"
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"registry": "https://registry.npmjs.org/",
|
|
32
|
+
"access": "public"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://contractspec.io"
|
|
35
|
+
}
|