forked from demergent-labs/azle
-
Notifications
You must be signed in to change notification settings - Fork 0
176 lines (148 loc) · 7.13 KB
/
run_test.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
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
name: Run Test
on:
workflow_call:
inputs:
directories:
required: true
type: string
exclude-dirs:
required: false
type: string
default: ''
link-azle:
required: true
type: boolean
run-experimental:
required: false
type: boolean
default: false
fuzz:
required: false
type: boolean
default: false
call-delay:
required: false
type: string
default: '.1'
timeout:
required: false
type: string
default: '300'
jobs:
get-test-infos:
name: Get test infos
runs-on: ubuntu-latest
outputs:
test-infos: ${{ steps.get-test-infos.outputs.test-infos }}
steps:
- uses: actions/checkout@v4
- id: get-test-infos
uses: ./.github/actions/get_test_infos
with:
directories: ${{ inputs.directories }}
exclude-dirs: ${{ inputs.exclude-dirs }}
run-test:
name: '${{matrix.test.name}} | ${{matrix.test.displayPath}} | ${{matrix.azle_source}}'
needs: get-test-infos
runs-on: ${{ matrix.os }}
env:
ETHEREUM_URL: ${{ secrets.ETHEREUM_URL }}
AZLE_IDENTITY_STORAGE_MODE: 'plaintext'
AZLE_END_TO_END_TEST_LINK_AZLE: ${{ matrix.azle_source == 'repo' }}
AZLE_IS_MAIN_BRANCH_PUSH: ''
AZLE_IS_MAIN_BRANCH_PUSH_FROM_RELEASE_MERGE: ''
AZLE_IS_RELEASE_BRANCH_PR: ''
AZLE_IS_FEATURE_BRANCH_PR: ''
AZLE_IS_FEATURE_BRANCH_DRAFT_PR: ''
strategy:
fail-fast: false # We want to see which example tests succeed and which ones fail, we don't want one example test to cancel the rest
matrix: # spins up one job per combination of test and code source (repo or npm).
# os: [macos-latest, ubuntu-latest]
os: [ubuntu-latest]
azle_source:
- ${{ inputs.link-azle == true && 'repo' || 'npm' }}
test: ${{ fromJSON(needs.get-test-infos.outputs.test-infos) }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/determine_workflow_context
id: set-conditions
- name: Set condition environment variables
run: |
echo "AZLE_IS_MAIN_BRANCH_PUSH=${{ steps.set-conditions.outputs.is_main_branch_push }}" >> $GITHUB_ENV
echo "AZLE_IS_MAIN_BRANCH_PUSH_FROM_RELEASE_MERGE=${{ steps.set-conditions.outputs.is_main_branch_push_from_release_merge }}" >> $GITHUB_ENV
echo "AZLE_IS_RELEASE_BRANCH_PR=${{ steps.set-conditions.outputs.is_release_branch_pr }}" >> $GITHUB_ENV
echo "AZLE_IS_FEATURE_BRANCH_PR=${{ steps.set-conditions.outputs.is_feature_branch_pr }}" >> $GITHUB_ENV
echo "AZLE_IS_FEATURE_BRANCH_DRAFT_PR=${{ steps.set-conditions.outputs.is_feature_branch_draft_pr }}" >> $GITHUB_ENV
- name: Print environment variables
run: |
echo "AZLE_IS_MAIN_BRANCH_PUSH: $AZLE_IS_MAIN_BRANCH_PUSH"
echo "AZLE_IS_MAIN_BRANCH_PUSH_FROM_RELEASE_MERGE: $AZLE_IS_MAIN_BRANCH_PUSH_FROM_RELEASE_MERGE"
echo "AZLE_IS_RELEASE_BRANCH_PR: $AZLE_IS_RELEASE_BRANCH_PR"
echo "AZLE_IS_FEATURE_BRANCH_PR: $AZLE_IS_FEATURE_BRANCH_PR"
echo "AZLE_IS_FEATURE_BRANCH_DRAFT_PR: $AZLE_IS_FEATURE_BRANCH_DRAFT_PR"
- name: Report full path of test
# Just in case the path isn't obvious from the name, this will remove ambiguity
run: echo ${{matrix.test.path}}
- uses: ./.github/actions/setup_node
- uses: ./.github/actions/setup_dfx
- name: Configure MacOS DNS (if needed)
if: matrix.os == 'macos-latest'
run: sudo networksetup -setdnsservers Ethernet 9.9.9.9
- run: npm install
- run: npm link
if: matrix.azle_source == 'repo'
- run: npm run lint
- run: npm install
working-directory: ${{ matrix.test.path }}
- run: npm link azle
if: matrix.azle_source == 'repo'
working-directory: ${{ matrix.test.path }}
- run: npx azle install-dfx-extension
working-directory: ${{ matrix.test.path }}
- name: Start dfx with artificial delay 0
if: ${{ steps.set-conditions.outputs.is_feature_branch_pr == 'true' || steps.set-conditions.outputs.is_feature_branch_draft_pr == 'true' }}
working-directory: ${{ matrix.test.path }}
run: dfx start --clean --background --host 127.0.0.1:8000 --artificial-delay 0
- name: Start dfx
if: ${{ steps.set-conditions.outputs.is_release_branch_pr == 'true' || steps.set-conditions.outputs.is_main_branch_push == 'true' || steps.set-conditions.outputs.is_main_branch_push_from_release_merge == 'true' }}
working-directory: ${{ matrix.test.path }}
run: dfx start --clean --background --host 127.0.0.1:8000
- name: Calculate number of test runs
id: calc-runs
run: |
RUNS=1
if [[ "${{ steps.set-conditions.outputs.is_main_branch_push }}" == "true" ]]; then
RUNS=100
fi
if [[ "${{ steps.set-conditions.outputs.is_main_branch_push_from_release_merge }}" == "true" ]]; then
RUNS=100
fi
if [[ "${{ steps.set-conditions.outputs.is_release_branch_pr }}" == "true" ]]; then
RUNS=10
fi
if [[ "${{ steps.set-conditions.outputs.is_feature_branch_pr }}" == "true" ]]; then
RUNS=5
fi
if [[ "${{ steps.set-conditions.outputs.is_feature_branch_draft_pr }}" == "true" ]]; then
RUNS=1
fi
echo "Running tests $RUNS times"
echo "runs=$RUNS" >> $GITHUB_OUTPUT
- name: Run tests
run: |
timeout ${{ inputs.timeout }}m npm test
exit_code=$?
if [ $exit_code -eq 124 ] || [ $exit_code -eq 142 ]; then
# Exit code 124 is for timeout, 142 is for SIGALRM
exit 0
else
exit $exit_code
fi
working-directory: ${{ matrix.test.path }}
shell: bash -l {0}
env:
AZLE_PROPTEST_NUM_RUNS: ${{ steps.calc-runs.outputs.runs }}
AZLE_PROPTEST_VERBOSE: true
AZLE_EXPERIMENTAL: ${{ inputs.run-experimental }}
AZLE_FUZZ: ${{ inputs.fuzz }}
AZLE_FUZZ_CALL_DELAY: ${{ inputs.call-delay }}