forked from hyperlane-xyz/hyperlane-monorepo
-
Notifications
You must be signed in to change notification settings - Fork 0
104 lines (94 loc) · 3.44 KB
/
Copy pathinterface-analysis.yml
File metadata and controls
104 lines (94 loc) · 3.44 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
name: Check Interface Changes
on:
pull_request:
paths:
- 'solidity/**'
- '.github/workflows/interface-analysis.yml'
workflow_dispatch:
inputs:
base:
description: 'Branch to compare against'
required: true
default: 'main'
jobs:
diff-check:
runs-on: ubuntu-latest
steps:
# Checkout the PR branch
- name: Checkout PR branch
uses: actions/checkout@v7
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
submodules: recursive
persist-credentials: false
- uses: actions/setup-node@v7
with:
node-version-file: .nvmrc
- name: pnpm-cache
uses: ./.github/actions/pnpm-cache
- name: pnpm-install
run: pnpm install --frozen-lockfile
- name: Setup Foundry
uses: ./.github/actions/setup-foundry
# Run the command on PR branch
- name: Run command on PR branch
run: pnpm -C solidity interface HEAD-interface
# Checkout the target branch (base)
- name: Checkout target branch (base) contracts
env:
BASE_REF: ${{ github.event.inputs.base || github.event.pull_request.base.sha }}
run: |
git fetch origin $BASE_REF
# Remove then checkout to ensure clean state
# (git checkout alone doesn't delete files that only exist in HEAD)
rm -rf solidity/contracts
if [[ "$BASE_REF" =~ ^[0-9a-f]{40}$ ]]; then
git checkout $BASE_REF -- solidity/contracts
else
git checkout origin/$BASE_REF -- solidity/contracts
fi
# Run the command on the target branch
- name: Run command on target branch
run: pnpm -C solidity interface base-interface
# Compare outputs and check for appropriate changeset
- name: Compare outputs
env:
BASE_REF: ${{ github.event.inputs.base || github.event.pull_request.base.sha }}
run: |
set +e
pnpm -C solidity interface test-interface base-interface HEAD-interface
EXIT_CODE=$?
set -e
if [ "$EXIT_CODE" -eq 0 ]; then
echo "No interface changes detected."
exit 0
elif [ "$EXIT_CODE" -eq 1 ]; then
# Removals detected - require major changeset
echo ""
if .github/scripts/check-solidity-changeset.sh major "$BASE_REF"; then
echo ""
echo "Interface removals are permitted with the existing changeset."
exit 0
else
echo ""
echo "ERROR: Interface removals (breaking changes) require a changeset for @hyperlane-xyz/core with a 'major' bump."
exit 1
fi
elif [ "$EXIT_CODE" -eq 2 ]; then
# Additions only - require minor changeset
echo ""
if .github/scripts/check-solidity-changeset.sh minor "$BASE_REF"; then
echo ""
echo "Interface additions are permitted with the existing changeset."
exit 0
else
echo ""
echo "ERROR: Interface additions require a changeset for @hyperlane-xyz/core with at least a 'minor' bump."
exit 1
fi
else
# Unexpected exit code - treat as error
echo ""
echo "ERROR: Interface check script failed with unexpected exit code: $EXIT_CODE"
exit 1
fi