EthStats Demo #6
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: EthStats Demo | |
on: | |
workflow_dispatch: | |
inputs: | |
jarArg: | |
description: 'The argument to pass to the Java jar command' | |
required: false | |
tpsDuration: | |
description: 'Duration of TPS function execution in minutes' | |
required: false | |
default: '2' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up JDK | |
uses: actions/setup-java@v2 | |
with: | |
java-version: '8' | |
distribution: 'adopt' | |
- name: Download jar file | |
run: | | |
wget https://github.com/sunchengzhu/eth-performance/releases/download/v1.0.0/ethStats.jar | |
- name: Run ethStats | |
env: | |
GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
GIST_ID: 5ad4ca3b06f39c2d56cd2b1aa8f25204 | |
run: | | |
(java -jar ethStats.jar ${{ github.event.inputs.jarArg }} | tee ethStats.log) & | |
curl -X POST \ | |
-H "Authorization: token $GH_TOKEN" \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
https://api.github.com/repos/${{ github.repository }}/actions/workflows/write_gist.yml/dispatches \ | |
-d '{"ref":"main", "inputs": {"tpsDuration": "'${{ github.event.inputs.tpsDuration }}'"}' | |
PREV_GIST_CONTENT="" | |
while true; do | |
sleep 2 | |
GIST_CONTENT=$(curl -s -H "Authorization: token $GH_TOKEN" https://api.github.com/gists/$GIST_ID | jq -r '.files["commands.txt"].content') | |
if [ "$GIST_CONTENT" != "$PREV_GIST_CONTENT" ]; then | |
echo $GIST_CONTENT >> commands.txt | |
PREV_GIST_CONTENT=$GIST_CONTENT | |
fi | |
if [ "$GIST_CONTENT" == "successRate" ]; then | |
break | |
fi | |
done | |
tail -f ethStats.log | while read LOGLINE | |
do | |
[[ "${LOGLINE}" == *"JVM正在退出"* ]] && pkill -P $$ tail | |
done | |
- name: Archive production artifacts | |
if: always() | |
uses: actions/upload-artifact@v2 | |
with: | |
name: files | |
path: | | |
commands.txt | |
tps.csv | |
performance.csv |