ci: fixup workflows based on upstream examples

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I4c82ef7b6874e213dadbbe3cc1f665466a6a6964
This commit is contained in:
raf 2025-11-30 15:20:42 +03:00
commit 8f69512e40
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
2 changed files with 102 additions and 58 deletions

View file

@ -7,6 +7,7 @@ on:
- completed
permissions:
contents: read
pull-requests: write
jobs:
@ -15,35 +16,50 @@ jobs:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Download profiling results
uses: actions/download-artifact@v4
with:
name: hotpath-results
name: profile-metrics
path: /tmp/metrics/
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
- name: Read PR number
id: pr
run: echo "number=$(cat pr_number.txt)" >> $GITHUB_OUTPUT
- name: Setup Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Install hotpath CLI
run: cargo install hotpath
- name: Post timing comparison comment
run: |
hotpath profile-pr \
--head-metrics head-timing.json \
--base-metrics base-timing.json \
--github-token ${{ secrets.GITHUB_TOKEN }} \
--pr-number ${{ steps.pr.outputs.number }}
- name: Post allocation comparison comment
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
HEAD_METRICS=$(cat /tmp/metrics/head_alloc.json)
BASE_METRICS=$(cat /tmp/metrics/base_alloc.json)
PR_NUMBER=$(cat /tmp/metrics/pr_number.txt)
hotpath profile-pr \
--head-metrics head-alloc.json \
--base-metrics base-alloc.json \
--github-token ${{ secrets.GITHUB_TOKEN }} \
--pr-number ${{ steps.pr.outputs.number }}
--head-metrics "$HEAD_METRICS" \
--base-metrics "$BASE_METRICS" \
--github-token "$GH_TOKEN" \
--pr-number "$PR_NUMBER"
- name: Post timing comparison comment
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
HEAD_METRICS=$(cat /tmp/metrics/head_timing.json)
BASE_METRICS=$(cat /tmp/metrics/base_timing.json)
PR_NUMBER=$(cat /tmp/metrics/pr_number.txt)
hotpath profile-pr \
--head-metrics "$HEAD_METRICS" \
--base-metrics "$BASE_METRICS" \
--github-token "$GH_TOKEN" \
--pr-number "$PR_NUMBER"

View file

@ -4,6 +4,9 @@ on:
pull_request:
branches: [ "main" ]
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
@ -14,50 +17,75 @@ jobs:
steps:
- name: Checkout PR HEAD
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
uses: dtolnay/rust-toolchain@stable
- name: Run timing profiling on HEAD
env:
HOTPATH_JSON: "true"
run: |
cargo run --features='hotpath' 2>&1 | grep '^{"hotpath_profiling_mode"' > head-timing.json
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Run allocation profiling on HEAD
id: head_alloc_metrics
env:
HOTPATH_JSON: "true"
run: |
cargo run --features='hotpath,hotpath-alloc-count-total' 2>&1 | grep '^{"hotpath_profiling_mode"' > head-alloc.json
{
echo 'metrics<<EOF'
cargo run --release --features='hotpath,hotpath-alloc' 2>&1 | grep '^{"hotpath_profiling_mode"'
echo 'EOF'
} >> "$GITHUB_OUTPUT"
- name: Run timing profiling on HEAD
id: head_timing_metrics
env:
HOTPATH_JSON: "true"
run: |
{
echo 'metrics<<EOF'
cargo run --release --features='hotpath' 2>&1 | grep '^{"hotpath_profiling_mode"'
echo 'EOF'
} >> "$GITHUB_OUTPUT"
- name: Checkout base branch
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.base.sha }}
- name: Run timing profiling on base
env:
HOTPATH_JSON: "true"
run: |
cargo run --features='hotpath' 2>&1 | grep '^{"hotpath_profiling_mode"' > base-timing.json
git checkout ${{ github.event.pull_request.base.sha }}
- name: Run allocation profiling on base
id: base_alloc_metrics
env:
HOTPATH_JSON: "true"
run: |
cargo run --features='hotpath,hotpath-alloc-count-total' 2>&1 | grep '^{"hotpath_profiling_mode"' > base-alloc.json
{
echo 'metrics<<EOF'
cargo run --release --features='hotpath,hotpath-alloc' 2>&1 | grep '^{"hotpath_profiling_mode"'
echo 'EOF'
} >> "$GITHUB_OUTPUT"
- name: Save PR number
run: echo "${{ github.event.number }}" > pr_number.txt
- name: Run timing profiling on base
id: base_timing_metrics
env:
HOTPATH_JSON: "true"
run: |
{
echo 'metrics<<EOF'
cargo run --release --features='hotpath' 2>&1 | grep '^{"hotpath_profiling_mode"'
echo 'EOF'
} >> "$GITHUB_OUTPUT"
- name: Save metrics to artifact
run: |
mkdir -p /tmp/metrics
echo '${{ steps.head_alloc_metrics.outputs.metrics }}' > /tmp/metrics/head_alloc.json
echo '${{ steps.base_alloc_metrics.outputs.metrics }}' > /tmp/metrics/base_alloc.json
echo '${{ steps.head_timing_metrics.outputs.metrics }}' > /tmp/metrics/head_timing.json
echo '${{ steps.base_timing_metrics.outputs.metrics }}' > /tmp/metrics/base_timing.json
echo '${{ github.event.pull_request.number }}' > /tmp/metrics/pr_number.txt
- name: Upload profiling results
uses: actions/upload-artifact@v4
with:
name: hotpath-results
path: |
head-timing.json
head-alloc.json
base-timing.json
base-alloc.json
pr_number.txt
name: profile-metrics
path: /tmp/metrics/
retention-days: 1