Skip to content

Commit c2effd3

Browse files
committed
Update the CI
* Fix the mysql runner * Add MacOS M1 support * Add sqlite support * General housekeeping (actions)
1 parent 1d83ba2 commit c2effd3

File tree

1 file changed

+99
-23
lines changed

1 file changed

+99
-23
lines changed

.github/workflows/ci.yml

+99-23
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,16 @@ jobs:
2121
fail-fast: false
2222
matrix:
2323
rust: ["stable", "beta", "nightly"]
24-
backend: ["postgres", "mysql"]
25-
os: [ubuntu-latest, macos-latest, windows-latest]
24+
backend: ["postgres", "mysql", "sqlite"]
25+
os: [ubuntu-latest, macos-latest, macos-14, windows-latest]
2626
runs-on: ${{ matrix.os }}
2727
steps:
2828
- name: Checkout sources
29-
uses: actions/checkout@v2
29+
uses: actions/checkout@v4
3030

3131
- name: Cache cargo registry
32-
uses: actions/cache@v2
32+
uses: Swatinem/rust-cache@v2
3333
with:
34-
path: |
35-
~/.cargo/registry
36-
~/.cargo/git
3734
key: ${{ runner.os }}-${{ matrix.backend }}-cargo-${{ hashFiles('**/Cargo.toml') }}
3835

3936
- name: Set environment variables
@@ -66,25 +63,85 @@ jobs:
6663
mysql -e "create database diesel_test; create database diesel_unit_test; grant all on \`diesel_%\`.* to 'root'@'localhost';" -uroot -proot
6764
echo "DATABASE_URL=mysql://root:root@localhost/diesel_test" >> $GITHUB_ENV
6865
66+
- name: Install sqlite (Linux)
67+
if: runner.os == 'Linux' && matrix.backend == 'sqlite'
68+
run: |
69+
curl -fsS --retry 3 -o sqlite-autoconf-3400100.tar.gz https://www.sqlite.org/2022/sqlite-autoconf-3400100.tar.gz
70+
tar zxf sqlite-autoconf-3400100.tar.gz
71+
cd sqlite-autoconf-3400100
72+
CFLAGS="$CFLAGS -O2 -fno-strict-aliasing \
73+
-DSQLITE_DEFAULT_FOREIGN_KEYS=1 \
74+
-DSQLITE_SECURE_DELETE \
75+
-DSQLITE_ENABLE_COLUMN_METADATA \
76+
-DSQLITE_ENABLE_FTS3_PARENTHESIS \
77+
-DSQLITE_ENABLE_RTREE=1 \
78+
-DSQLITE_SOUNDEX=1 \
79+
-DSQLITE_ENABLE_UNLOCK_NOTIFY \
80+
-DSQLITE_OMIT_LOOKASIDE=1 \
81+
-DSQLITE_ENABLE_DBSTAT_VTAB \
82+
-DSQLITE_ENABLE_UPDATE_DELETE_LIMIT=1 \
83+
-DSQLITE_ENABLE_LOAD_EXTENSION \
84+
-DSQLITE_ENABLE_JSON1 \
85+
-DSQLITE_LIKE_DOESNT_MATCH_BLOBS \
86+
-DSQLITE_THREADSAFE=1 \
87+
-DSQLITE_ENABLE_FTS3_TOKENIZER=1 \
88+
-DSQLITE_MAX_SCHEMA_RETRY=25 \
89+
-DSQLITE_ENABLE_PREUPDATE_HOOK \
90+
-DSQLITE_ENABLE_SESSION \
91+
-DSQLITE_ENABLE_STMTVTAB \
92+
-DSQLITE_MAX_VARIABLE_NUMBER=250000" \
93+
./configure --prefix=/usr \
94+
--enable-threadsafe \
95+
--enable-dynamic-extensions \
96+
--libdir=/usr/lib/x86_64-linux-gnu \
97+
--libexecdir=/usr/lib/x86_64-linux-gnu/sqlite3
98+
sudo make
99+
sudo make install
100+
echo "DATABASE_URL=/tmp/test.db" >> $GITHUB_ENV
101+
69102
- name: Install postgres (MacOS)
70-
if: runner.os == 'macOS' && matrix.backend == 'postgres'
103+
if: matrix.os == 'macos-latest' && matrix.backend == 'postgres'
71104
run: |
72105
initdb -D /usr/local/var/postgres
73106
pg_ctl -D /usr/local/var/postgres start
74107
sleep 3
75108
createuser -s postgres
76109
echo "DATABASE_URL=postgres://postgres@localhost/" >> $GITHUB_ENV
77110
111+
- name: Install postgres (MacOS M1)
112+
if: matrix.os == 'macos-14' && matrix.backend == 'postgres'
113+
run: |
114+
brew install postgresql
115+
brew services start postgresql@14
116+
sleep 3
117+
createuser -s postgres
118+
echo "DATABASE_URL=postgres://postgres@localhost/" >> $GITHUB_ENV
119+
- name: Install sqlite (MacOS)
120+
if: runner.os == 'macOS' && matrix.backend == 'sqlite'
121+
run: |
122+
brew install sqlite
123+
echo "DATABASE_URL=/tmp/test.db" >> $GITHUB_ENV
124+
78125
- name: Install mysql (MacOS)
79-
if: runner.os == 'macOS' && matrix.backend == 'mysql'
126+
if: matrix.os == 'macos-latest' && matrix.backend == 'mysql'
80127
run: |
81-
brew install --overwrite mariadb@10.8
82-
/usr/local/opt/mariadb@10.8/bin/mysql_install_db
83-
/usr/local/opt/mariadb@10.8/bin/mysql.server start
128+
brew install mariadb@10.5
129+
/usr/local/opt/mariadb@10.5/bin/mysql_install_db
130+
/usr/local/opt/mariadb@10.5/bin/mysql.server start
84131
sleep 3
85-
/usr/local/opt/[email protected]/bin/mysql -e "ALTER USER 'runner'@'localhost' IDENTIFIED BY 'diesel';" -urunner
86-
/usr/local/opt/[email protected]/bin/mysql -e "create database diesel_test; create database diesel_unit_test; grant all on \`diesel_%\`.* to 'runner'@'localhost';" -urunner -pdiesel
87-
echo "DATABASE_URL=mysql://runner:diesel@localhost/diesel_test" >> $GITHUB_ENV
132+
/usr/local/opt/[email protected]/bin/mysql -e "create database diesel_test; create database diesel_unit_test; grant all on \`diesel_%\`.* to 'runner'@'localhost';" -urunner
133+
echo "DATABASE_URL=mysql://runner@localhost/diesel_test" >> $GITHUB_ENV
134+
135+
- name: Install mysql (MacOS M1)
136+
if: matrix.os == 'macos-14' && matrix.backend == 'mysql'
137+
run: |
138+
brew install [email protected]
139+
ls /opt/homebrew/opt/[email protected]
140+
/opt/homebrew/opt/[email protected]/bin/mysql_install_db
141+
/opt/homebrew/opt/[email protected]/bin/mysql.server start
142+
sleep 3
143+
/opt/homebrew/opt/[email protected]/bin/mysql -e "create database diesel_test; create database diesel_unit_test; grant all on \`diesel_%\`.* to 'runner'@'localhost';" -urunner
144+
echo "DATABASE_URL=mysql://runner@localhost/diesel_test" >> $GITHUB_ENV
88145
89146
- name: Install postgres (Windows)
90147
if: runner.os == 'Windows' && matrix.backend == 'postgres'
@@ -106,6 +163,22 @@ jobs:
106163
run: |
107164
echo "DATABASE_URL=mysql://root@localhost/diesel_test" >> $GITHUB_ENV
108165
166+
- name: Install sqlite (Windows)
167+
if: runner.os == 'Windows' && matrix.backend == 'sqlite'
168+
shell: cmd
169+
run: |
170+
choco install sqlite
171+
cd /D C:\ProgramData\chocolatey\lib\SQLite\tools
172+
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
173+
lib /machine:x64 /def:sqlite3.def /out:sqlite3.lib
174+
- name: Set variables for sqlite (Windows)
175+
if: runner.os == 'Windows' && matrix.backend == 'sqlite'
176+
shell: bash
177+
run: |
178+
echo "C:\ProgramData\chocolatey\lib\SQLite\tools" >> $GITHUB_PATH
179+
echo "SQLITE3_LIB_DIR=C:\ProgramData\chocolatey\lib\SQLite\tools" >> $GITHUB_ENV
180+
echo "DATABASE_URL=C:\test.db" >> $GITHUB_ENV
181+
109182
- name: Install rust toolchain
110183
uses: dtolnay/rust-toolchain@master
111184
with:
@@ -115,26 +188,29 @@ jobs:
115188

