Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
rustup component add rustfmt clippy

- name: Cache Rust dependencies
uses: actions/cache@v4
uses: actions/cache@v5
with:
path: |
~/.cargo/registry
Expand Down Expand Up @@ -61,7 +61,7 @@ jobs:
pip install pre-commit hatch "virtualenv<21.0.0"

- name: Cache pre-commit hooks
uses: actions/cache@v4
uses: actions/cache@v5
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }}
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/test-jdbc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,26 @@ jobs:
java-version: ${{ matrix.java-version }}
distribution: 'temurin'

- name: Cache Cargo registry
uses: actions/cache@v5
with:

path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-registry-

- name: Cache Rust target
uses: actions/cache@v5
with:

path: target
key: ${{ runner.os }}-rust-jdbc-target-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-rust-jdbc-target-

- name: Decode secrets
run: ./scripts/decode_secrets.sh
env:
Expand Down
58 changes: 58 additions & 0 deletions .github/workflows/test-odbc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,26 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Cache Cargo registry
uses: actions/cache@v5
with:

path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-registry-

- name: Cache Rust target
uses: actions/cache@v5
with:

path: target
key: ${{ runner.os }}-rust-odbc-unit-target-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-rust-odbc-unit-target-

- name: Install dependencies
run: |
set -euxo pipefail
Expand Down Expand Up @@ -111,6 +131,15 @@ jobs:
PARAMETERS_SECRET: ${{ secrets.PARAMETERS_SECRET }}
shell: bash

- name: Cache C++ ODBC test build (reference)
uses: actions/cache@v5
with:

path: odbc_tests/cmake-build
key: ${{ runner.os }}-cpp-odbc-tests-old-${{ hashFiles('odbc_tests/**/*.cpp', 'odbc_tests/**/*.hpp', 'odbc_tests/**/*.h', 'odbc_tests/**/CMakeLists.txt') }}
restore-keys: |
${{ runner.os }}-cpp-odbc-tests-old-
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we restore from any key? CMake is not very cacheable


