add more testing scaffolding #162
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
on: [push, pull_request] | |
name: CI | |
jobs: | |
build: | |
name: Tests | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
rust: | |
- stable | |
- 1.65 | |
services: | |
postgres: | |
image: postgres | |
ports: | |
- 5432:5432 | |
env: | |
POSTGRES_PASSWORD: postgres | |
mysql: | |
image: mysql | |
ports: | |
- 3306:3306 | |
env: | |
MYSQL_ROOT_PASSWORD: mysql | |
MYSQL_DATABASE: test | |
steps: | |
- name: Install dependencies | |
run: sudo apt install -y libpq-dev libsqlite3-dev libmysqlclient-dev | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Install toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: ${{ matrix.rust }} | |
override: true | |
- name: Test Postgres | |
uses: actions-rs/cargo@v1 | |
with: | |
command: test | |
args: --manifest-path tests/Cargo.toml --features postgres | |
env: | |
PG_TEST_DATABASE_URL: "postgres://postgres:postgres@localhost:5432" | |
RUST_TEST_THREADS: 1 | |
- name: Create MySQL database | |
run: mysql -h 127.0.0.1 --port 3306 -u root -pmysql -e 'CREATE DATABASE IF NOT EXISTS test;' | |
- name: Test MySQL | |
uses: actions-rs/cargo@v1 | |
with: | |
command: test | |
args: --manifest-path tests/Cargo.toml --features mysql | |
env: | |
MYSQL_TEST_DATABASE_URL: "mysql://root:[email protected]:3306/test" | |
RUST_TEST_THREADS: 1 | |
- name: Test sqlite | |
uses: actions-rs/cargo@v1 | |
with: | |
command: test | |
args: --manifest-path tests/Cargo.toml --features sqlite | |
- name: Install Diesel-CLI | |
run: | | |
cargo install --features postgres --no-default-features diesel_cli | |
diesel --help | |
- name: Run Diesel-CLI tests | |
env: | |
DATABASE_URL: postgres://postgres:postgres@localhost:5432 | |
run: | | |
cd tests_with_diesel_cli | |
# with default schema | |
diesel setup | |
diesel migration run | |
cargo test | |
diesel migration revert | |
rm src/schema.rs diesel.toml | |
# create a custom schema | |
diesel migration run --config-file custom.diesel.toml | |
cargo test --features custom | |
rm -rf src/custom_schema.rs |