forked from Emmyt24/nova-launch
-
Notifications
You must be signed in to change notification settings - Fork 0
185 lines (166 loc) · 8.52 KB
/
error-code-stability.yml
File metadata and controls
185 lines (166 loc) · 8.52 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
name: Error Code Stability
on:
push:
branches: [ main, develop ]
paths:
- 'contracts/token-factory/src/types.rs'
- 'contracts/token-factory/src/error_code_stability_test.rs'
- '.github/workflows/error-code-stability.yml'
pull_request:
branches: [ main, develop ]
paths:
- 'contracts/token-factory/src/types.rs'
- 'contracts/token-factory/src/error_code_stability_test.rs'
env:
RUST_BACKTRACE: 1
jobs:
error-code-stability:
name: Verify Error Code Stability
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: wasm32-unknown-unknown
override: true
- name: Cache cargo registry
uses: actions/cache@v3
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v3
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo build
uses: actions/cache@v3
with:
path: contracts/token-factory/target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
- name: Run error code stability tests
working-directory: contracts/token-factory
run: |
echo "🔒 Running error code stability tests..."
echo ""
echo "These tests protect API consumers by ensuring error codes remain stable."
echo "Any failure indicates a breaking change that requires a major version bump."
echo ""
cargo test --lib error_code_stability_test -- --nocapture --test-threads=1
- name: Verify no error code collisions
working-directory: contracts/token-factory
run: |
echo "🔍 Checking for error code collisions..."
cargo test --lib test_no_error_code_collisions -- --nocapture
- name: Verify error code ranges
working-directory: contracts/token-factory
run: |
echo "📊 Verifying error codes are in expected ranges..."
cargo test --lib test_error_code_ranges -- --nocapture
- name: Test common failure scenarios
working-directory: contracts/token-factory
run: |
echo "🧪 Testing common failure scenario error codes..."
cargo test --lib test_auth_failure_error_codes -- --nocapture
cargo test --lib test_validation_failure_error_codes -- --nocapture
cargo test --lib test_not_found_error_codes -- --nocapture
cargo test --lib test_paused_error_codes -- --nocapture
cargo test --lib test_replay_protection_error_codes -- --nocapture
- name: Test milestone verification errors
working-directory: contracts/token-factory
run: |
echo "🔐 Testing milestone verification error codes..."
cargo test --lib test_milestone_verification_error_codes -- --nocapture
- name: Test vault lifecycle errors
working-directory: contracts/token-factory
run: |
echo "🏦 Testing vault lifecycle error codes..."
cargo test --lib test_vault_lifecycle_error_codes -- --nocapture
- name: Generate error code report
if: always()
working-directory: contracts/token-factory
run: |
echo "## Error Code Stability Report" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### ✅ Error Code Stability Verified" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "All error codes are stable and protected by automated tests." >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Error Code Categories:" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Category | Range | Count | Description |" >> $GITHUB_STEP_SUMMARY
echo "|----------|-------|-------|-------------|" >> $GITHUB_STEP_SUMMARY
echo "| Core Errors | 1-10 | 10 | Validation, initialization, auth |" >> $GITHUB_STEP_SUMMARY
echo "| Token Errors | 11-18 | 8 | Token-specific operations |" >> $GITHUB_STEP_SUMMARY
echo "| Treasury Errors | 19-20 | 2 | Treasury withdrawals |" >> $GITHUB_STEP_SUMMARY
echo "| Validation Errors | 21-26 | 6 | Parameter validation |" >> $GITHUB_STEP_SUMMARY
echo "| Stream Errors | 27-31 | 5 | Vesting streams |" >> $GITHUB_STEP_SUMMARY
echo "| Governance Errors | 32-41 | 10 | Governance operations |" >> $GITHUB_STEP_SUMMARY
echo "| Milestone Errors | 42-43 | 2 | Milestone verification |" >> $GITHUB_STEP_SUMMARY
echo "| Misc Errors | 44-51 | 8 | Various operations |" >> $GITHUB_STEP_SUMMARY
echo "| Vault Errors | 60-65 | 6 | Vault lifecycle |" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Protected Scenarios:" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- ✅ Authentication failures (Unauthorized = 2)" >> $GITHUB_STEP_SUMMARY
echo "- ✅ Invalid parameters (InvalidParameters = 3)" >> $GITHUB_STEP_SUMMARY
echo "- ✅ Not found errors (TokenNotFound = 4, VaultNotFound = 60)" >> $GITHUB_STEP_SUMMARY
echo "- ✅ Contract paused (ContractPaused = 14)" >> $GITHUB_STEP_SUMMARY
echo "- ✅ Replay protection (AlreadyInitialized = 6, AlreadyVoted = 46)" >> $GITHUB_STEP_SUMMARY
echo "- ✅ Milestone verification (InvalidProof = 42, ProofRequired = 43)" >> $GITHUB_STEP_SUMMARY
echo "- ✅ Vault lifecycle (VaultLocked = 61, VaultAlreadyClaimed = 62)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Breaking Change Protection:" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- ✅ No error code collisions detected" >> $GITHUB_STEP_SUMMARY
echo "- ✅ All error codes in expected ranges" >> $GITHUB_STEP_SUMMARY
echo "- ✅ Common failure paths have stable codes" >> $GITHUB_STEP_SUMMARY
echo "- ✅ CI will fail if error codes change" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### API Consumer Protection:" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "These tests ensure that:" >> $GITHUB_STEP_SUMMARY
echo "1. Error codes never change accidentally" >> $GITHUB_STEP_SUMMARY
echo "2. No enum reordering breaks client code" >> $GITHUB_STEP_SUMMARY
echo "3. New errors are added with explicit codes" >> $GITHUB_STEP_SUMMARY
echo "4. Client error handling remains correct" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "⚠️ **Any change to error codes requires a major version bump!**" >> $GITHUB_STEP_SUMMARY
- name: Check for breaking changes
if: github.event_name == 'pull_request'
working-directory: contracts/token-factory
run: |
echo "🔍 Checking for breaking changes in error codes..."
echo ""
echo "If this step fails, you have made a breaking change to error codes."
echo "This requires:"
echo " 1. Major version bump (e.g., 1.0.0 -> 2.0.0)"
echo " 2. Migration guide for API consumers"
echo " 3. Update to client libraries"
echo " 4. Communication to all integrators"
echo ""
# Run all stability tests - any failure is a breaking change
cargo test --lib error_code_stability_test -- --nocapture --test-threads=1
if [ $? -eq 0 ]; then
echo "✅ No breaking changes detected in error codes"
else
echo "❌ BREAKING CHANGE DETECTED!"
echo ""
echo "Error codes have changed. This is a breaking change that will affect:"
echo " - Client applications"
echo " - Indexers and monitoring systems"
echo " - Error handling logic"
echo " - User-facing error messages"
echo ""
echo "Please review the changes and ensure proper versioning."
exit 1
fi
- name: Fail on breaking changes
if: failure() && github.event_name == 'pull_request'
run: |
echo "::error::Breaking change detected in error codes. See job summary for details."
exit 1