- name: Run Old ODBC tests (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
Expand Down Expand Up @@ -157,6 +186,26 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Cache Cargo registry
uses: actions/cache@v5
with:

path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-registry-

- name: Cache Rust target
uses: actions/cache@v5
with:

path: target
key: ${{ runner.os }}-rust-odbc-target-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-rust-odbc-target-

- name: Install dependencies (Linux)
if: runner.os == 'Linux'
run: |
Expand Down Expand Up @@ -226,6 +275,15 @@ jobs:
env:
RUSTFLAGS: "-C linker=rust-lld"

- name: Cache C++ ODBC test build
uses: actions/cache@v5
with:

path: odbc_tests/cmake-build
key: ${{ runner.os }}-cpp-odbc-tests-${{ hashFiles('odbc_tests/**/*.cpp', 'odbc_tests/**/*.hpp', 'odbc_tests/**/*.h', 'odbc_tests/**/CMakeLists.txt') }}
restore-keys: |
${{ runner.os }}-cpp-odbc-tests-

- name: Build and run ODBC tests (Unix)
if: runner.os != 'Windows'
run: |
Expand Down
131 changes: 124 additions & 7 deletions .github/workflows/test-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,91 @@ jobs:
- name: Dummy step
run: echo 'Dummy step to pass required check'

# Build Python wheel with compiled extensions for each OS/Python version
# Build sf_core once per platform and share via artifact.
# The Rust library is identical regardless of Python version, so building it
# once avoids redundant ~12 min (Linux) / ~17 min (Windows) Rust compiles
# across the build_wheel matrix.
build_sf_core:
needs: detect-changes
if: github.event_name == 'push' || needs.detect-changes.outputs.run_python == 'true'
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
lib_name: libsf_core.so
- os: windows-11-arm
lib_name: sf_core.dll
runs-on: ${{ matrix.os }}
name: build_sf_core (${{ matrix.os }})
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Cache Cargo registry
uses: actions/cache@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does the Cargo.lock version sf_core?

restore-keys: |
${{ runner.os }}-cargo-registry-

- name: Cache Rust target
uses: actions/cache@v5
with:
path: target
key: ${{ runner.os }}-rust-sf-core-release-target-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-rust-sf-core-release-target-

- name: Cache vcpkg packages
if: matrix.os == 'windows-11-arm'
uses: actions/cache@v5
with:
path: C:\vcpkg\installed
key: vcpkg-arm64-windows-static-md-openssl

- name: Install ARM64 OpenSSL (static) via vcpkg
if: matrix.os == 'windows-11-arm'
shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" arm64
vcpkg install openssl:arm64-windows-static-md

- name: Configure ARM64 OpenSSL (static)
if: matrix.os == 'windows-11-arm'
shell: pwsh
run: |
echo "OPENSSL_DIR=C:\vcpkg\installed\arm64-windows-static-md" >> $env:GITHUB_ENV
echo "OPENSSL_LIB_DIR=C:\vcpkg\installed\arm64-windows-static-md\lib" >> $env:GITHUB_ENV
echo "OPENSSL_STATIC=1" >> $env:GITHUB_ENV

- name: Build sf_core (Linux)
if: runner.os == 'Linux'
run: cargo build --release --package sf_core

- name: Build sf_core (Windows ARM64)
if: matrix.os == 'windows-11-arm'
shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" arm64
cargo build --release --package sf_core --config profile.release.strip=false

- name: Upload sf_core library
uses: actions/upload-artifact@v4
with:
name: sf-core-${{ matrix.os }}
path: target/release/${{ matrix.lib_name }}

# Build Python wheel with compiled extensions for each OS/Python version.
# sf_core is pre-built by build_sf_core and downloaded as an artifact.
# NOTE: All Windows runners in this matrix are ARM64 (windows-11-arm).
# Steps conditioned on runner.os=='Windows' assume ARM64 semantics.
# If a non-ARM64 Windows runner is added, review all runner.os=='Windows' steps.
build_wheel:
needs: detect-changes
needs: [detect-changes, build_sf_core]
if: github.event_name == 'push' || needs.detect-changes.outputs.run_python == 'true'
strategy: &matrix
fail-fast: false
Expand All @@ -60,10 +139,17 @@ jobs:
env:
# Configure CMake for ARM64 on Windows ARM64 runners
CMAKE_GENERATOR_PLATFORM: ${{ matrix.os == 'windows-11-arm' && 'ARM64' || '' }}
SKIP_CORE_BUILD: "true"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that, we need to add wheel building test to pakaging tests. Previously it was always tested when building the lib.

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Download pre-built sf_core
uses: actions/download-artifact@v4
with:
name: sf-core-${{ matrix.os }}
path: python/src/snowflake/connector/_core

- name: Install system dependencies (Linux)
if: runner.os == 'Linux'
run: sudo apt-get update
Expand All @@ -80,10 +166,29 @@ jobs:
# explicitly as uv suggests: cpython-X.Y-windows-aarch64-none
run: uv python install ${{ matrix.os == 'windows-11-arm' && format('cpython-{0}-windows-aarch64-none', matrix.py) || matrix.py }}

- name: Cache proto generator target
uses: actions/cache@v5
with:
path: proto-target
key: ${{ runner.os }}-proto-target-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-proto-target-

- name: Build python wheel (Linux)
if: runner.os == 'Linux'
working-directory: ./python
run: uv run --python ${{ matrix.py }} --with hatch --with cython --with setuptools --with "virtualenv<21.0.0" hatch build
env:
PROTO_CARGO_TARGET_DIR: ${{ github.workspace }}/proto-target

# cryptography has no pre-built ARM64 Windows wheel, so uv builds it from
# source via maturin. OpenSSL is needed for this dependency build.
- name: Cache vcpkg packages
if: matrix.os == 'windows-11-arm'
uses: actions/cache@v5
with:
path: C:\vcpkg\installed
key: vcpkg-arm64-windows-static-md-openssl

- name: Install ARM64 OpenSSL (static) via vcpkg
if: matrix.os == 'windows-11-arm'
Expand All @@ -107,6 +212,8 @@ jobs:
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" arm64
uv run --python ${{ matrix.py }} --with hatch --with cython --with setuptools --with "virtualenv<21.0.0" hatch build
env:
PROTO_CARGO_TARGET_DIR: ${{ github.workspace }}\proto-target

- name: Inspect wheel (Linux)
if: runner.os == 'Linux'
Expand Down Expand Up @@ -175,7 +282,7 @@ jobs:

- name: Restore uv cache (Linux)
if: runner.os == 'Linux'
uses: actions/cache@v4
uses: actions/cache@v5
with:
path: /tmp/.uv-cache
key: uv-${{ matrix.os }}-${{ matrix.py }}-${{ hashFiles('python/uv.lock', 'python/pyproject.toml') }}
Expand All @@ -185,7 +292,7 @@ jobs:

- name: Restore uv cache (Windows)
if: runner.os == 'Windows'
uses: actions/cache@v4
uses: actions/cache@v5
with:
path: ${{ runner.temp }}\.uv-cache
key: uv-${{ matrix.os }}-${{ matrix.py }}-${{ hashFiles('python/uv.lock', 'python/pyproject.toml') }}
Expand Down Expand Up @@ -213,6 +320,13 @@ jobs:
# source via maturin. Use static OpenSSL (arm64-windows-static-md) so the
# built _rust.pyd embeds OpenSSL rather than depending on DLLs at runtime —
# the same reason we use static OpenSSL for sf_core in the build_wheel job.
- name: Cache vcpkg packages
if: matrix.os == 'windows-11-arm'
uses: actions/cache@v5
with:
path: C:\vcpkg\installed
key: vcpkg-arm64-windows-static-md-openssl

- name: Install ARM64 OpenSSL (static) via vcpkg (for dependency source builds)
if: matrix.os == 'windows-11-arm'
shell: cmd
Expand Down Expand Up @@ -299,7 +413,7 @@ jobs:
version: "0.9.28"

- name: Restore uv cache
uses: actions/cache@v4
uses: actions/cache@v5
with:
path: /tmp/.uv-cache
# Key uses REFERENCE_OS_VERSION (= "ubuntu-latest") to match the matrix.os-based
Expand Down Expand Up @@ -388,7 +502,7 @@ jobs:
--fail-on-regressions 0 | tee -a $GITHUB_STEP_SUMMARY

python-status:
needs: [detect-changes, build_wheel, packaging_tests, python_tests, python_tests_reference, python_compare_results]
needs: [detect-changes, build_sf_core, build_wheel, packaging_tests, python_tests, python_tests_reference, python_compare_results]
if: always()
runs-on: ubuntu-latest
steps:
Expand All @@ -405,11 +519,13 @@ jobs:

# Check if critical jobs failed or were cancelled
# Note: python_tests_reference has continue-on-error:true, so we don't fail on it
if [[ "${{ needs.build_wheel.result }}" =~ ^(failure|cancelled)$ ]] || \
if [[ "${{ needs.build_sf_core.result }}" =~ ^(failure|cancelled)$ ]] || \
[[ "${{ needs.build_wheel.result }}" =~ ^(failure|cancelled)$ ]] || \
[[ "${{ needs.packaging_tests.result }}" =~ ^(failure|cancelled)$ ]] || \
[[ "${{ needs.python_tests.result }}" =~ ^(failure|cancelled)$ ]] || \
[[ "${{ needs.python_compare_results.result }}" =~ ^(failure|cancelled)$ ]]; then
echo "✗ Python CI FAILED or CANCELLED"
echo " - build_sf_core: ${{ needs.build_sf_core.result }}"
echo " - build_wheel: ${{ needs.build_wheel.result }}"
echo " - packaging_tests: ${{ needs.packaging_tests.result }}"
echo " - python_tests: ${{ needs.python_tests.result }}"
Expand All @@ -420,6 +536,7 @@ jobs:

# Tests ran and passed
echo "✓ Python CI PASSED"
echo " - build_sf_core: ${{ needs.build_sf_core.result }}"
echo " - build_wheel: ${{ needs.build_wheel.result }}"
echo " - packaging_tests: ${{ needs.packaging_tests.result }}"
echo " - python_tests: ${{ needs.python_tests.result }}"
Expand Down
Loading
Loading