Skip to content

Track PR metrics with Bencher #1

Track PR metrics with Bencher

Track PR metrics with Bencher #1

Workflow file for this run

on:
push:
branches: master
pull_request:
types: [labeled, opened, reopened, synchronize]
name: Run and Cache Benchmarks
jobs:
run_benchmarks:
if: (github.event_name == 'push' && github.ref == 'refs/heads/master') || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'run-benchmarks'))
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
backend: ["postgres", "sqlite", "mysql"]
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Install postgres (Linux)
if: matrix.backend == 'postgres'
run: |
sudo apt-get update
sudo apt-get install -y libpq-dev postgresql
echo "host all all 127.0.0.1/32 md5" > sudo tee -a /etc/postgresql/10/main/pg_hba.conf
sudo service postgresql restart && sleep 3
sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'postgres';"
sudo service postgresql restart && sleep 3
echo 'DATABASE_URL=postgres://postgres:postgres@localhost/' >> $GITHUB_ENV
- name: Install sqlite (Linux)
if: matrix.backend == 'sqlite'
run: |
sudo apt-get update
sudo apt-get install -y libsqlite3-dev
echo 'DATABASE_URL=/tmp/test.db' >> $GITHUB_ENV
- name: Install mysql (Linux)
if: matrix.backend == 'mysql'
run: |
sudo systemctl start mysql.service
sudo apt-get update
sudo apt-get -y install libmysqlclient-dev
mysql -e "create database diesel_test; create database diesel_unit_test; grant all on \`diesel_%\`.* to 'root'@'localhost';" -uroot -proot
echo 'DATABASE_URL=mysql://root:root@localhost/diesel_test' >> $GITHUB_ENV
- name: Install rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Benchmark ${{ matrix.backend }}
run: cargo +stable bench --manifest-path diesel_bench/Cargo.toml --no-default-features --features "${{ matrix.backend }}" > ${{ matrix.backend }}.txt
- name: Upload ${{ matrix.backend }} Benchmark Results
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.backend }}.txt
path: ./${{ matrix.backend }}.txt
- name: Upload GitHub Event
uses: actions/upload-artifact@v3
with:
name: event.json
path: ${{ github.event_path }}