ci: emulated perf workflow (#7949)

This commit is contained in:
André Costa
2025-06-26 08:09:23 +02:00
committed by GitHub
parent a96c2044d8
commit 47977f33d1
33 changed files with 1720 additions and 36 deletions
+103
View File
@@ -0,0 +1,103 @@
name: Emulated Performance Test
on:
push:
branches: 'master'
pull_request:
branches: 'master'
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true
jobs:
check_scripts:
runs-on: ubuntu-24.04
name: ARM Emulated Benchmark - Script Check
strategy:
fail-fast: false
matrix:
test_script:
- scripts/perf/tests/filter_docker_logs/test.sh
# These scripts aren't executed in this workflow directly. Instead, they're run
# by the `Emulated Performance Test Results Handler` workflow.
# That workflow runs in the context of the `master` branch, so this workflow ensures
# the scripts are tested in the PR context before merging. Helping to prevent CI failures in `master`
- scripts/perf/tests/benchmark_results_comment/test.sh
- scripts/perf/tests/serialize_results/test.sh
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check Script
run: |
pip3 install msgpack==1.1.0
./${{ matrix.test_script }}
run_benchmark:
runs-on: ubuntu-24.04
name: ARM Emulated Benchmark ${{ matrix.image_type }} - ${{matrix.config }}
needs: check_scripts
strategy:
fail-fast: false
matrix:
include:
- image_type: 32b
image_version : |
main@sha256:9c4587f5852be856aed4548fcb8b505290410de837bb87fb2ba8e1b778f10bec
config : lv_conf_perf32b
- image_type: 64b
image_version: |
main@sha256:7e4c0a883dec21e2e9c027fe21188b2b009e46a1b3eb9f02499ca02ed7914e4a
config : lv_conf_perf64b
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate lv_conf.h
run: |
cp lv_conf_template.h configs/ci/perf/lv_conf_perf.h
python scripts/generate_lv_conf.py \
--template lv_conf_template.h \
--config configs/ci/perf/lv_conf_perf.h \
--defaults configs/ci/perf/${{matrix.config}}.defaults
- name: Run Benchmark Demo
run: |
# Mounts the current lvgl source code into the container and runs the demo benchmark
# To add additional build dependencies, modify the `lvperf_dependencies.sh` script
docker run -t --privileged \
--name so3-lvperf \
-v /dev:/dev \
-v $(pwd)/configs/ci/perf/lv_conf_perf.h:/so3/usr/lib/lv_conf.h \
-v $(pwd):/so3/usr/lib/lvgl \
-v $(pwd)/scripts/perf/lvperf_dependencies.sh:/so3/install_dependencies.sh \
ghcr.io/smartobjectoriented/so3-lvperf${{matrix.image_type}}:${{matrix.image_version}}
- name: Collect Logs
run: |
sudo cat $(docker inspect --format='{{.LogPath}}' so3-lvperf) | python scripts/perf/filter_docker_benchmark_logs.py results-${{matrix.image_type}}-${{matrix.config}}.json
- name: Upload Results
uses: actions/upload-artifact@v4
with:
name: results-${{matrix.image_type}}-${{matrix.config}}
path: results-${{matrix.image_type}}-${{matrix.config}}.json
if-no-files-found: error
save_pr_number:
runs-on: ubuntu-24.04
if: ${{ github.event_name == 'pull_request' }}
name: ARM Emulated Benchmark - Save PR Number
needs: run_benchmark
steps:
- name: Save PR number
run: |
echo ${{ github.event.number }} > pr_number
- name: Upload PR number as artifact
uses: actions/upload-artifact@v4
with:
name: pr_number
path: pr_number
@@ -0,0 +1,133 @@
name: Emulated Performance Test Results Handler
on:
workflow_run:
workflows: [Emulated Performance Test]
types:
- completed
concurrency:
group: ${{ github.event.workflow_run.event }}-${{ github.event.workflow_run.head_branch }}-${{ github.workflow }}
cancel-in-progress: true
permissions:
contents: write
pull-requests: write
jobs:
check_scripts:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-24.04
name: ARM Emulated Benchmark - Script Check
strategy:
fail-fast: false
matrix:
test_script:
- scripts/perf/tests/benchmark_results_comment/test.sh
- scripts/perf/tests/serialize_results/test.sh
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check Script
run: |
pip3 install msgpack==1.1.0
./${{ matrix.test_script }}
handle_results:
needs: check_scripts
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-24.04
name: ARM Emulated Benchmark - Handle Results
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download Results
uses: dawidd6/action-download-artifact@v9
with:
workflow: perf_emulation.yml
path: artifacts
- name: Move JSON files to a single folder
run: |
mkdir input
find artifacts -name "*.json" -exec mv {} input/ \;
- name: Collect 'master' Results
uses: robinraju/release-downloader@v1
continue-on-error: true # The release may not exist yet
with:
preRelease: true
tag: emulated-benchmark-latest
fileName: results*.mpk
- name: Move PR data files to current folder
if: ${{ github.event.workflow_run.event == 'pull_request' }}
run: |
mv artifacts/pr_number/pr_number .
- name: Prepare Comment
if: ${{ github.event.workflow_run.event == 'pull_request' }}
run: |
pip3 install msgpack==1.1.0
if ls results*.mpk 1> /dev/null 2>&1; then
python3 scripts/perf/benchmark_results_comment.py \
--previous results*.mpk \
--new input/results*.json \
--output comment.md
else
echo "No previous results found, generating comment without comparison."
python3 scripts/perf/benchmark_results_comment.py \
--new input/results*.json \
--output comment.md
fi
- name: Comment PR
if: ${{ github.event.workflow_run.event == 'pull_request' }}
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const commentPath = 'comment.md';
const prPath = 'pr_number';
if (!fs.existsSync(commentPath)) {
throw new Error('Error: comment.md not found! Exiting.');
}
if (!fs.existsSync(prPath)) {
throw new Error('Error: pr_number not found! Exiting.');
}
const commentBody = fs.readFileSync(commentPath, 'utf8').trim();
const prNumber = Number(fs.readFileSync(prPath, 'utf8').trim());
github.rest.issues.createComment({
issue_number: prNumber,
owner: context.repo.owner,
repo: context.repo.repo,
body: commentBody
});
- name: Serialize Results
if: ${{ github.event.workflow_run.event == 'push' && github.event.workflow_run.head_branch == 'master' }}
run: |
# Here the input folder already exists from a previous step
pip3 install msgpack==1.1.0
mkdir output
find . -maxdepth 1 \( -name "results*.mpk" \) -exec mv -t input {} +
python scripts/perf/serialize_results.py --input input --output output --commit-hash ${{ github.sha }}
- name: Store Results in Benchmark Release
if: ${{ github.event.workflow_run.event == 'push' && github.event.workflow_run.head_branch == 'master' }}
uses: softprops/action-gh-release@v2
with:
name: Emulated Benchmark Latest
files: output/results*.mpk
tag_name: emulated-benchmark-latest
prerelease: true