Skip to content

Commit

Permalink
Treat warnings as errors on CI builds
Browse files Browse the repository at this point in the history
  • Loading branch information
nyurik committed Jul 25, 2023
1 parent 7e7dded commit 794b0de
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/examples.yml
Expand Up @@ -33,6 +33,8 @@ jobs:
--release
--no-default-features
--features mysql,postgres,sqlite
env:
RUSTFLAGS: -D warnings

- uses: actions/upload-artifact@v3
with:
Expand Down
14 changes: 9 additions & 5 deletions .github/workflows/sqlx.yml
Expand Up @@ -55,13 +55,17 @@ jobs:
--manifest-path sqlx-core/Cargo.toml
--no-default-features
--features json,offline,migrate,_rt-${{ matrix.runtime }},_tls-${{ matrix.tls }}
env:
RUSTFLAGS: -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

test:
name: Unit Test
Expand Down Expand Up @@ -189,7 +193,7 @@ jobs:
env:
SQLX_OFFLINE: true
SQLX_OFFLINE_DIR: .sqlx
RUSTFLAGS: --cfg sqlite_ipaddr
RUSTFLAGS: -D warnings --cfg sqlite_ipaddr
LD_LIBRARY_PATH: /tmp/sqlite3-lib

# Test macros in offline mode (still needs DATABASE_URL to run)
Expand Down Expand Up @@ -233,7 +237,7 @@ jobs:
env:
# FIXME: needed to disable `ltree` tests in Postgres 9.6
# but `PgLTree` should just fall back to text format
RUSTFLAGS: --cfg postgres_${{ matrix.postgres }}
RUSTFLAGS: -D warnings --cfg postgres_${{ matrix.postgres }}
with:
command: build
args: >
Expand Down Expand Up @@ -289,7 +293,7 @@ jobs:
SQLX_OFFLINE_DIR: .sqlx
# FIXME: needed to disable `ltree` tests in Postgres 9.6
# but `PgLTree` should just fall back to text format
RUSTFLAGS: --cfg postgres_${{ matrix.postgres }}
RUSTFLAGS: -D warnings --cfg postgres_${{ matrix.postgres }}

# Test macros in offline mode (still needs DATABASE_URL to run)
- uses: actions-rs/cargo@v1
Expand Down Expand Up @@ -399,7 +403,7 @@ jobs:
env:
SQLX_OFFLINE: true
SQLX_OFFLINE_DIR: .sqlx
RUSTFLAGS: --cfg mysql_${{ matrix.mysql }}
RUSTFLAGS: -D warnings --cfg mysql_${{ matrix.mysql }}

# Test macros in offline mode (still needs DATABASE_URL to run)
# MySQL 5.7 supports TLS but not TLSv1.3 as required by RusTLS.
Expand Down Expand Up @@ -495,7 +499,7 @@ jobs:
env:
SQLX_OFFLINE: true
SQLX_OFFLINE_DIR: .sqlx
RUSTFLAGS: --cfg mariadb_${{ matrix.mariadb }}
RUSTFLAGS: -D warnings --cfg mariadb_${{ matrix.mariadb }}

# Test macros in offline mode (still needs DATABASE_URL to run)
- uses: actions-rs/cargo@v1
Expand Down
2 changes: 2 additions & 0 deletions sqlx-macros-core/src/database/mod.rs
Expand Up @@ -39,10 +39,12 @@ pub trait DatabaseExt: Database {
fn describe_blocking(query: &str, database_url: &str) -> sqlx_core::Result<Describe<Self>>;
}

#[allow(dead_code)]
pub struct CachingDescribeBlocking<DB: DatabaseExt> {
connections: Lazy<Mutex<HashMap<String, DB::Connection>>>,
}

#[allow(dead_code)]
impl<DB: DatabaseExt> CachingDescribeBlocking<DB> {
pub const fn new() -> Self {
CachingDescribeBlocking {
Expand Down
12 changes: 7 additions & 5 deletions sqlx-macros-core/src/test_attr.rs
@@ -1,15 +1,16 @@
use proc_macro2::{Span, TokenStream};
use proc_macro2::TokenStream;
use quote::quote;
use syn::LitStr;

#[cfg(feature = "migrate")]
struct Args {
fixtures: Vec<LitStr>,
fixtures: Vec<syn::LitStr>,
migrations: MigrationsOpt,
}

#[cfg(feature = "migrate")]
enum MigrationsOpt {
InferredPath,
ExplicitPath(LitStr),
ExplicitPath(syn::LitStr),
ExplicitMigrator(syn::Path),
Disabled,
}
Expand Down Expand Up @@ -89,7 +90,8 @@ fn expand_advanced(args: syn::AttributeArgs, input: syn::ItemFn) -> crate::Resul
quote! { args.migrator(&#migrator); }
}
MigrationsOpt::InferredPath if !inputs.is_empty() => {
let migrations_path = crate::common::resolve_path("./migrations", Span::call_site())?;
let migrations_path =
crate::common::resolve_path("./migrations", proc_macro2::Span::call_site())?;

if migrations_path.is_dir() {
let migrator = crate::migrate::expand_migrator(&migrations_path)?;
Expand Down
2 changes: 1 addition & 1 deletion sqlx-sqlite/src/connection/mod.rs
Expand Up @@ -258,7 +258,7 @@ impl LockedSqliteHandle<'_> {
/// The progress handler callback must not do anything that will modify the database connection that invoked
/// the progress handler. Note that sqlite3_prepare_v2() and sqlite3_step() both modify their database connections
/// in this context.
pub fn set_progress_handler<F>(&mut self, num_ops: i32, mut callback: F)
pub fn set_progress_handler<F>(&mut self, num_ops: i32, callback: F)
where
F: FnMut() -> bool + Send + 'static,
{
Expand Down

0 comments on commit 794b0de

Please sign in to comment.