diff --git a/.github/workflows/qemu-perf.yml b/.github/workflows/qemu-perf.yml index 134c50b..e0dfb78 100644 --- a/.github/workflows/qemu-perf.yml +++ b/.github/workflows/qemu-perf.yml @@ -4,6 +4,10 @@ on: schedule: - cron: '2 1 * * *' + push: + branches: + - 'perf' + jobs: build: name: Build @@ -31,6 +35,9 @@ jobs: steps: - uses: actions/checkout@v1.0.0 + - name: Log start time + run: touch /tmp/start + - name: Register self-compiled qemu run: docker run --rm --privileged meedamian/simple-qemu:${{matrix.qemu}}-${{matrix.arch}} -p yes @@ -59,3 +66,78 @@ jobs: docker run --rm --entrypoint=uname bitcoind -a docker run --rm bitcoind --version + - name: Calculate execution time + run: | + START=$(date -r /tmp/start +%s) + NOW=$(date +%s) + + DIFF=$(( NOW - START )) + + SEC=1 + MIN=$(( 60 * SEC )) + HOUR=$(( 60 * MIN )) + DAY=$(( 24 * HOUR )) + + secs=$(( DIFF % 60 )) + mins=$(( $(( DIFF / MIN )) % 60 )) + hours=$(( $(( DIFF / HOUR )) % 24 )) + days=$(( DIFF / DAY )) + + OUT="" + if [[ "${days}" -ne "0" ]]; then + # Days-long jobs shouldn't happen, but 🤷🏻‍♂️ + OUT="${days}d " + fi + + OUT="${OUT}${hours}h:${mins}m:${secs}s" + + mkdir -p stat + + echo "${OUT}" > stat/${{matrix.qemu}}-${{matrix.arch}} + + - name: Save execution time as an artifact + uses: actions/upload-artifact@v1.0.0 + with: + name: stats + path: stat/ + + comment: + name: Report result + needs: build + runs-on: ubuntu-18.04 + steps: + - name: Download perf stats + uses: actions/download-artifact@v1.0.0 + with: + name: stats + + - name: Aggregate results + run: | + touch ./all-stats + + echo "| version | arm32v7 | arm64" >> ./all-stats + echo "|:-------:|--------:|-----:" >> ./all-stats + + for ver in $(ls ./stats/* | awk -F/ '{print $NF}' | cut -d- -f1 | uniq); do + line="| **${ver}**" + + line="${line} | $(cat ./stats/${ver}-arm32v7 | tr -d '\n')" + line="${line} | $(cat ./stats/${ver}-arm64 | tr -d '\n')" + + echo "${line}" >> ./all-stats + done + + cat ./all-stats + + echo ::set-env name=RESULTS::"$(cat ./all-stats | sed -z 's/\n/\\n/g')" + + - uses: actions/github-script@0.4.0 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + github.issues.createComment({ + owner: 'lncm', + repo: 'docker-bitcoind', + issue_number: 9, + body: `Today's results:\n\n${process.env.RESULTS.replace(/\\n/g, '\n')}` + })