-
Notifications
You must be signed in to change notification settings - Fork 39
185 lines (171 loc) · 7.12 KB
/
web3_compatible.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
177
178
179
180
181
182
183
184
185
name: Web3 Compatible Tests
on:
merge_group:
workflow_dispatch:
inputs:
# used by regression_testing.yml and entry_workflow.yml
dispatch:
type: string
description: "'regression' or the JSON of a PR's context"
required: false
jobs:
web3-compatible-test:
strategy:
matrix:
# Supported GitHub-hosted runners and hardware resources
# see https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
os: [ubuntu-22.04]
fail-fast: false
runs-on: ${{ matrix.os }}
env:
IS_DISPATCH: ${{ github.event_name == 'workflow_dispatch' }}
IS_REGRESSION: ${{ github.event.inputs.dispatch == 'regression' }}
# When the permissions key is used, all unspecified permissions are set to no access, with the exception of the metadata scope, which always gets read access.
# See https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token
permissions:
statuses: write
steps:
- name: Get the git ref of Axon
uses: actions/github-script@v7
id: axon_git_ref
with:
script: |
if (`${{ env.IS_DISPATCH }}` == 'true' && `${{ env.IS_REGRESSION }}` == 'false' && `${{ github.event.inputs.dispatch }}`) {
const dispatch = JSON.parse(`${{ github.event.inputs.dispatch }}`);
const prNum = dispatch.issue.number;
const { data: pullRequest } = await github.rest.pulls.get({
owner: dispatch.repo.owner,
repo: dispatch.repo.repo,
pull_number: dispatch.issue.number,
});
return pullRequest.head.sha;
}
return `${{ github.sha }}`;
result-encoding: string
# The `statuses: write` permission is required in this step.
- name: Update the commit Status
if: always()
uses: actions/github-script@v7
with:
script: |
if (`${{ env.IS_DISPATCH }}` == 'true' && `${{ env.IS_REGRESSION }}` == 'false') {
github.rest.repos.createCommitStatus({
state: 'pending',
owner: context.repo.owner,
repo: context.repo.repo,
context: '${{ github.workflow }}',
sha: '${{ steps.axon_git_ref.outputs.result}}',
target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
});
}
- name: Checkout Axon ${{ steps.axon_git_ref.outputs.result}}
uses: actions/checkout@v4
with:
ref: ${{ steps.axon_git_ref.outputs.result}}
- name: Cache of Cargo
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-cargo-build
- name: Build Axon in the development profile
run: |
# check for AVX2 support by inspecting `/proc/cpuinfo` or running `lscpu`
# related issue: https://github.com/axonweb3/axon/issues/1387
lscpu
# PORTABLE=1 USE_SSE=1 tell rocksdb to target AVX2
PORTABLE=1 USE_SSE=1 cargo build
- name: Deploy Local Network of Axon
run: |
./target/debug/axon init \
--config devtools/chain/config.toml \
--chain-spec devtools/chain/specs/single_node/chain-spec.toml \
> /tmp/log 2>&1
./target/debug/axon run \
--config devtools/chain/config.toml \
>> /tmp/log 2>&1 &
- name: Check Axon Status Before Test
run: |
MAX_RETRIES=10
for i in $(seq 1 $MAX_RETRIES); do
sleep 10
response=$(curl -s -w "\n%{http_code}" http://localhost:8000 -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"web3_clientVersion","params": [],"id":1}')
http_code=$(echo "$response" | tail -n1)
response_body=$(echo "$response" | sed '$d')
if [[ "$http_code" -eq 200 ]]; then
echo "$response_body"
exit 0
else
echo "Axon status check failed with HTTP status code: $http_code, retrying ($i/$MAX_RETRIES)"
if [[ "$i" -eq $MAX_RETRIES ]]; then
echo "Axon status check failed after $MAX_RETRIES attempts."
exit 1
fi
fi
done
- name: Checkout axonweb3/axon-test
uses: actions/checkout@v4
with:
repository: axonweb3/axon-test
ref: 5b50a5382604812e5aba1d27e1eef2e941ef55ad
path: axon-test
- uses: actions/setup-node@v4
with:
node-version: "18"
- name: Get yarn cache directory
id: yarn-cache-dir
run: echo "dir=$(yarn cache dir)" >> ${GITHUB_OUTPUT}
- name: Get npm cache directory
id: npm-cache-dir
shell: bash
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
- name: Node Cache
uses: actions/cache@v3
id: npm-and-yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: |
${{ steps.yarn-cache-dir.outputs.dir }}
${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node_modules-
- name: Run axon-test
working-directory: axon-test
run: |
npm install
npm run test:test --network=axon_test --grep=""
- name: Check Axon Status
if: success() || failure()
run: |
npx zx <<'EOF'
import { waitXBlocksPassed } from './devtools/ci/scripts/helper.js'
await retry(3, '6s', () => waitXBlocksPassed('http://127.0.0.1:8000', 2))
EOF
- name: Publish reports
if: success() || failure()
uses: actions/upload-artifact@v4
with:
name: jfoa-build-reports-${{ runner.os }}
path: axon-test/mochawesome-report/
# The `statuses: write` permission is required in this step.
- name: Update the commit Status
if: always()
uses: actions/github-script@v7
with:
script: |
if (`${{ env.IS_DISPATCH }}` == 'true' && `${{ env.IS_REGRESSION }}` == 'false') {
github.rest.repos.createCommitStatus({
state: '${{ job.status }}',
owner: context.repo.owner,
repo: context.repo.repo,
context: '${{ github.workflow }}',
sha: '${{ steps.axon_git_ref.outputs.result}}',
target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
});
}