Skip to content

Solutions/alexsotocx #76

Solutions/alexsotocx

Solutions/alexsotocx #76

Workflow file for this run

name: Flamegraph PR
on:
pull_request:
workflow_dispatch:
defaults:
run:
shell: bash --noprofile --norc -CeEuxo pipefail {0}
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
flamegraph:
if: ${{ github.event.label.name == 'flamegraph' }}
name: flamegraph
runs-on:
group: Benchmark
timeout-minutes: 8
steps:
- uses: actions/checkout@v4
- name: determine the new added project
id: determine_project
run: |
# Get the name of the main branch (assuming it's 'main')
MAIN_BRANCH="main"
# Fetch the main branch
git fetch origin $MAIN_BRANCH:$MAIN_BRANCH
NEW_FOLDER=$(git diff --name-status $MAIN_BRANCH | grep -E '^[AM]' | awk '{print $2}' | grep 'Cargo.toml' | awk -F/ '{printf("%s/%s\n", $1, $2)}' | uniq)
# Extract the names of new folders
if [[ -z "$NEW_FOLDER" ]]; then
echo "No new project found - skipping the build"
gh run cancel ${{ github.run_id }}
gh run watch ${{ github.run_id }}
fi
# Set the output variable
echo "PROJECT_FOLDER=$NEW_FOLDER" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ github.token }}
# - name: setup | rust
# uses: dtolnay/rust-toolchain@stable
# with:
# default: true
# profile: minimal
- name: build
run: cargo build --release
working-directory: ${{ steps.determine_project.outputs.PROJECT_FOLDER }}
- name: generate flamegraph
run: |
set
echo $0
cargo flamegraph --verbose --cmd "record -F 997 --call-graph dwarf,16384 -g -o /tmp/perf.data" -- ~/samples/weather_1M.csv
shell: bash
working-directory: ${{ steps.determine_project.outputs.PROJECT_FOLDER }}
env:
CARGO_PROFILE_RELEASE_DEBUG: "true"
- name: setup up node with fnm
run: eval "$(fnm env)"
- name: Archive flamegraph
id: artifact-upload-step
uses: actions/upload-artifact@v4
with:
name: flamegraph.svg
path: ${{ steps.determine_project.outputs.PROJECT_FOLDER }}/flamegraph.svg
- name: post comment
run: |
# link of the just uploaded artefact
LINK='${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts/${{ steps.artifact-upload-step.outputs.artifact-id }}'
GITSHA=$(git rev-parse HEAD)
echo "### Flamegraph at $GITSHA" > comment.md
echo "" >> comment.md
echo "![flamegraph]($LINK)" >> comment.md
echo "" >> comment.md
# Post the comment to the PR
gh pr comment ${{ github.event.pull_request.number }} -F comment.md
env:
GH_TOKEN: ${{ github.token }}