Merge pull request #43 from sgrif/feature/asan #110
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: | |
pull_request: | |
types: [opened, synchronize, reopened] | |
push: | |
branches: | |
- master | |
name: CI Tests | |
jobs: | |
check_and_test: | |
name: Check | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, macos-13, macos-14, windows-2022] | |
features: [default, buildtime_bindgen, bundled] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Cache cargo registry | |
uses: Swatinem/rust-cache@v2 | |
with: | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }} | |
- name: Set environment variables | |
shell: bash | |
run: | | |
echo "RUSTFLAGS=-D warnings" >> $GITHUB_ENV | |
echo "RUSTDOCFLAGS=-D warnings" >> $GITHUB_ENV | |
- name: Install mysql (Linux) | |
if: runner.os == 'Linux' && matrix.features != 'bundled' | |
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 "MYSQL_DATABASE_URL=mysql://root:root@localhost/diesel_test" >> $GITHUB_ENV | |
echo "MYSQL_EXAMPLE_DATABASE_URL=mysql://root:root@localhost/diesel_example" >> $GITHUB_ENV | |
echo "MYSQL_UNIT_TEST_DATABASE_URL=mysql://root:root@localhost/diesel_unit_test" >> $GITHUB_ENV | |
- name: Install mysql (MacOS) | |
if: matrix.os == 'macos-13' && matrix.features != 'bundled' | |
run: | | |
brew install mariadb@10.5 | |
/usr/local/opt/mariadb@10.5/bin/mysql_install_db | |
/usr/local/opt/mariadb@10.5/bin/mysql.server start | |
sleep 3 | |
/usr/local/opt/mariadb@10.5/bin/mysql -e "create database diesel_test; create database diesel_unit_test; grant all on \`diesel_%\`.* to 'runner'@'localhost';" -urunner | |
echo "MYSQL_DATABASE_URL=mysql://runner@localhost/diesel_test" >> $GITHUB_ENV | |
echo "MYSQL_EXAMPLE_DATABASE_URL=mysql://runner@localhost/diesel_example" >> $GITHUB_ENV | |
echo "MYSQL_UNIT_TEST_DATABASE_URL=mysql://runner@localhost/diesel_unit_test" >> $GITHUB_ENV | |
echo "PKG_CONFIG_PATH=/usr/local/opt/mariadb@10.5/lib/pkgconfig" >> $GITHUB_ENV | |
echo "BINDGEN_EXTRA_CLANG_ARGS=-I /usr/local/opt/mariadb@10.5/include" >> $GITHUB_ENV | |
ls /usr/local/opt/mariadb@10.5/include/mysql | |
- name: Install mysql (MacOS M1) | |
if: matrix.os == 'macos-14' && matrix.features != 'bundled' | |
run: | | |
brew install mariadb@10.5 | |
ls /opt/homebrew/opt/mariadb@10.5 | |
/opt/homebrew/opt/mariadb@10.5/bin/mysql_install_db | |
/opt/homebrew/opt/mariadb@10.5/bin/mysql.server start | |
sleep 3 | |
/opt/homebrew/opt/mariadb@10.5/bin/mysql -e "create database diesel_test; create database diesel_unit_test; grant all on \`diesel_%\`.* to 'runner'@'localhost';" -urunner | |
echo "MYSQL_DATABASE_URL=mysql://runner@localhost/diesel_test" >> $GITHUB_ENV | |
echo "MYSQL_EXAMPLE_DATABASE_URL=mysql://runner@localhost/diesel_example" >> $GITHUB_ENV | |
echo "MYSQL_UNIT_TEST_DATABASE_URL=mysql://runner@localhost/diesel_unit_test" >> $GITHUB_ENV | |
echo "MYSQLCLIENT_LIB_DIR=/opt/homebrew/opt/mariadb@10.5/lib" >> $GITHUB_ENV | |
echo "BINDGEN_EXTRA_CLANG_ARGS=-I/opt/homebrew/opt/mariadb@10.5/include" >> $GITHUB_ENV | |
echo "MYSQLCLIENT_VERSION=10.5" >> $GITHUB_ENV | |
ls /opt/homebrew/opt/mariadb@10.5/include/mysql | |
- name: Install mysql (Windows) | |
if: runner.os == 'Windows' && matrix.features != 'bundled' | |
shell: cmd | |
run: | | |
curl -L https://dev.mysql.com/get/Downloads/MySQL-8.3/mysql-8.3.0-winx64.zip -o library.zip | |
unzip library.zip | |
- name: Set variables for mysql (Windows) | |
if: runner.os == 'Windows' && matrix.features != 'bundled' | |
shell: bash | |
run: | | |
echo "MYSQLCLIENT_LIB_DIR=${{github.workspace}}/mysql-8.3.0-winx64/lib/" >> $GITHUB_ENV | |
echo "MYSQLCLIENT_VERSION=8.3.0" >> $GITHUB_ENV | |
echo "BINDGEN_EXTRA_CLANG_ARGS=-I./include" >> $GITHUB_ENV | |
mkdir include | |
cp ./mysql-8.3.0-winx64/include include/mysql -r | |
dir ./include/mysql | |
dir ./mysql-8.3.0-winx64/lib | |
- name: Windows setup (bundled) | |
if: runner.os == 'Windows' && matrix.features == 'bundled' | |
shell: bash | |
run: | | |
echo "OPENSSL_RUST_USE_NASM=0" >> $GITHUB_ENV | |
echo OPENSSL_SRC_PERL=C:/Strawberry/perl/bin/perl >> $GITHUB_ENV | |
- name: Install rust toolchain | |
uses: dtolnay/rust-toolchain@stable | |
- name: Check | |
shell: bash | |
run: | | |
cargo check --no-default-features --features "${{ matrix.features }}" --verbose | |
- name: Tests | |
shell: bash | |
run: | | |
cargo test --no-default-features --features "${{ matrix.features }}" | |
- name: Test compile diesel | |
shell: bash | |
run: | | |
cargo new test_diesel | |
cd test_diesel | |
echo "[workspace]" >> Cargo.toml | |
cargo add diesel --no-default-features --features "mysql" --git "https://github.com/weiznich/diesel/" --branch "fix/mysql_troubles" | |
cargo add mysqlclient-sys | |
echo "[patch.crates-io]" >> Cargo.toml | |
echo "mysqlclient-sys = { path = \"..\" }" >> Cargo.toml | |
cat Cargo.toml | |
echo "use diesel::prelude::*;" > src/main.rs | |
echo "fn main() { MysqlConnection::establish(\"foo\").unwrap(); }" >> src/main.rs | |
cargo build --features "mysqlclient-sys/${{ matrix.features }}" | |
- name: Test all files included | |
shell: bash | |
if: matrix.features == 'bundled' | |
run: | | |
rm -rf test_diesel | |
git reset --hard HEAD | |
cd mysqlclient-src | |
cargo publish --dry-run |