Skip to content

Commit 8f69512

Browse files
committed
ci: fixup workflows based on upstream examples
Signed-off-by: NotAShelf <[email protected]> Change-Id: I4c82ef7b6874e213dadbbe3cc1f665466a6a6964
1 parent 48c3807 commit 8f69512

File tree

2 files changed

+96
-52
lines changed

2 files changed

+96
-52
lines changed

.github/workflows/hotpath-comment.yml

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
- completed
88

99
permissions:
10+
contents: read
1011
pull-requests: write
1112

1213
jobs:
@@ -15,35 +16,50 @@ jobs:
1516
if: ${{ github.event.workflow_run.conclusion == 'success' }}
1617

1718
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- name: Setup Rust
23+
uses: dtolnay/rust-toolchain@stable
24+
25+
- name: Rust Cache
26+
uses: Swatinem/rust-cache@v2
27+
1828
- name: Download profiling results
1929
uses: actions/download-artifact@v4
2030
with:
21-
name: hotpath-results
31+
name: profile-metrics
32+
path: /tmp/metrics/
2233
github-token: ${{ secrets.GITHUB_TOKEN }}
2334
run-id: ${{ github.event.workflow_run.id }}
2435

25-
- name: Read PR number
26-
id: pr
27-
run: echo "number=$(cat pr_number.txt)" >> $GITHUB_OUTPUT
28-
29-
- name: Setup Rust
30-
uses: actions-rust-lang/setup-rust-toolchain@v1
31-
3236
- name: Install hotpath CLI
3337
run: cargo install hotpath
3438

39+
- name: Post allocation comparison comment
40+
env:
41+
GH_TOKEN: ${{ github.token }}
42+
run: |
43+
set -euo pipefail
44+
HEAD_METRICS=$(cat /tmp/metrics/head_alloc.json)
45+
BASE_METRICS=$(cat /tmp/metrics/base_alloc.json)
46+
PR_NUMBER=$(cat /tmp/metrics/pr_number.txt)
47+
hotpath profile-pr \
48+
--head-metrics "$HEAD_METRICS" \
49+
--base-metrics "$BASE_METRICS" \
50+
--github-token "$GH_TOKEN" \
51+
--pr-number "$PR_NUMBER"
52+
3553
- name: Post timing comparison comment
36-
run: |
37-
hotpath profile-pr \
38-
--head-metrics head-timing.json \
39-
--base-metrics base-timing.json \
40-
--github-token ${{ secrets.GITHUB_TOKEN }} \
41-
--pr-number ${{ steps.pr.outputs.number }}
42-
43-
- name: Post allocation comparison comment
44-
run: |
45-
hotpath profile-pr \
46-
--head-metrics head-alloc.json \
47-
--base-metrics base-alloc.json \
48-
--github-token ${{ secrets.GITHUB_TOKEN }} \
49-
--pr-number ${{ steps.pr.outputs.number }}
54+
env:
55+
GH_TOKEN: ${{ github.token }}
56+
run: |
57+
set -euo pipefail
58+
HEAD_METRICS=$(cat /tmp/metrics/head_timing.json)
59+
BASE_METRICS=$(cat /tmp/metrics/base_timing.json)
60+
PR_NUMBER=$(cat /tmp/metrics/pr_number.txt)
61+
hotpath profile-pr \
62+
--head-metrics "$HEAD_METRICS" \
63+
--base-metrics "$BASE_METRICS" \
64+
--github-token "$GH_TOKEN" \
65+
--pr-number "$PR_NUMBER"

.github/workflows/hotpath-profile.yml

Lines changed: 58 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,60 +4,88 @@ on:
44
pull_request:
55
branches: [ "main" ]
66

7+
permissions:
8+
contents: read
9+
710
env:
811
CARGO_TERM_COLOR: always
912

