fetch_ml/.forgejo/workflows/benchmark-metrics.yml
Jeremie Fraeys 2d66a85abc
Some checks failed
Build CLI with Embedded SQLite / build (arm64, aarch64-linux) (push) Waiting to run
Build CLI with Embedded SQLite / build (x86_64, x86_64-linux) (push) Waiting to run
Build CLI with Embedded SQLite / build-macos (arm64) (push) Waiting to run
Build CLI with Embedded SQLite / build-macos (x86_64) (push) Waiting to run
Documentation / build-and-publish (push) Waiting to run
Security Scan / Security Analysis (push) Waiting to run
Security Scan / Native Library Security (push) Waiting to run
Checkout test / test (push) Successful in 5s
CI/CD Pipeline / Test (push) Has been cancelled
CI/CD Pipeline / Dev Compose Smoke Test (push) Has been cancelled
CI/CD Pipeline / Build (push) Has been cancelled
CI/CD Pipeline / Test Scripts (push) Has been cancelled
CI/CD Pipeline / Test Native Libraries (push) Has been cancelled
CI/CD Pipeline / Docker Build (push) Has been cancelled
ci: add SHA256 verification for SQLite and fix CLI build
- Add SHA256 verification to build_sqlite.sh (SQLite 3.48.0)

- Add build-sqlite and CLI build steps to ci.yml build job

- Remove cache from benchmark-metrics.yml
2026-02-21 20:58:08 -05:00

84 lines
3.3 KiB
YAML

name: Benchmark Metrics
on:
workflow_dispatch:
jobs:
benchmark:
runs-on: self-hosted
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Setup Go (fast)
run: |
REQUIRED_GO="1.25.0"
if command -v go &> /dev/null && go version | grep -q "go${REQUIRED_GO}"; then
echo "Go ${REQUIRED_GO} already installed - skipping download"
else
echo "Installing Go ${REQUIRED_GO}..."
curl -sL "https://go.dev/dl/go${REQUIRED_GO}.linux-amd64.tar.gz" | sudo tar -C /usr/local -xzf -
export PATH="/usr/local/go/bin:$PATH"
echo "/usr/local/go/bin" >> $GITHUB_PATH
echo "Go ${REQUIRED_GO} installed"
fi
go version
- name: Run benchmarks
run: |
echo "Running performance benchmarks..."
go test -bench=. -benchmem ./tests/benchmarks/... > benchmark_results.txt 2>&1
grep "Benchmark.*-[0-9].*" benchmark_results.txt > clean_benchmarks.txt || true
- name: Convert to Prometheus metrics
run: |
echo "# HELP benchmark_time_per_op Time per operation in nanoseconds" > prometheus_metrics.txt
echo "# TYPE benchmark_time_per_op gauge" >> prometheus_metrics.txt
echo "# HELP benchmark_memory_per_op Memory per operation in bytes" >> prometheus_metrics.txt
echo "# TYPE benchmark_memory_per_op gauge" >> prometheus_metrics.txt
echo "# HELP benchmark_allocs_per_op Allocations per operation" >> prometheus_metrics.txt
echo "# TYPE benchmark_allocs_per_op gauge" >> prometheus_metrics.txt
while IFS= read -r line; do
if [[ -n "$line" ]]; then
BENCHMARK_NAME=$(echo "$line" | awk '{print $1}' | sed 's/-[0-9]*$//')
TIME_PER_OP=$(echo "$line" | awk '{print $3}')
MEMORY_PER_OP=$(echo "$line" | awk '{print $4}')
ALLOCS_PER_OP=$(echo "$line" | awk '{print $5}')
CLEAN_NAME=$(echo "$BENCHMARK_NAME" | sed 's/[^a-zA-Z0-9_]/_/g')
echo "benchmark_time_per_op{benchmark=\"$CLEAN_NAME\"} ${TIME_PER_OP/ns/}" >> prometheus_metrics.txt
echo "benchmark_memory_per_op{benchmark=\"$CLEAN_NAME\"} ${MEMORY_PER_OP/B\/op/}" >> prometheus_metrics.txt
echo "benchmark_allocs_per_op{benchmark=\"$CLEAN_NAME\"} ${ALLOCS_PER_OP/allocs\/op/}" >> prometheus_metrics.txt
fi
done < clean_benchmarks.txt
- name: Push to Prometheus Pushgateway
env:
PROMETHEUS_PUSHGATEWAY_URL: ${{ secrets['PROMETHEUS_PUSHGATEWAY_URL'] }}
run: |
if [ -n "$PROMETHEUS_PUSHGATEWAY_URL" ]; then
echo "Pushing metrics to Prometheus..."
curl --data-binary @prometheus_metrics.txt \
"$PROMETHEUS_PUSHGATEWAY_URL/metrics/job/benchmark/instance/${{ github.run_id }}"
else
echo "PROMETHEUS_PUSHGATEWAY_URL not configured, skipping push"
fi
- name: Upload benchmark results
uses: actions/upload-artifact@v4
with:
name: benchmark-results
path: |
benchmark_results.txt
clean_benchmarks.txt
prometheus_metrics.txt
retention-days: 30
- name: Display results summary
run: |
echo "=== Benchmark Results Summary ==="
cat prometheus_metrics.txt | grep "benchmark_time_per_op" | head -10