Skip to content

Commit

Permalink
Fix CI after Rust 1.80, remove dead feature references (launchbadge#3381
Browse files Browse the repository at this point in the history
)

* fix(ci): update workflows/examples.yml

* Removed archived `actions-rs` actions
* Upgraded `Swatinem/rust-cache`, `actions/checkout`, `actions/download-artifact`, `actions/upload-artifact`

* chore: deprecate `AnyKind`

* fix: remove dead references to DB features in `sqlx-core`

This reactivates a couple of tests that had stopped working.

* chore(ci): move sqlx-cli checks to their own workflow

* fix(ci): remove remaining `uses: actions-rs/cargo`

* fix warnings

* chore: add titles to sqlx-cli jobs

* fix warnings (2)

* fix error in pool example

* fix warnings (3)

* fix query_builder test

* fix: don't run CLI tests on Windows

* chore: upgrade `rust-toolchain` to 1.80

* fix(postgres): fix missing Tokio specialization in `PgCopyIn`

Caught by the new `unexpected_cfgs` lint.

* fix new warnings
  • Loading branch information
abonander authored and jrasanen committed Oct 14, 2024
1 parent 2eb75f3 commit 943f4d8
Show file tree
Hide file tree
Showing 22 changed files with 334 additions and 352 deletions.
116 changes: 28 additions & 88 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,24 @@ jobs:
name: Build SQLx CLI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Use latest Rust
run: rustup override set stable

- uses: Swatinem/rust-cache@v1
- uses: Swatinem/rust-cache@v2
with:
key: sqlx-cli

- uses: actions-rs/cargo@v1
with:
command: build
args: >
- run: >
cargo build
-p sqlx-cli
--bin sqlx
--release
--no-default-features
--features mysql,postgres,sqlite
env:
RUSTFLAGS: -D warnings
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: sqlx-cli
path: target/release/sqlx
Expand All @@ -56,7 +49,7 @@ jobs:

steps:
- name: Get SQLx-CLI
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: sqlx-cli
# $HOME is interpreted differently by the shell
Expand All @@ -68,15 +61,9 @@ jobs:
echo /home/runner/.local/bin >> $GITHUB_PATH
sleep 10
- uses: actions/checkout@v2

- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions/checkout@v4

- uses: Swatinem/rust-cache@v1
- uses: Swatinem/rust-cache@v2
with:
key: mysql-examples

Expand All @@ -87,13 +74,9 @@ jobs:
run: sqlx db setup

- name: Todos (Run)
uses: actions-rs/cargo@v1
env:
DATABASE_URL: mysql://root:password@localhost:3306/todos?ssl-mode=disabled
with:
# TODO: test full CLI
command: run
args: -p sqlx-example-mysql-todos
run: cargo run -p sqlx-example-mysql-todos

postgres:
name: PostgreSQL Examples
Expand All @@ -110,7 +93,7 @@ jobs:

steps:
- name: Get SQLx-CLI
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: sqlx-cli
path: /home/runner/.local/bin
Expand All @@ -121,15 +104,9 @@ jobs:
echo $HOME/.local/bin >> $GITHUB_PATH
sleep 10
- uses: actions/checkout@v2

- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions/checkout@v4

- uses: Swatinem/rust-cache@v1
- uses: Swatinem/rust-cache@v2
with:
key: pg-examples

Expand All @@ -140,28 +117,19 @@ jobs:
run: sqlx db setup

- name: Axum Social with Tests (Check)
uses: actions-rs/cargo@v1
env:
DATABASE_URL: postgres://postgres:password@localhost:5432/axum-social
with:
command: check
args: -p sqlx-example-postgres-axum-social
run: cargo check -p sqlx-example-postgres-axum-social

- name: Axum Social with Tests (Test)
uses: actions-rs/cargo@v1
env:
DATABASE_URL: postgres://postgres:password@localhost:5432/axum-social
with:
command: test
args: -p sqlx-example-postgres-axum-social
run: cargo test -p sqlx-example-postgres-axum-social

# The Chat example has an interactive TUI which is not trivial to test automatically,
# so we only check that it compiles.
- name: Chat (Check)
uses: actions-rs/cargo@v1
with:
command: check
args: -p sqlx-example-postgres-chat
run: cargo check -p sqlx-example-postgres-chat

- name: Files (Setup)
working-directory: examples/postgres/files
Expand All @@ -170,12 +138,9 @@ jobs:
run: sqlx db setup

- name: Files (Run)
uses: actions-rs/cargo@v1
env:
DATABASE_URL: postgres://postgres:password@localhost:5432/files
with:
command: run
args: -p sqlx-example-postgres-files
run: cargo run -p sqlx-example-postgres-files

- name: JSON (Setup)
working-directory: examples/postgres/json
Expand All @@ -184,12 +149,9 @@ jobs:
run: sqlx db setup

- name: JSON (Run)
uses: actions-rs/cargo@v1
env:
DATABASE_URL: postgres://postgres:password@localhost:5432/json
with:
command: run
args: -p sqlx-example-postgres-json
run: cargo run -p sqlx-example-postgres-json

