fix(ci): pin Rust version, ditch unmaintained actions (#3234)

This commit is contained in:
Austin Bonander 2024-05-14 23:57:31 -07:00 committed by GitHub
parent 5d6c33ed65
commit 60d033eda2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 141 additions and 260 deletions

View File

@ -10,27 +10,15 @@ on:
jobs:
format:
name: Format
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
# this is cheaper than requesting the non-minimal profile
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- run: cargo fmt --all -- --check
check:
name: Check
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
matrix:
runtime: [async-std, tokio]
@ -38,38 +26,32 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- uses: Swatinem/rust-cache@v2
with:
profile: minimal
toolchain: stable
override: true
key: "${{ runner.os }}-check-${{ matrix.runtime }}-${{ matrix.tls }}"
- uses: Swatinem/rust-cache@v1
with:
key: ${{ runner.os }}-check-${{ matrix.runtime }}-${{ matrix.tls }}
- run: |
rustup update
rustup component add clippy
rustup toolchain install beta
- uses: actions-rs/cargo@v1
with:
command: check
args: >
--manifest-path sqlx-core/Cargo.toml
--no-default-features
--features json,offline,migrate,_rt-${{ matrix.runtime }},_tls-${{ matrix.tls }}
env:
RUSTFLAGS: -D warnings
- run: >
cargo clippy
--no-default-features
--features all-databases,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }},macros
-- -D warnings
- uses: actions-rs/cargo@v1
with:
command: check
args: >
--no-default-features
--features all-databases,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }},macros
env:
RUSTFLAGS: -D warnings
# Run beta for new warnings but don't break the build.
# Use a subdirectory of `target` to avoid clobbering the cache.
- run: >
cargo +beta clippy
--no-default-features
--features all-databases,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }},macros
--target-dir target/beta/
test:
name: Unit Test
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
matrix:
runtime: [async-std, tokio]
@ -77,44 +59,26 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: Swatinem/rust-cache@v1
- uses: Swatinem/rust-cache@v2
with:
key: ${{ runner.os }}-test
- uses: actions-rs/cargo@v1
with:
command: test
args: >
--manifest-path sqlx-core/Cargo.toml
--features json,_rt-${{ matrix.runtime }},_tls-${{ matrix.tls }}
- run: >
cargo test
--manifest-path sqlx-core/Cargo.toml
--features json,_rt-${{ matrix.runtime }},_tls-${{ matrix.tls }}
cli-test:
name: CLI Unit Test
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: Swatinem/rust-cache@v1
- uses: Swatinem/rust-cache@v2
with:
key: ${{ runner.os }}-test
- uses: actions-rs/cargo@v1
with:
command: test
args: >
--manifest-path sqlx-cli/Cargo.toml
- run: cargo test --manifest-path sqlx-cli/Cargo.toml
cli:
name: CLI Binaries
@ -139,21 +103,11 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: ${{ matrix.target }}
override: true
- uses: Swatinem/rust-cache@v1
- uses: Swatinem/rust-cache@v2
with:
key: ${{ runner.os }}-cli
- uses: actions-rs/cargo@v1
with:
command: build
args: --manifest-path sqlx-cli/Cargo.toml --bin cargo-sqlx ${{ matrix.args }}
- run: cargo build --manifest-path sqlx-cli/Cargo.toml --bin cargo-sqlx ${{ matrix.args }}
- uses: actions/upload-artifact@v2
with:
@ -162,7 +116,7 @@ jobs:
sqlite:
name: SQLite
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
matrix:
runtime: [async-std, tokio]
@ -172,29 +126,21 @@ jobs:
- run: mkdir /tmp/sqlite3-lib && wget -O /tmp/sqlite3-lib/ipaddr.so https://github.com/nalgeon/sqlean/releases/download/0.15.2/ipaddr.so
- uses: actions-rs/toolchain@v1
- uses: Swatinem/rust-cache@v2
with:
profile: minimal
toolchain: stable
override: true
- uses: Swatinem/rust-cache@v1
with:
key: ${{ runner.os }}-sqlite-${{ matrix.runtime }}-${{ matrix.tls }}
key: "${{ runner.os }}-sqlite-${{ matrix.runtime }}-${{ matrix.tls }}"
- run: echo "using ${DATABASE_URL}"
# Create data dir for offline mode
- run: mkdir .sqlx
- uses: actions-rs/cargo@v1
with:
command: test
args: >
--no-default-features
--features any,macros,sqlite,_unstable-all-types,runtime-${{ matrix.runtime }}
--
--test-threads=1
- run: >
cargo test
--no-default-features
--features any,macros,sqlite,_unstable-all-types,runtime-${{ matrix.runtime }}
--
--test-threads=1
env:
DATABASE_URL: sqlite:tests/sqlite/sqlite.db
SQLX_OFFLINE_DIR: .sqlx
@ -205,13 +151,11 @@ jobs:
- run: cargo clean -p sqlx
# Build the macros-test in offline mode (omit DATABASE_URL)
- uses: actions-rs/cargo@v1
with:
command: build
args: >
--no-default-features
--test sqlite-macros
--features any,macros,sqlite,_unstable-all-types,runtime-${{ matrix.runtime }}
- run: >
cargo test
--no-default-features
--test sqlite-macros
--features any,macros,sqlite,_unstable-all-types,runtime-${{ matrix.runtime }}
env:
SQLX_OFFLINE: true
SQLX_OFFLINE_DIR: .sqlx
@ -219,13 +163,11 @@ jobs:
LD_LIBRARY_PATH: /tmp/sqlite3-lib
# Test macros in offline mode (still needs DATABASE_URL to run)
- uses: actions-rs/cargo@v1
with:
command: test
args: >
--no-default-features
--test sqlite-macros
--features any,macros,sqlite,_unstable-all-types,runtime-${{ matrix.runtime }}
- run: >
cargo test
--no-default-features
--test sqlite-macros
--features any,macros,sqlite,_unstable-all-types,runtime-${{ matrix.runtime }}
env:
DATABASE_URL: sqlite://tests/sqlite/sqlite.db
SQLX_OFFLINE: true
@ -235,7 +177,7 @@ jobs:
postgres:
name: Postgres
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
matrix:
postgres: [15, 11]
@ -245,25 +187,15 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- uses: Swatinem/rust-cache@v2
with:
profile: minimal
toolchain: stable
override: true
key: "${{ runner.os }}-postgres-${{ matrix.runtime }}-${{ matrix.tls }}"
- uses: Swatinem/rust-cache@v1
with:
key: ${{ runner.os }}-postgres-${{ matrix.runtime }}-${{ matrix.tls }}
- uses: actions-rs/cargo@v1
env:
- env:
# FIXME: needed to disable `ltree` tests in Postgres 9.6
# but `PgLTree` should just fall back to text format
RUSTFLAGS: -D warnings --cfg postgres_${{ matrix.postgres }}
with:
command: build
args: >
--features postgres,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
run: cargo build --features postgres,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
- run: |
docker compose -f tests/docker-compose.yml run -d -p 5432:5432 --name postgres_${{ matrix.postgres }} postgres_${{ matrix.postgres }}
@ -272,12 +204,10 @@ jobs:
# Create data dir for offline mode
- run: mkdir .sqlx
- uses: actions-rs/cargo@v1
with:
command: test
args: >
--no-default-features
--features any,postgres,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
- run: : >
cargo test
--no-default-features
--features any,postgres,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
env:
DATABASE_URL: postgres://postgres:password@localhost:5432/sqlx
SQLX_OFFLINE_DIR: .sqlx
@ -285,13 +215,11 @@ jobs:
# but `PgLTree` should just fall back to text format
RUSTFLAGS: --cfg postgres_${{ matrix.postgres }}
- uses: actions-rs/cargo@v1
if: matrix.tls != 'none'
with:
command: test
args: >
--no-default-features
--features any,postgres,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
- if: matrix.tls != 'none'
run: >
cargo test
--no-default-features
--features any,postgres,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
env:
DATABASE_URL: postgres://postgres:password@localhost:5432/sqlx?sslmode=verify-ca&sslrootcert=.%2Ftests%2Fcerts%2Fca.crt
SQLX_OFFLINE_DIR: .sqlx
@ -303,13 +231,11 @@ jobs:
- run: cargo clean -p sqlx
# Build the macros-test in offline mode (omit DATABASE_URL)
- uses: actions-rs/cargo@v1
with:
command: build
args: >
--no-default-features
--test postgres-macros
--features any,postgres,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
- run: >
cargo build
--no-default-features
--test postgres-macros
--features any,postgres,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
env:
SQLX_OFFLINE: true
SQLX_OFFLINE_DIR: .sqlx
@ -318,13 +244,11 @@ jobs:
RUSTFLAGS: -D warnings --cfg postgres_${{ matrix.postgres }}
# Test macros in offline mode (still needs DATABASE_URL to run)
- uses: actions-rs/cargo@v1
with:
command: test
args: >
--no-default-features
--test postgres-macros
--features any,postgres,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
- run: >
cargo test
--no-default-features
--test postgres-macros
--features any,postgres,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
env:
DATABASE_URL: postgres://postgres:password@localhost:5432/sqlx
SQLX_OFFLINE: true
@ -340,13 +264,11 @@ jobs:
docker compose -f tests/docker-compose.yml run -d -p 5432:5432 --name postgres_${{ matrix.postgres }}_client_ssl postgres_${{ matrix.postgres }}_client_ssl
docker exec postgres_${{ matrix.postgres }}_client_ssl bash -c "until pg_isready; do sleep 1; done"
- uses: actions-rs/cargo@v1
if: matrix.tls != 'none'
with:
command: test
args: >
--no-default-features
--features any,postgres,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
- if: matrix.tls != 'none'
run: >
cargo test
--no-default-features
--features any,postgres,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
env:
DATABASE_URL: postgres://postgres@localhost:5432/sqlx?sslmode=verify-ca&sslrootcert=.%2Ftests%2Fcerts%2Fca.crt&sslkey=.%2Ftests%2Fkeys%2Fclient.key&sslcert=.%2Ftests%2Fcerts%2Fclient.crt
# FIXME: needed to disable `ltree` tests in Postgres 9.6
@ -355,7 +277,7 @@ jobs:
mysql:
name: MySQL
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
matrix:
mysql: [8, 5_7]
@ -365,21 +287,11 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- uses: Swatinem/rust-cache@v2
with:
profile: minimal
toolchain: stable
override: true
key: "${{ runner.os }}-mysql-${{ matrix.runtime }}-${{ matrix.tls }}"
- uses: Swatinem/rust-cache@v1
with:
key: ${{ runner.os }}-mysql-${{ matrix.runtime }}-${{ matrix.tls }}
- uses: actions-rs/cargo@v1
with:
command: build
args: >
--features mysql,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
- run: cargo build --features mysql,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
- run: docker compose -f tests/docker-compose.yml run -d -p 3306:3306 --name mysql_${{ matrix.mysql }} mysql_${{ matrix.mysql }}
- run: sleep 60
@ -387,25 +299,21 @@ jobs:
# Create data dir for offline mode
- run: mkdir .sqlx
- uses: actions-rs/cargo@v1
with:
command: test
args: >
--no-default-features
--features any,mysql,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
- run: >
cargo test
--no-default-features
--features any,mysql,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
env:
DATABASE_URL: mysql://root:password@localhost:3306/sqlx?ssl-mode=disabled
SQLX_OFFLINE_DIR: .sqlx
RUSTFLAGS: --cfg mysql_${{ matrix.mysql }}
# MySQL 5.7 supports TLS but not TLSv1.3 as required by RusTLS.
- uses: actions-rs/cargo@v1
if: ${{ !(matrix.mysql == '5_7' && matrix.tls == 'rustls') }}
with:
command: test
args: >
--no-default-features
--features any,mysql,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
- if: ${{ !(matrix.mysql == '5_7' && matrix.tls == 'rustls') }}
run: >
cargo test
--no-default-features
--features any,mysql,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
env:
DATABASE_URL: mysql://root:password@localhost:3306/sqlx
SQLX_OFFLINE_DIR: .sqlx
@ -415,13 +323,11 @@ jobs:
- run: cargo clean -p sqlx
# Build the macros-test in offline mode (omit DATABASE_URL)
- uses: actions-rs/cargo@v1
with:
command: build
args: >
--no-default-features
--test mysql-macros
--features any,mysql,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
- run: >
cargo test
--no-default-features
--test mysql-macros
--features any,mysql,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
env:
SQLX_OFFLINE: true
SQLX_OFFLINE_DIR: .sqlx
@ -429,14 +335,11 @@ jobs:
# Test macros in offline mode (still needs DATABASE_URL to run)
# MySQL 5.7 supports TLS but not TLSv1.3 as required by RusTLS.
- uses: actions-rs/cargo@v1
if: ${{ !(matrix.mysql == '5_7' && matrix.tls == 'rustls') }}
with:
command: test
args: >
--no-default-features
--test mysql-macros
--features any,mysql,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
- run: >
cargo test
--no-default-features
--test mysql-macros
--features any,mysql,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
env:
DATABASE_URL: mysql://root:password@localhost:3306/sqlx
SQLX_OFFLINE: true
@ -451,20 +354,17 @@ jobs:
sleep 60
# MySQL 5.7 supports TLS but not TLSv1.3 as required by RusTLS.
- uses: actions-rs/cargo@v1
if: ${{ !(matrix.mysql == '5_7' && matrix.tls == 'rustls') && matrix.tls != 'none' }}
with:
command: test
args: >
--no-default-features
--features any,mysql,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
- run: >
cargo test
--no-default-features
--features any,mysql,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
env:
DATABASE_URL: mysql://root@localhost:3306/sqlx?sslmode=verify_ca&ssl-ca=.%2Ftests%2Fcerts%2Fca.crt&ssl-key=.%2Ftests%2Fkeys%2Fclient.key&ssl-cert=.%2Ftests%2Fcerts%2Fclient.crt
RUSTFLAGS: --cfg mysql_${{ matrix.mysql }}
mariadb:
name: MariaDB
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
matrix:
mariadb: [verylatest, 10_11, 10_4]
@ -478,21 +378,11 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- uses: Swatinem/rust-cache@v2
with:
profile: minimal
toolchain: stable
override: true
key: "${{ runner.os }}-mysql-${{ matrix.runtime }}-${{ matrix.tls }}"
- uses: Swatinem/rust-cache@v1
with:
key: ${{ runner.os }}-mysql-${{ matrix.runtime }}-${{ matrix.tls }}
- uses: actions-rs/cargo@v1
with:
command: build
args: >
--features mysql,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
- run: cargo build --features mysql,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
- run: docker compose -f tests/docker-compose.yml run -d -p 3306:3306 --name mariadb_${{ matrix.mariadb }} mariadb_${{ matrix.mariadb }}
- run: sleep 30
@ -500,12 +390,10 @@ jobs:
# Create data dir for offline mode
- run: mkdir .sqlx
- uses: actions-rs/cargo@v1
with:
command: test
args: >
--no-default-features
--features any,mysql,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
- run: >
cargo test
--no-default-features
--features any,mysql,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
env:
DATABASE_URL: mysql://root:password@localhost:3306/sqlx
SQLX_OFFLINE_DIR: .sqlx
@ -515,26 +403,22 @@ jobs:
- run: cargo clean -p sqlx
# Build the macros-test in offline mode (omit DATABASE_URL)
- uses: actions-rs/cargo@v1
with:
command: build
args: >
--no-default-features
--test mysql-macros
--features any,mysql,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
- run: >
cargo build
--no-default-features
--test mysql-macros
--features any,mysql,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
env:
SQLX_OFFLINE: true
SQLX_OFFLINE_DIR: .sqlx
RUSTFLAGS: -D warnings --cfg mariadb_${{ matrix.mariadb }}
# Test macros in offline mode (still needs DATABASE_URL to run)
- uses: actions-rs/cargo@v1
with:
command: test
args: >
--no-default-features
--test mysql-macros
--features any,mysql,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
- run: >
cargo test
--no-default-features
--test mysql-macros
--features any,mysql,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
env:
DATABASE_URL: mysql://root:password@localhost:3306/sqlx
SQLX_OFFLINE: true
@ -548,13 +432,11 @@ jobs:
docker compose -f tests/docker-compose.yml run -d -p 3306:3306 --name mariadb_${{ matrix.mariadb }}_client_ssl mariadb_${{ matrix.mariadb }}_client_ssl
sleep 60
- uses: actions-rs/cargo@v1
if: matrix.tls != 'none'
with:
command: test
args: >
--no-default-features
--features any,mysql,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
- if: matrix.tls != 'none'
run: >
cargo test
--no-default-features
--features any,mysql,macros,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }}
env:
DATABASE_URL: mysql://root@localhost:3306/sqlx?sslmode=verify_ca&ssl-ca=.%2Ftests%2Fcerts%2Fca.crt&ssl-key=.%2Ftests%2Fkeys%2Fclient.key&ssl-cert=.%2Ftests%2Fcerts%2Fclient.crt
RUSTFLAGS: --cfg mariadb_${{ matrix.mariadb }}

