Skip to content

chore: extract the Sqlite ODBC driver from the stackable-odbc-rs workspace #2

chore: extract the Sqlite ODBC driver from the stackable-odbc-rs workspace

chore: extract the Sqlite ODBC driver from the stackable-odbc-rs workspace #2

Workflow file for this run

---
name: Build and Test
permissions:
contents: read
on:
push:
branches:
- main
pull_request:
merge_group:
# Supersede in-flight runs on the same ref. Never cancel in a merge queue: a
# cancelled merge_group run reports failure and evicts the PR from the queue.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
CARGO_TERM_COLOR: always
RUST_TOOLCHAIN_VERSION: "1.95.0"
jobs:
# The whole gate: `cargo test`, formatting, clippy (which is what enforces the
# unwrap_used / unwrap_in_result / panic denies from Cargo.toml), rustdoc,
# cargo-deny, cargo-sort and shellcheck.
#
# This lives here rather than in its own workflow because `needs:` cannot
# cross workflows, and a lint gate the required check does not observe is not
# a gate. It runs the hooks rather than the underlying commands so that CI and
# `pre-commit run --all-files` cannot drift apart -- CLAUDE.md points
# contributors at that command as the single source of truth for what must
# pass, which is only true if CI runs the same thing.
pre-commit:
name: pre-commit
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
# The cargo-test pre-commit hook links libodbc via odbc-sys.
- name: Install host dependencies
uses: awalsh128/cache-apt-pkgs-action@acb598e5ddbc6f68a970c5da0688d2f3a9f04d05 # v1.6.0
with:
packages: unixodbc-dev
version: ubuntu-latest
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false
- name: Install Rust ${{ env.RUST_TOOLCHAIN_VERSION }} toolchain
uses: dtolnay/rust-toolchain@b3b07ba8b418998c39fb20f53e8b695cdcc8de1b
with:
toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }}
components: rustfmt, clippy
- name: Setup Rust Cache
uses: Swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0 # v2.8.0
- name: Install cargo-deny and cargo-sort
uses: taiki-e/install-action@97a5807a604e12de3a13b52d868ebecaeeea757c # v2.75.4
with:
tool: cargo-deny,cargo-sort
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: "3.12"
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
# This suite needs only unixODBC and the sqlite3 CLI, no server and no
# container, so it runs on a standard runner in seconds and is worth
# gating every pull request on.
sqlite-integration:
name: SQLite Integration Tests
runs-on: ubuntu-latest
timeout-minutes: 20
needs: [pre-commit]
steps:
- name: Install host dependencies
uses: awalsh128/cache-apt-pkgs-action@acb598e5ddbc6f68a970c5da0688d2f3a9f04d05 # v1.6.0
with:
packages: unixodbc-dev unixodbc sqlite3
version: ubuntu-latest
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false
token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Rust ${{ env.RUST_TOOLCHAIN_VERSION }} toolchain
uses: dtolnay/rust-toolchain@b3b07ba8b418998c39fb20f53e8b695cdcc8de1b
with:
toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }}
- name: Setup Rust Cache
uses: Swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0 # v2.8.0
- name: Install uv
uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
- name: Run SQLite integration tests
run: |
./integration-tests/setup.sh
# --skip-cargo-test: the pre-commit job above already ran it.
./integration-tests/run-tests.sh --skip-cargo-test
windows-cross-compile:
name: Cross-compile Windows DLL
runs-on: ubuntu-latest
timeout-minutes: 20
needs: [pre-commit]
steps:
- name: Install MinGW cross-compiler
run: sudo apt-get update && sudo apt-get install -y gcc-mingw-w64-x86-64
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false
token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Rust ${{ env.RUST_TOOLCHAIN_VERSION }} toolchain
uses: dtolnay/rust-toolchain@b3b07ba8b418998c39fb20f53e8b695cdcc8de1b
with:
toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }}
targets: x86_64-pc-windows-gnu
- name: Setup Rust Cache
uses: Swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0 # v2.8.0
with:
key: windows-gnu
- name: Build Windows DLL
run: cargo build --target x86_64-pc-windows-gnu --release
- name: Verify DLL exports
run: |
x86_64-w64-mingw32-objdump -p target/x86_64-pc-windows-gnu/release/stackable_odbc_sqlite.dll | grep -c "SQL" | xargs -I{} echo "SQLite DLL: {} ODBC symbols exported"
# Single required check for branch protection rules.
finished:
name: Finished Build and Test
if: always()
needs:
- pre-commit
- sqlite-integration
- windows-cross-compile
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Check job results
run: |
if [[ "${{ needs.pre-commit.result }}" != "success" ]] ||
[[ "${{ needs.sqlite-integration.result }}" != "success" ]] ||
[[ "${{ needs.windows-cross-compile.result }}" != "success" ]]; then
echo "One or more jobs failed"
exit 1
fi
echo "All jobs passed"