forked from diesel-rs/diesel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
132 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
on: | ||
push: | ||
branches: does_not_exist | ||
pull_request_target: | ||
|
||
name: Benchmarks | ||
|
||
jobs: | ||
benchmarks: | ||
if: (github.event_name == 'push' && github.ref == 'refs/heads/master') || (github.event_name == 'pull_request_target' && contains(github.event.pull_request.labels.*.name, 'run-benchmarks')) | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
backend: ["postgres", "sqlite", "mysql"] | ||
env: | ||
BENCHER_PROJECT: diesel | ||
BENCHER_ADAPTER: rust_criterion | ||
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: Install Bencher CLI | ||
uses: bencherdev/bencher@main | ||
|
||
- name: Benchmark master | ||
if: github.event_name == 'push' && github.ref == 'refs/heads/master' | ||
env: | ||
BENCHER_BRANCH: master | ||
BENCHER_TESTBED: ubuntu-latest-${{ matrix.backend }} | ||
run: | | ||
bencher run \ | ||
--token '${{ secrets.BENCHER_API_TOKEN }}' \ | ||
'cargo +stable bench --manifest-path diesel_bench/Cargo.toml --no-default-features --features "${{ matrix.backend }}"' | ||
- name: Checkout PR sources | ||
if: github.event_name == 'pull_request_target' && contains(github.event.pull_request.labels.*.name, 'run-benchmarks') | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
repository: ${{ github.event.pull_request.head.repo.full_name }} | ||
persist-credentials: false | ||
|
||
- name: Benchmark PR ${{ github.event.pull_request.number }} | ||
if: github.event_name == 'pull_request_target' && contains(github.event.pull_request.labels.*.name, 'run-benchmarks') | ||
env: | ||
BENCHER_TESTBED: ubuntu-latest-${{ matrix.backend }} | ||
run: | | ||
bencher run \ | ||
--if-branch '${{ github.event.pull_request.head.ref }}' \ | ||
--else-if-branch '${{ github.event.pull_request.base.ref }}' \ | ||
--else-if-branch master \ | ||
--err \ | ||
--github-actions '${{ secrets.GITHUB_TOKEN }}' \ | ||
--token '${{ secrets.BENCHER_API_TOKEN }}' \ | ||
'cargo +stable bench --manifest-path diesel_bench/Cargo.toml --no-default-features --features "${{ matrix.backend }}"' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters