v3 Core Tests #1483
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: v3 Core Tests | |
on: | |
merge_group: | |
workflow_dispatch: | |
inputs: | |
dispatch: | |
type: string | |
description: "'regression' or the JSON of a PR's context" | |
required: true | |
jobs: | |
v3-core-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 }} | |
# 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 | |
env: | |
IS_DISPATCH: ${{ github.event_name == 'workflow_dispatch' }} | |
IS_REGRESSION: ${{ github.event.inputs.dispatch == 'regression' }} | |
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 commit ${{ steps.axon_git_ref.outputs.result}} | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ steps.axon_git_ref.outputs.result}} | |
- name: Git checkout axonweb3/v3-core | |
uses: actions/checkout@v4 | |
with: | |
repository: axonweb3/v3-core | |
ref: 578307adcaf60ddf08ac46ef7fddb012ded20922 | |
path: v3-core | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
- id: yarn-cache | |
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT | |
- 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: | | |
rm -rf ./devtools/chain/data | |
./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 & | |
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: Check Axon web3_clientVersion 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: Install the dependencies of v3-core tests | |
run: | | |
cd /home/runner/work/axon/axon/v3-core | |
yarn install | |
# This is required separately from yarn test because it generates the typechain definitions | |
- name: Compile | |
run: | | |
cd /home/runner/work/axon/axon/v3-core | |
yarn compile | |
- name: Run tests 0 | |
if: success() || failure() | |
id: runtest | |
run: | | |
cd /home/runner/work/axon/axon/v3-core | |
yarn test:prepare | |
yarn test:runAll0 | |
- name: Run test 1 | |
timeout-minutes: 5 | |
if: success() || failure() | |
run: | | |
cd /home/runner/work/axon/axon/v3-core | |
yarn test:runAll1 | |
- name: Run test 2 | |
timeout-minutes: 30 | |
if: success() || failure() | |
run: | | |
cd /home/runner/work/axon/axon/v3-core | |
yarn test:runAll2 | |
- 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: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: jfoa-build-reports-${{ runner.os }} | |
path: v3-core/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 }}' | |
}); | |
} |