- name: Listen (Setup)
working-directory: examples/postgres/listen
Expand All @@ -198,12 +160,9 @@ jobs:
run: sqlx db create

- name: Listen (Run)
uses: actions-rs/cargo@v1
env:
DATABASE_URL: postgres://postgres:password@localhost:5432/listen
with:
command: run
args: -p sqlx-example-postgres-listen
run: cargo run -p sqlx-example-postgres-listen

- name: Mockable TODOs (Setup)
working-directory: examples/postgres/mockable-todos
Expand All @@ -212,13 +171,9 @@ jobs:
run: sqlx db setup

- name: Mockable TODOs (Run)
uses: actions-rs/cargo@v1
env:
DATABASE_URL: postgres://postgres:password@localhost:5432/mockable-todos
with:
# TODO: test full CLI
command: run
args: -p sqlx-example-postgres-mockable-todos
run: cargo run -p sqlx-example-postgres-mockable-todos

- name: TODOs (Setup)
working-directory: examples/postgres/todos
Expand All @@ -227,13 +182,10 @@ jobs:
run: sqlx db setup

- name: TODOs (Run)
uses: actions-rs/cargo@v1
env:
DATABASE_URL: postgres://postgres:password@localhost:5432/todos
with:
# TODO: test full CLI
command: run
args: -p sqlx-example-postgres-todos
# TODO: test full CLI
run: cargo run -p sqlx-example-postgres-todos

- name: Transaction (Setup)
working-directory: examples/postgres/transaction
Expand All @@ -242,12 +194,9 @@ jobs:
run: sqlx db setup

- name: Transaction (Run)
uses: actions-rs/cargo@v1
env:
DATABASE_URL: postgres://postgres:password@localhost:5432/txn
with:
command: run
args: -p sqlx-example-postgres-transaction
run: cargo run -p sqlx-example-postgres-transaction

sqlite:
name: SQLite Examples
Expand All @@ -256,7 +205,7 @@ jobs:

steps:
- name: Get SQLx-CLI
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: sqlx-cli
path: /home/runner/.local/bin
Expand All @@ -266,15 +215,9 @@ jobs:
chmod +x /home/runner/.local/bin/sqlx
echo /home/runner/.local/bin >> $GITHUB_PATH
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- uses: Swatinem/rust-cache@v1
- uses: Swatinem/rust-cache@v2
with:
key: sqlite-examples

Expand All @@ -284,9 +227,6 @@ jobs:
run: sqlx db setup --source=examples/sqlite/todos/migrations

- name: TODOs (Run)
uses: actions-rs/cargo@v1
env:
DATABASE_URL: sqlite://todos.sqlite
with:
command: run
args: -p sqlx-example-sqlite-todos
run: cargo run -p sqlx-example-sqlite-todos
100 changes: 100 additions & 0 deletions .github/workflows/sqlx-cli.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: SQLx CLI

on:
pull_request:
push:
branches:
- main
- "*-dev"

jobs:
check:
name: Check
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- run: |
rustup update
rustup component add clippy
rustup toolchain install beta
rustup component add --toolchain beta clippy
- uses: Swatinem/rust-cache@v2

- run: cargo clippy --manifest-path sqlx-cli/Cargo.toml -- -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
--manifest-path sqlx-cli/Cargo.toml
--target-dir target/beta/
test:
name: Test
runs-on: ${{ matrix.os }}

strategy:
matrix:
# Note: macOS-latest uses M1 Silicon (ARM64)
os:
- ubuntu-latest
# FIXME: migrations tests fail on Windows for whatever reason
# - windows-latest
- macOS-13
- macOS-latest

steps:
- uses: actions/checkout@v4

- uses: Swatinem/rust-cache@v2
with:
key: ${{ runner.os }}-test

- run: cargo test --manifest-path sqlx-cli/Cargo.toml

build:
name: Build
runs-on: ${{ matrix.os }}

strategy:
matrix:
# Note: macOS-latest uses M1 Silicon (ARM64)
os:
- ubuntu-latest
- windows-latest
- macOS-13
- macOS-latest
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
args: --features openssl-vendored
bin: target/debug/cargo-sqlx
- os: windows-latest
target: x86_64-pc-windows-msvc
bin: target/debug/cargo-sqlx.exe
- os: macOS-13
target: x86_64-apple-darwin
bin: target/debug/cargo-sqlx
- os: macOS-latest
target: aarch64-apple-darwin
bin: target/debug/cargo-sqlx

steps:
- uses: actions/checkout@v4

- name: Use latest Rust
run: rustup override set stable

- uses: Swatinem/rust-cache@v2
with:
key: ${{ runner.os }}-cli

- run: cargo build --manifest-path sqlx-cli/Cargo.toml --bin cargo-sqlx ${{ matrix.args }}

- uses: actions/upload-artifact@v4
with:
name: cargo-sqlx-${{ matrix.target }}
path: ${{ matrix.bin }}
Loading

0 comments on commit 943f4d8

Please sign in to comment.