6
rust-toolchain.toml Normal file
View File

@ -0,0 +1,6 @@
# NOTE: this does NOT indicate a Minimum Supported Rust Version (MSRV) of SQLx.
# We reserve the right to increase this version at any time without considering it to be a breaking change.
# See the answer in FAQ.md for details.
[toolchain]
channel = "1.78"
profile = "minimal"

View File

@ -11,6 +11,7 @@ pub trait MySqlBufExt: Buf {
fn get_uint_lenenc(&mut self) -> u64;
// Read a length-encoded string.
#[allow(dead_code)]
fn get_str_lenenc(&mut self) -> Result<String, Error>;
// Read a length-encoded byte sequence.

View File

@ -211,20 +211,13 @@ impl<C: DerefMut<Target = PgConnection>> PgCopyIn<C> {
/// If both `runtime-async-std` and `runtime-tokio` features are enabled, the Tokio version
/// takes precedent.
pub async fn read_from(&mut self, mut source: impl AsyncRead + Unpin) -> Result<&mut Self> {
// this is a separate guard from WriteAndFlush so we can reuse the buffer without zeroing
struct BufGuard<'s>(&'s mut Vec<u8>);
impl Drop for BufGuard<'_> {
fn drop(&mut self) {
self.0.clear()
}
}
let conn: &mut PgConnection = self.conn.as_deref_mut().expect("copy_from: conn taken");
loop {
let buf = conn.stream.write_buffer_mut();
// CopyData format code and reserved space for length
// Write the CopyData format code and reserve space for the length.
// This may end up sending an empty `CopyData` packet if, after this point,
// we get canceled or read 0 bytes, but that should be fine.
buf.put_slice(b"d\0\0\0\x04");
let read = match () {
@ -236,7 +229,6 @@ impl<C: DerefMut<Target = PgConnection>> PgCopyIn<C> {
};
if read == 0 {
// This will end up sending an empty `CopyData` packet but that should be fine.
break;
}

View File

@ -40,7 +40,7 @@ pub use advisory_lock::{PgAdvisoryLock, PgAdvisoryLockGuard, PgAdvisoryLockKey};
pub use arguments::{PgArgumentBuffer, PgArguments};
pub use column::PgColumn;
pub use connection::PgConnection;
pub use copy::PgCopyIn;
pub use copy::{PgCopyIn, PgPoolCopyExt};
pub use database::Postgres;
pub use error::{PgDatabaseError, PgErrorPosition};
pub use listener::{PgListener, PgNotification};