Files
storage/.github/workflows/benchmark.yml
2025-12-11 07:59:23 +00:00

149 lines
5.6 KiB
YAML

on:
push:
branches:
- master
- main
paths:
- "**"
- "!**.md"
pull_request:
paths:
- "**"
- "!**.md"
permissions:
deployments: write
contents: write
name: Benchmark
jobs:
changes:
runs-on: ubuntu-latest
permissions:
pull-requests: read
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Generate filters
id: filter-setup
run: |
filters=$(find . -maxdepth 1 -type d ! -path ./.git ! -path . ! -path ./testhelpers -exec basename {} \; | grep -v '^\.' | awk '{printf "%s: \"%s/**\"\n", $1, $1}')
echo "filters<<EOF" >> $GITHUB_OUTPUT
echo "$filters" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
shell: bash
- name: Filter changes
id: filter
uses: dorny/paths-filter@v3
with:
filters: ${{ steps.filter-setup.outputs.filters }}
outputs:
packages: ${{ steps.filter.outputs.changes || '[]' }}
compare:
needs: changes
runs-on: ubuntu-latest
timeout-minutes: 30
if: needs.changes.outputs.packages != '[]' # Ensure job runs only if there are changes
strategy:
matrix:
package: ${{ fromJSON(needs.changes.outputs.packages || '[]') }}
fail-fast: false
steps:
- name: Fetch Repository
uses: actions/checkout@v6
- name: Install Go
if: ${{ matrix.package != 'clickhouse' }}
uses: actions/setup-go@v6
with:
# NOTE: Keep this in sync with the version from go.mod
go-version: "1.25.x"
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '20'
- name: Install Cloudflare Worker
if: ${{ matrix.package == 'cloudflarekv' }}
run: |
.github/scripts/initialize-wrangler.sh
cd cloudflarekv && npx wrangler dev &
npx wait-on tcp:8787
- name: Install Coherence
if: ${{ matrix.package == 'coherence' }}
run: |
docker run -d -p 1408:1408 -p 30000:30000 ghcr.io/oracle/coherence-ce:22.06.5
sleep 30
- name: Setup Redis
if: ${{ matrix.package == 'rueidis' || matrix.package == 'valkey' }}
uses: shogo82148/actions-setup-redis@v1
with:
redis-version: '7.x'
auto-start: 'false'
- name: Run Redis
if: ${{ matrix.package == 'rueidis' || matrix.package == 'valkey' }}
run: |
redis-server --port 6379 &
sleep 15
- name: Install MSSQL
if: ${{ matrix.package == 'mssql' }}
run: |
docker run -d --name mssql-server \
--publish 1433:1433 \
--env ACCEPT_EULA=Y \
--env SA_PASSWORD=MsSql!1234 \
--env MSSQL_DB=master \
--env MSSQL_USER=sa \
--env MSSQL_PASSWORD=MsSql!1234 \
--health-cmd "/opt/mssql-tools/bin/sqlcmd -U sa -P MsSql!1234 -Q 'select 1' -b -o /dev/null" \
--health-interval 1s \
--health-timeout 30s \
--health-start-period 10s \
--health-retries 20 \
mcmoe/mssqldocker:latest
- name: Run Benchmarks
working-directory: ${{ matrix.package }}
run: |
set -o pipefail
echo "Bench dir: ${{ matrix.package }}"
go test ./... -timeout 900s -benchmem -run=^$ -bench . | tee -a output.txt
shell: bash
env:
MSSQL_DATABASE: master
MSSQL_USERNAME: sa
MSSQL_PASSWORD: MsSql!1234
TEST_AEROSPIKE_IMAGE: aerospike/aerospike-server:latest
TEST_ARANGODB_IMAGE: arangodb:latest
TEST_AZURITE_IMAGE: mcr.microsoft.com/azure-storage/azurite:latest
TEST_CASSANDRA_IMAGE: "cassandra:latest"
TEST_COHERENCE_IMAGE: "ghcr.io/oracle/coherence-ce:25.03.1-graal"
TEST_CLICKHOUSE_IMAGE: "clickhouse/clickhouse-server:23-alpine"
TEST_COUCHBASE_IMAGE: "couchbase:enterprise-7.6.5"
TEST_DYNAMODB_IMAGE: amazon/dynamodb-local:latest
TEST_ETCD_IMAGE: gcr.io/etcd-development/etcd:v3.6.6
TEST_MEMCACHED_IMAGE: "memcached:latest"
TEST_MINIO_IMAGE: "docker.io/minio/minio:latest"
TEST_MONGODB_IMAGE: "docker.io/mongo:7"
TEST_MYSQL_IMAGE: "docker.io/mysql:9"
TEST_NATS_IMAGE: "nats:2-alpine"
TEST_POSTGRES_IMAGE: "docker.io/postgres:16-alpine"
TEST_REDIS_IMAGE: "docker.io/redis:7"
TEST_SCYLLADB_IMAGE: "scylladb/scylla:6.2"
TEST_SURREALDB_IMAGE: "surrealdb/surrealdb:latest"
TEST_VALKEY_IMAGE: "valkey/valkey:8"
COHERENCE_LOG_LEVEL: "ERROR"
- name: Get Previous Benchmark Results
uses: actions/cache@v4
with:
path: ./cache
key: ${{ runner.os }}-benchmark-${{ matrix.package }}
- name: Save Benchmark Results
uses: benchmark-action/github-action-benchmark@v1.20.7
with:
tool: "go"
output-file-path: ${{ matrix.package }}/output.txt
github-token: ${{ secrets.BENCHMARK_TOKEN }}
benchmark-data-dir-path: "benchmarks/${{ matrix.package }}"
alert-threshold: "300%"
fail-on-alert: true
comment-on-alert: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
#summary-always: ${{ github.event_name != 'push' && github.event_name != 'workflow_dispatch' }}
auto-push: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
save-data-file: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}