Skip to content

Commit

Permalink
Automatically add new flame graphs to gh_pages, prune old (#1105)
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvanoosten authored Nov 23, 2023
1 parent 6ee5d0b commit a8a5fdd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
31 changes: 23 additions & 8 deletions .github/workflows/profile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-latest
if: ${{ !github.event.pull_request.head.repo.fork }} # comes from https://github.com/orgs/community/discussions/25217#discussioncomment-3246904
steps:
- uses: actions/checkout@v3.0.2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Java
Expand All @@ -26,6 +26,8 @@ jobs:
distribution: temurin
java-version: 17
check-latest: true
- uses: coursier/cache-action@v6
- uses: VirtusLab/scala-cli-setup@main
- name: Use CI sbt jvmopts
shell: bash
run: |
Expand Down Expand Up @@ -57,22 +59,35 @@ jobs:
mv .jvmopts_old .jvmopts
cat .jvmopts
- name: Store flamegraphs
- name: Store flame graphs
run: |
git config pull.rebase true
export REV=$(git rev-parse --short HEAD)
echo "Store flame graphs"
echo "Collecting new flame graph"
git config pull.rebase true
read REV COMMIT_DATE COMMIT_TIME COMMIT_TZ COMMIT_MSG <<< \
$(git log --pretty=format:'%h %ad %s' --date=iso8601 -n 1 ${{ github.event.pull_request.head.sha }})
HTML_LINE=" <li>$COMMIT_DATE $COMMIT_TIME <a href=\"$REV\">Flame graphs for $REV</a> $COMMIT_MSG</li>"
echo "::group::Content of zio-kafka-bench directory"
ls -al zio-kafka-bench/
echo "::endgroup::"
mv zio-kafka-bench/zio.kafka.bench.* /tmp
echo "::group::Checkout gh-pages branch"
git clean -fdx
git checkout gh-pages
git pull
git config --global user.name "zio-kafka CI"
git config --global user.email "ziokafkaci@users.noreply.github.com"
echo "::endgroup::"
echo "Remove old flame graphs"
scala-cli scripts/prune-flame-graph.sc
echo "::group::Adding new flame graph"
mkdir -p dev/profile/$REV
mv /tmp/zio.kafka.bench.* dev/profile/$REV
cd dev/profile
find . -maxdepth 1 -type d \( ! -name . \) -exec bash -c "cd '{}' && tree -H . -o index.html" \;
sed -i'' -e '/NEW-FLAME-GRAPHS-GO-HERE/a\'$'\n'"$HTML_LINE"$'\n' index.html
cd ../../
git config --global user.name "zio-kafka CI"
git config --global user.email "ziokafkaci@users.noreply.github.com"
git add .
git commit -m "flamegraphs for $REV"
git push
git commit -m "Flame graphs for $REV"
git push
echo "::endgroup::"
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,6 @@ project/plugins/project/

# MacOS
.DS_Store

#scala-cli
.scala-build/

0 comments on commit a8a5fdd

Please sign in to comment.