-
Notifications
You must be signed in to change notification settings - Fork 2
122 lines (107 loc) · 4.16 KB
/
test-generate-contract-spec.yml
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
---
name: Test generate contract spec
on:
pull_request:
branches:
- main
push:
branches:
- main
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true
jobs:
main:
name: Test generate-contract-spec action
runs-on: ubuntu-20.04
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Create input dummy files
shell: bash
run: |
echo '{"contract1": "5A","contract2": "5B"}' > azero_addresses.json
echo '{"cont3": "5C","cont4": "5D"}' > eth_addresses.json
- name: Generate contract spec JSON file from files
uses: ./generate-contract-spec
with:
src-files: |-
azero_addresses.json|azero_
eth_addresses.json|eth_
dst-file: generated-from-files.json
exclude: |-
eth_cont3
spec-version: '0.1'
contract-version: 'v'
- name: Generate contract spec JSON file from string
uses: ./generate-contract-spec
with:
src-string: |-
azero_con1|5E
azero_con2|5F
azero_con3|5G
dst-file: generated-from-string.json
exclude: |-
azero_con2
spec-version: '0.1'
contract-version: 'v'
- name: Generate contract spec JSON file from files and string
uses: ./generate-contract-spec
with:
src-files: |-
azero_addresses.json|azero_
eth_addresses.json|eth_
src-string: |-
azero_con1|5E
azero_con2|5F
azero_con3|5G
dst-file: generated-from-files-and-string.json
exclude: |-
azero_con1
eth_cont4
spec-version: '0.1'
contract-version: 'v'
- name: Check created files
shell: bash
# yamllint disable rule:line-length
run: |
if [[ $(cat generated-from-files.json | jq -r '.version') != '0.1' ]]; then
echo "Invalid spec version";
exit 1;
fi
if [[ $(cat generated-from-files.json | jq -r '.contract_version') != 'v' ]]; then
echo "Invalid contract version";
exit 1;
fi
cat generated-from-files.json
if [[ \
$(cat generated-from-files.json | jq -r '.addresses.azero_contract1.address') != '5A' \
|| $(cat generated-from-files.json | jq -r '.addresses.azero_contract2.address') != '5B' \
|| $(cat generated-from-files.json | jq -rR 'fromjson? | .addresses.eth_cont3.address') != '' \
|| $(cat generated-from-files.json | jq -r '.addresses.eth_cont4.address') != '5D'
]]; then
echo "Invalid file generated";
exit 1;
fi
cat generated-from-string.json
if [[ \
$(cat generated-from-string.json | jq -r '.addresses.azero_con1.address') != '5E' \
|| $(cat generated-from-string.json | jq -r '.addresses.azero_con3.address') != '5G' \
|| $(cat generated-from-string.json | jq -rR 'fromjson? | .addresses.azero_con2.address') != ''
]]; then
echo "Invalid file generated";
exit 1;
fi
cat generated-from-files-and-string.json
if [[ \
$(cat generated-from-files-and-string.json | jq -rR 'fromjson? | .addresses.azero_con1.address') != '' \
|| $(cat generated-from-files-and-string.json | jq -r '.addresses.azero_con2.address') != '5F' \
|| $(cat generated-from-files-and-string.json | jq -r '.addresses.azero_con3.address') != '5G' \
|| $(cat generated-from-files-and-string.json | jq -r '.addresses.azero_contract1.address') != '5A' \
|| $(cat generated-from-files-and-string.json | jq -r '.addresses.azero_contract2.address') != '5B' \
|| $(cat generated-from-files-and-string.json | jq -r '.addresses.eth_cont3.address') != '5C' \
|| $(cat generated-from-files-and-string.json | jq -rR 'fromjson? | .addresses.eth_cont4.address') != ''
]]; then
echo "Invalid file generated";
exit 1;
fi