Skip to content

Commit e9e5d2b

Browse files
committed
update ci
1 parent 4043eee commit e9e5d2b

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

.github/workflows/pre-genesis-transactions-checks.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ permissions:
2020
contents: write
2121

2222
env:
23-
CAN_ADD_VALIDATORS: ${{ vars.CAN_ADD_VALIDATORS }}
24-
CAN_ADD_BONDS: ${{ vars.CAN_ADD_BONDS }}
25-
CAN_ADD_ACCOUNTS: ${{ vars.CAN_ADD_ACCOUNTS }}
23+
CAN_ADD_VALIDATORS: 'true'
24+
CAN_ADD_BONDS: 'false'
25+
CAN_ADD_ACCOUNTS: 'true'
2626
RUST_BACKTRACE: 1
2727

2828
jobs:

scripts/validate-pr.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010

1111

1212
def read_env():
13-
can_apply_for_validators = os.environ.get('CAN_ADD_VALIDATORS', True).lower() in ('true', '1', 't')
14-
can_apply_for_bonds = os.environ.get('CAN_ADD_BONDS', True).lower() in ('true', '1', 't')
15-
can_apply_for_accounts = os.environ.get('CAN_ADD_ACCOUNTS', True).lower() in ('true', '1', 't')
13+
can_apply_for_validators = os.environ.get('CAN_ADD_VALIDATORS', 'true').lower() in ('true', '1', 't')
14+
can_apply_for_bonds = os.environ.get('CAN_ADD_BONDS', 'true').lower() in ('true', '1', 't')
15+
can_apply_for_accounts = os.environ.get('CAN_ADD_ACCOUNTS', 'true').lower() in ('true', '1', 't')
1616

1717
print("Can add validators: {}".format(can_apply_for_validators))
1818
print("Can add bonds: {}".format(can_apply_for_bonds))
@@ -188,35 +188,41 @@ def check_if_bond_is_valid(bonds_toml: List[Dict], balances: Dict[str, Dict]):
188188
return True
189189

190190

191-
def validate_toml(file, can_apply_for_validators, can_apply_for_bonds, can_apply_for_accounts):
191+
def validate_toml(file, can_apply_for_validators, can_apply_for_bonds, can_apply_for_accounts) -> bool:
192192
balances = toml.load(open("genesis/balances.toml", "r"))
193193
nam_balances = balances['token']['NAM']
194194

195195
if '-account.toml' in file and can_apply_for_accounts:
196196
accounts_toml = read_unsafe_toml(file)
197197
if accounts_toml is None:
198198
print("{} is NOT valid.".format(file))
199+
return False
199200
is_valid = check_if_account_is_valid(accounts_toml)
200201
if not is_valid:
201202
print("{} is NOT valid.".format(file))
203+
return False
202204
elif '-validator.toml' in file and can_apply_for_validators:
203205
validators_toml = read_unsafe_toml(file)
204206
if validators_toml is None:
205207
print("{} is NOT valid.".format(file))
208+
return False
206209
is_valid = check_if_validator_is_valid(validators_toml)
207210
if not is_valid:
208211
print("{} is NOT valid.".format(file))
212+
return False
209213
elif '-bond.toml' in file and can_apply_for_bonds:
210214
bonds_toml = read_unsafe_toml(file)
211215
if not bonds_toml:
212216
print("{} is NOT valid.".format(file))
217+
return False
213218
is_valid = check_if_bond_is_valid(bonds_toml, nam_balances)
214219
if not is_valid:
215220
print("{} is NOT valid.".format(file))
221+
return False
216222
else:
217223
return False
218-
219-
print("{} is valid.".format(file))
224+
225+
return True
220226

221227
def main():
222228
alias = get_alias_from_env()
@@ -236,11 +242,17 @@ def main():
236242

237243
file_alias = get_alias_from_file(file)
238244
if not alias.lower() in file_alias.lower():
245+
print("alias {} doesn't correspond".format(alias.lower()))
239246
exit(1)
240247

241248
print("{} is allowed, checking if its valid...".format(file))
242249

243-
validate_toml(file, can_apply_for_validators, can_apply_for_bonds, can_apply_for_accounts)
250+
res = validate_toml(file, can_apply_for_validators, can_apply_for_bonds, can_apply_for_accounts)
251+
if res:
252+
print("{} is valid.".format(file))
253+
else:
254+
print("{} is NOT valid".format(file))
255+
exit(1)
244256

245257

246258
if __name__ == "__main__":

0 commit comments

Comments
 (0)