mirror of
https://github.com/gofiber/storage.git
synced 2025-12-24 13:29:30 +08:00
217 lines
7.4 KiB
YAML
217 lines
7.4 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@v4
|
|
|
|
- name: Generate filters
|
|
id: filter-setup
|
|
run: |
|
|
filters=$(find . -maxdepth 1 -type d ! -path ./.git ! -path . -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@v4
|
|
|
|
- name: Install Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
# NOTE: Keep this in sync with the version from go.mod
|
|
go-version: "1.21.x"
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '18'
|
|
|
|
- name: Install ArangoDB
|
|
if: ${{ matrix.package == 'arangodb' }}
|
|
run: |
|
|
docker run -d -p 8529:8529 -e "ARANGO_NO_AUTH=1" arangodb:latest
|
|
|
|
- name: Install DynamoDB
|
|
if: ${{ matrix.package == 'dynamodb' }}
|
|
run: |
|
|
docker run -d -p 8000:8000 amazon/dynamodb-local:latest
|
|
|
|
- name: Install Memcached
|
|
if: ${{ matrix.package == 'memcache' }}
|
|
run: |
|
|
docker run -d -p 11211:11211 memcached:latest
|
|
|
|
- name: Install MongoDB
|
|
if: ${{ matrix.package == 'mongodb' }}
|
|
run: |
|
|
docker run -d -p 27017:27017 mongo:latest
|
|
|
|
- name: Install MSSQL
|
|
if: ${{ matrix.package == 'mssql' }}
|
|
run: |
|
|
docker run -d -p 1433:1433 \
|
|
-e "ACCEPT_EULA=Y" -e "SA_PASSWORD=MsSql!1234" \
|
|
-e "MSSQL_DB=master" -e "MSSQL_USER=sa" \
|
|
-e "MSSQL_PASSWORD=MsSql!1234" \
|
|
--health-cmd "/opt/mssql-tools/bin/sqlcmd -U sa -P $SA_PASSWORD -Q 'select 1' -b -o /dev/null" \
|
|
--health-interval 1s \
|
|
--health-timeout 30s \
|
|
--health-start-period 10s \
|
|
--health-retries 20 \
|
|
mcmoe/mssqldocker:latest
|
|
|
|
- name: Install MySQL
|
|
if: ${{ matrix.package == 'mysql' }}
|
|
run: |
|
|
docker run -d -p 3306:3306 \
|
|
-e "MYSQL_DATABASE=fiber" \
|
|
-e "MYSQL_USER=username" \
|
|
-e "MYSQL_PASSWORD=password" \
|
|
-e "MYSQL_ROOT_PASSWORD=password" \
|
|
--health-cmd "mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 5 \
|
|
mysql:latest
|
|
|
|
- name: Install Postgres
|
|
if: ${{ matrix.package == 'postgres' }}
|
|
run: |
|
|
docker run -d -p 5432:5432 \
|
|
-e "POSTGRES_DB=fiber" \
|
|
-e "POSTGRES_USER=username" \
|
|
-e "POSTGRES_PASSWORD=pass#w%rd" \
|
|
--health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 \
|
|
postgres:latest
|
|
|
|
- name: Install Azurite
|
|
if: ${{ matrix.package == 'azureblob' }}
|
|
run: |
|
|
docker run -d -p 10000:10000 mcr.microsoft.com/azure-storage/azurite azurite-blob --blobHost 0.0.0.0 --blobPort 10000
|
|
|
|
- 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: Install etcd
|
|
if: ${{ matrix.package == 'etcd' }}
|
|
run: |
|
|
docker run -d --name Etcd-server \
|
|
--publish 2379:2379 \
|
|
--publish 2380:2380 \
|
|
--env ALLOW_NONE_AUTHENTICATION=yes \
|
|
--env ETCD_ADVERTISE_CLIENT_URLS=http://etcd-server:2379 \
|
|
bitnami/etcd:latest
|
|
|
|
- name: Install ScyllaDb
|
|
if: ${{ matrix.package == 'scylladb' }}
|
|
run: |
|
|
docker run --name scylladb -p 9042:9042 -p 19042:19042 -p 9160:9160 -p 7000:7000 -p 7001:7001 -p 7199:7199 -p 9180:9180 -d scylladb/scylla:latest --broadcast-address 127.0.0.1 --listen-address 0.0.0.0 --broadcast-rpc-address 127.0.0.1
|
|
sleep 15 # Wait for ScyllaDb to initialize
|
|
|
|
- name: Setup Redis
|
|
if: ${{ matrix.package == 'redis' || matrix.package == 'rueidis' }}
|
|
uses: shogo82148/actions-setup-redis@v1
|
|
with:
|
|
redis-version: '7.x'
|
|
auto-start: 'false'
|
|
|
|
- name: Run Redis
|
|
if: ${{ matrix.package == 'redis' || matrix.package == 'rueidis' }}
|
|
run: |
|
|
redis-server --port 6379 &
|
|
|
|
- name: Run NATS
|
|
if: ${{ matrix.package == 'nats' }}
|
|
run: |
|
|
./.github/scripts/gen-test-certs.sh
|
|
docker run -d --name nats-jetstream -p 4443:4443 -v ./nats/testdata:/testdata -v ./tls:/tls nats:latest --jetstream -c /testdata/nats-tls.conf
|
|
sleep 2
|
|
|
|
- name: Run Benchmarks
|
|
working-directory: ${{ matrix.package }}
|
|
run: |
|
|
set -o pipefail
|
|
echo "Bench dir: ${{ matrix.package }}"
|
|
go test ./... -benchmem -run=^$ -bench . | tee -a output.txt
|
|
shell: bash
|
|
env:
|
|
MSSQL_DATABASE: master
|
|
MSSQL_USERNAME: sa
|
|
MSSQL_PASSWORD: MsSql!1234
|
|
MYSQL_USERNAME: username
|
|
MYSQL_PASSWORD: password
|
|
MYSQL_DATABASE: fiber
|
|
POSTGRES_DATABASE: fiber
|
|
POSTGRES_USERNAME: username
|
|
POSTGRES_PASSWORD: "pass#w%rd"
|
|
TEST_CLICKHOUSE_IMAGE: "clickhouse/clickhouse-server:23-alpine"
|
|
TEST_COUCHBASE_IMAGE: "couchbase:enterprise-7.1.1"
|
|
TEST_MINIO_IMAGE: "docker.io/minio/minio:RELEASE.2024-08-17T01-24-54Z"
|
|
|
|
- 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.4
|
|
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' }}
|