-
Notifications
You must be signed in to change notification settings - Fork 13
87 lines (73 loc) · 2.89 KB
/
Copy pathflamegraph-pr.yml
File metadata and controls
87 lines (73 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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 "" >> 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 }}