Skip to content

fix(ci): use flamegraph v0.6.6 to fix stdout pollution issue #93

fix(ci): use flamegraph v0.6.6 to fix stdout pollution issue

fix(ci): use flamegraph v0.6.6 to fix stdout pollution issue #93

Workflow file for this run

name: Flamegraph PR
on:
pull_request:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
flamegraph:
if: contains(github.event.pull_request.labels.*.name, 'flamegraph')
name: flamegraph
runs-on: ubuntu-latest
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: install flamegraph
run: cargo install flamegraph
- name: generate flamegraph
run: cargo flamegraph --root --verbose -- ../../samples/weather_1M.csv
shell: bash
working-directory: ${{ steps.determine_project.outputs.PROJECT_FOLDER }}
env:
CARGO_PROFILE_RELEASE_DEBUG: "true"
- name: rename the flamegraph to gitsha and run.id
run: |
mkdir -p guide/book/_flamegraphs
mv ${{ steps.determine_project.outputs.PROJECT_FOLDER }}/flamegraph.svg guide/book/_flamegraphs/flamegraph-${{ github.sha }}-${{ github.run_id }}.svg
shell: bash
- name: Store flamegraph
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: guide/book
keep_files: true
- name: post comment
run: |
# link of the just uploaded artefact
LINK='https://rust-meetup-munich.github.io/hack-evening-2024-4/_flamegraphs/flamegraph-${{ github.sha }}-${{ github.run_id }}.svg'
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 }}