116189
- name: Test diesel_async
117190
run: cargo +${{ matrix.rust }} test --manifest-path Cargo.toml --no-default-features --features "${{ matrix.backend }} deadpool bb8 mobc"
118-
- name: Run examples
191+
192+
- name: Run examples (Postgres)
119193
if: matrix.backend == 'postgres'
120194
run: |
121195
cargo +${{ matrix.rust }} check --manifest-path examples/postgres/pooled-with-rustls/Cargo.toml
122196
cargo +${{ matrix.rust }} check --manifest-path examples/postgres/run-pending-migrations-with-rustls/Cargo.toml
123197
198+
- name: Run examples (Sqlite)
199+
if: matrix.backend == 'sqlite'
200+
run: |
201+
cargo +${{ matrix.rust }} check --manifest-path examples/sync-wrapper/Cargo.toml
202+
124203
rustfmt_and_clippy:
125204
name: Check rustfmt style && run clippy
126205
runs-on: ubuntu-latest
127206
steps:
128-
- uses: actions/checkout@v2
207+
- uses: actions/checkout@v4
129208
- uses: dtolnay/rust-toolchain@stable
130209
with:
131210
components: clippy, rustfmt
132211
- name: Cache cargo registry
133-
uses: actions/cache@v2
212+
uses: Swatinem/rust-cache@v2
134213
with:
135-
path: |
136-
~/.cargo/registry
137-
~/.cargo/git
138214
key: clippy-cargo-${{ hashFiles('**/Cargo.toml') }}
139215

140216
- name: Remove potential newer clippy.toml from dependencies
@@ -152,12 +228,12 @@ jobs:
152228
name: Check Minimal supported rust version (1.65.0)
153229
runs-on: ubuntu-latest
154230
steps:
155-
- uses: actions/checkout@v3
231+
- uses: actions/checkout@v4
156232
- uses: dtolnay/[email protected]
157233
- uses: dtolnay/rust-toolchain@nightly
158234
- uses: taiki-e/install-action@cargo-hack
159235
- uses: taiki-e/install-action@cargo-minimal-versions
160236
- name: Check diesel-async
161237
# cannot test mysql yet as that crate
162238
# has broken min-version dependencies
163-
run: cargo +stable minimal-versions check -p diesel-async --features "postgres bb8 deadpool mobc"
239+
run: cargo +stable minimal-versions check -p diesel-async --features "postgres bb8 deadpool mobc sqlite"

0 commit comments

Comments
 (0)