Skip to content

Commit ee7ec9b

Browse files
committed
feat: add semantic version checks for contracts
1 parent 2033bc0 commit ee7ec9b

File tree

5 files changed

+803
-0
lines changed

5 files changed

+803
-0
lines changed

.github/workflows/semver-check.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Contract Semver Check
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
- master
8+
- develop
9+
paths:
10+
- 'src/**/*.sol'
11+
- 'semver-lock.json'
12+
- 'scripts/sol-semver.mjs'
13+
14+
jobs:
15+
check-semver:
16+
name: Verify contract semantic version bumps
17+
runs-on: general
18+
container:
19+
image: ${{ vars.GCP_DOCKER_IMAGE_REGISTRY }}/node-extended:f4f41461
20+
credentials:
21+
username: _json_key_base64
22+
password: ${{ secrets.GCP_DOCKER_IMAGES_REGISTRY_SERVICE_ACCOUNT }}
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 0
28+
29+
- name: Init env
30+
run: |
31+
yarn install
32+
forge soldeer install
33+
34+
- name: Check semantic version bumps in changed contracts
35+
env:
36+
BASE_REF: ${{ github.event.pull_request.base.sha }}
37+
HEAD_REF: ${{ github.event.pull_request.head.sha }}
38+
run: |
39+
node scripts/sol-semver.mjs check \
40+
--old-ref "$BASE_REF" \
41+
--new-ref "$HEAD_REF" \
42+
--lock-file semver-lock.json

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,3 +230,16 @@ BaseStrategy (Abstract)
230230
3. Add strategy-specific tests in `test/unit/core/` or `test/unit/zodiac-core/`
231231
4. Create factory in `src/factories/` if permissionless deployment needed
232232
5. Update documentation with strategy-specific details
233+
234+
**Contract semantic versioning checks**:
235+
1. Keep `API_VERSION` (or `VERSION`) in sync with contract interface/storage changes.
236+
2. Update `semver-lock.json` when a tracked contract version changes.
237+
3. Semver classification uses a single built-in mode based on storage, ABI, and bytecode layers.
238+
4. If a changed contract has no version constant, semver check fails and requires adding one in `X.Y.Z` format.
239+
5. Run local checks:
240+
241+
```bash
242+
yarn semver:diff --old-ref origin/develop --new-ref HEAD --contract src/core/MultistrategyVault.sol:MultistrategyVault
243+
yarn semver:check --old-ref origin/develop --new-ref HEAD
244+
node scripts/sol-semver.mjs check --old-ref origin/develop --new-ref HEAD --lock-file semver-lock.json
245+
```

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
"slither:setup": "python3 -m venv .venv && .venv/bin/pip3 install slither-analyzer",
4040
"slither": ".venv/bin/slither . --print human-summary",
4141
"slither:ci": "slither . --print human-summary --disable-color 2> reports/slither.txt; slither .",
42+
"semver:diff": "node scripts/sol-semver.mjs diff",
43+
"semver:check": "node scripts/sol-semver.mjs check --lock-file semver-lock.json",
4244
"storage:generate": "./script/storage.sh generate",
4345
"storage:check": "./script/storage.sh check",
4446
"init": "husky && shx chmod +x .husky/*",

0 commit comments

Comments
 (0)