Skip to content

Commit

Permalink
Store Benchmark Results in Dedicated CI Branch (#1172)
Browse files Browse the repository at this point in the history
Migrates benchmark result storage from GitHub Actions cache to a dedicated
yorkie-ci-benchmark branch. This approach provides better persistence and
accessibility of performance metrics for long-term analysis and comparison.
  • Loading branch information
chacha912 authored Feb 28, 2025
1 parent d40b3b8 commit c7797cf
Showing 1 changed file with 45 additions and 24 deletions.
69 changes: 45 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,24 +109,17 @@ jobs:
with:
go-version: ${{ env.GO_VERSION }}

- name: Check out code
- name: Checkout current repository
uses: actions/checkout@v4
with:
path: repo

- name: Stack
run: docker compose -f build/docker/docker-compose.yml up --build -d

- name: Bench
id: curr-bench
run: |
make bench
content=$(cat output.txt | jq -R -s .)
echo "BENCH_RESULT=$content" >> $GITHUB_OUTPUT
- name: Set up cache
uses: actions/cache@v3
- name: Checkout benchmark branch
uses: actions/checkout@v4
with:
path: ./cache
key: ${{ runner.os }}-benchmark
ref: yorkie-ci-benchmark
path: benchmark-repo
continue-on-error: true

- name: Read previous benchmark result
if: github.event_name == 'pull_request'
Expand All @@ -135,16 +128,26 @@ jobs:
echo "PREV_BENCH_RESULT=null" >> $GITHUB_OUTPUT
echo "PREV_COMMIT=null" >> $GITHUB_OUTPUT
if [ -f "./cache/bench_result.txt" ]; then
content=$(cat ./cache/bench_result.txt | jq -R -s .)
if [ -d "benchmark-repo" ] && [ -f "benchmark-repo/bench_result.txt" ]; then
content=$(cat benchmark-repo/bench_result.txt | jq -R -s .)
echo "PREV_BENCH_RESULT=$content" >> $GITHUB_OUTPUT
if [ -f "./cache/commit_hash.txt" ]; then
prev_commit=$(cat ./cache/commit_hash.txt)
if [ -f "benchmark-repo/commit_hash.txt" ]; then
prev_commit=$(cat benchmark-repo/commit_hash.txt)
echo "PREV_COMMIT=$prev_commit" >> $GITHUB_OUTPUT
fi
fi
- name: Stack
run: docker compose -f repo/build/docker/docker-compose.yml up --build -d

- name: Bench
id: curr-bench
run: |
cd repo
make bench
content=$(cat output.txt | jq -R -s .)
echo "BENCH_RESULT=$content" >> $GITHUB_OUTPUT
- name: Trigger n8n webhook
if: github.event_name == 'pull_request'
run: |
Expand All @@ -166,12 +169,30 @@ jobs:
exit 1
fi
- name: Store benchmark result to cache
- name: Store benchmark result
if: github.ref == 'refs/heads/main'
run: |
mkdir -p ./cache
cp output.txt ./cache/bench_result.txt
echo "${{ github.sha }}" > ./cache/commit_hash.txt
mkdir -p benchmark-repo
cp repo/output.txt benchmark-repo/bench_result.txt
echo "${{ github.sha }}" > benchmark-repo/commit_hash.txt
cd benchmark-repo
git config user.name "GitHub Actions"
git config user.email "[email protected]"
if [ ! -d ".git" ]; then
git init
git remote add origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
fi
git add bench_result.txt
git add commit_hash.txt
TIMESTAMP=$(date -u +"%Y-%m-%d %H:%M:%S UTC")
git diff --staged --quiet || git commit -m "Update benchmark results at $TIMESTAMP"
git checkout -B yorkie-ci-benchmark
git push -f origin yorkie-ci-benchmark
echo "Benchmark results have been pushed to yorkie-ci-benchmark branch"
complex-test:
name: complex-test
Expand Down

0 comments on commit c7797cf

Please sign in to comment.