1013
jobs:
1114
profile:
1215
runs-on: ubuntu-latest
13-
16+
1417
steps:
1518
- name: Checkout PR HEAD
1619
uses: actions/checkout@v4
17-
20+
with:
21+
fetch-depth: 0
22+
1823
- name: Setup Rust
19-
uses: actions-rust-lang/setup-rust-toolchain@v1
20-
21-
- name: Run timing profiling on HEAD
24+
uses: dtolnay/rust-toolchain@stable
25+
26+
- name: Rust Cache
27+
uses: Swatinem/rust-cache@v2
28+
29+
- name: Run allocation profiling on HEAD
30+
id: head_alloc_metrics
2231
env:
2332
HOTPATH_JSON: "true"
2433
run: |
25-
cargo run --features='hotpath' 2>&1 | grep '^{"hotpath_profiling_mode"' > head-timing.json
26-
27-
- name: Run allocation profiling on HEAD
34+
{
35+
echo 'metrics<<EOF'
36+
cargo run --release --features='hotpath,hotpath-alloc' 2>&1 | grep '^{"hotpath_profiling_mode"'
37+
echo 'EOF'
38+
} >> "$GITHUB_OUTPUT"
39+
40+
- name: Run timing profiling on HEAD
41+
id: head_timing_metrics
2842
env:
2943
HOTPATH_JSON: "true"
3044
run: |
31-
cargo run --features='hotpath,hotpath-alloc-count-total' 2>&1 | grep '^{"hotpath_profiling_mode"' > head-alloc.json
32-
45+
{
46+
echo 'metrics<<EOF'
47+
cargo run --release --features='hotpath' 2>&1 | grep '^{"hotpath_profiling_mode"'
48+
echo 'EOF'
49+
} >> "$GITHUB_OUTPUT"
50+
3351
- name: Checkout base branch
34-
uses: actions/checkout@v4
35-
with:
36-
ref: ${{ github.event.pull_request.base.sha }}
37-
38-
- name: Run timing profiling on base
52+
run: |
53+
git checkout ${{ github.event.pull_request.base.sha }}
54+
55+
- name: Run allocation profiling on base
56+
id: base_alloc_metrics
3957
env:
4058
HOTPATH_JSON: "true"
4159
run: |
42-
cargo run --features='hotpath' 2>&1 | grep '^{"hotpath_profiling_mode"' > base-timing.json
43-
44-
- name: Run allocation profiling on base
60+
{
61+
echo 'metrics<<EOF'
62+
cargo run --release --features='hotpath,hotpath-alloc' 2>&1 | grep '^{"hotpath_profiling_mode"'
63+
echo 'EOF'
64+
} >> "$GITHUB_OUTPUT"
65+
66+
- name: Run timing profiling on base
67+
id: base_timing_metrics
4568
env:
4669
HOTPATH_JSON: "true"
4770
run: |
48-
cargo run --features='hotpath,hotpath-alloc-count-total' 2>&1 | grep '^{"hotpath_profiling_mode"' > base-alloc.json
49-
50-
- name: Save PR number
51-
run: echo "${{ github.event.number }}" > pr_number.txt
52-
71+
{
72+
echo 'metrics<<EOF'
73+
cargo run --release --features='hotpath' 2>&1 | grep '^{"hotpath_profiling_mode"'
74+
echo 'EOF'
75+
} >> "$GITHUB_OUTPUT"
76+
77+
- name: Save metrics to artifact
78+
run: |
79+
mkdir -p /tmp/metrics
80+
echo '${{ steps.head_alloc_metrics.outputs.metrics }}' > /tmp/metrics/head_alloc.json
81+
echo '${{ steps.base_alloc_metrics.outputs.metrics }}' > /tmp/metrics/base_alloc.json
82+
echo '${{ steps.head_timing_metrics.outputs.metrics }}' > /tmp/metrics/head_timing.json
83+
echo '${{ steps.base_timing_metrics.outputs.metrics }}' > /tmp/metrics/base_timing.json
84+
echo '${{ github.event.pull_request.number }}' > /tmp/metrics/pr_number.txt
85+
5386
- name: Upload profiling results
5487
uses: actions/upload-artifact@v4
5588
with:
56-
name: hotpath-results
57-
path: |
58-
head-timing.json
59-
head-alloc.json
60-
base-timing.json
61-
base-alloc.json
62-
pr_number.txt
89+
name: profile-metrics
90+
path: /tmp/metrics/
6391
retention-days: 1

0 commit comments

Comments
 (0)