|
37 | 37 | - name: WASM Rust unit tests |
38 | 38 | run: cargo test -p polyglot-sql-wasm --lib -- --nocapture |
39 | 39 |
|
| 40 | + - name: FFI Rust tests |
| 41 | + run: cargo test -p polyglot-sql-ffi -- --nocapture |
| 42 | + |
| 43 | + - name: FFI release build |
| 44 | + run: cargo build -p polyglot-sql-ffi --profile ffi_release |
| 45 | + |
40 | 46 | - name: Generic identity tests |
41 | 47 | run: cargo test --test sqlglot_identity test_sqlglot_identity_all -p polyglot-sql -- --nocapture |
42 | 48 |
|
@@ -232,9 +238,136 @@ jobs: |
232 | 238 | env: |
233 | 239 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
234 | 240 |
|
| 241 | + ffi-build-artifacts: |
| 242 | + if: startsWith(github.ref, 'refs/tags/v') |
| 243 | + needs: rust-test |
| 244 | + name: Build FFI (${{ matrix.archive_name }}) |
| 245 | + runs-on: ${{ matrix.os }} |
| 246 | + strategy: |
| 247 | + fail-fast: false |
| 248 | + matrix: |
| 249 | + include: |
| 250 | + - os: ubuntu-latest |
| 251 | + target: x86_64-unknown-linux-gnu |
| 252 | + archive_name: linux-x86_64 |
| 253 | + archive_ext: tar.gz |
| 254 | + shared_lib: libpolyglot_sql_ffi.so |
| 255 | + static_lib: libpolyglot_sql_ffi.a |
| 256 | + use_cross: false |
| 257 | + - os: ubuntu-latest |
| 258 | + target: aarch64-unknown-linux-gnu |
| 259 | + archive_name: linux-aarch64 |
| 260 | + archive_ext: tar.gz |
| 261 | + shared_lib: libpolyglot_sql_ffi.so |
| 262 | + static_lib: libpolyglot_sql_ffi.a |
| 263 | + use_cross: true |
| 264 | + - os: macos-13 |
| 265 | + target: x86_64-apple-darwin |
| 266 | + archive_name: macos-x86_64 |
| 267 | + archive_ext: tar.gz |
| 268 | + shared_lib: libpolyglot_sql_ffi.dylib |
| 269 | + static_lib: libpolyglot_sql_ffi.a |
| 270 | + use_cross: false |
| 271 | + - os: macos-14 |
| 272 | + target: aarch64-apple-darwin |
| 273 | + archive_name: macos-aarch64 |
| 274 | + archive_ext: tar.gz |
| 275 | + shared_lib: libpolyglot_sql_ffi.dylib |
| 276 | + static_lib: libpolyglot_sql_ffi.a |
| 277 | + use_cross: false |
| 278 | + - os: windows-latest |
| 279 | + target: x86_64-pc-windows-msvc |
| 280 | + archive_name: windows-x86_64 |
| 281 | + archive_ext: zip |
| 282 | + shared_lib: polyglot_sql_ffi.dll |
| 283 | + static_lib: polyglot_sql_ffi.lib |
| 284 | + use_cross: false |
| 285 | + steps: |
| 286 | + - uses: actions/checkout@v4 |
| 287 | + |
| 288 | + - uses: dtolnay/rust-toolchain@stable |
| 289 | + with: |
| 290 | + targets: ${{ matrix.target }} |
| 291 | + |
| 292 | + - uses: Swatinem/rust-cache@v2 |
| 293 | + |
| 294 | + - name: Install cross (linux aarch64) |
| 295 | + if: matrix.use_cross |
| 296 | + run: cargo install cross --git https://github.com/cross-rs/cross |
| 297 | + |
| 298 | + - name: Build FFI artifacts with cross |
| 299 | + if: matrix.use_cross |
| 300 | + run: cross build -p polyglot-sql-ffi --profile ffi_release --target ${{ matrix.target }} |
| 301 | + |
| 302 | + - name: Build FFI artifacts with cargo |
| 303 | + if: ${{ !matrix.use_cross }} |
| 304 | + run: cargo build -p polyglot-sql-ffi --profile ffi_release --target ${{ matrix.target }} |
| 305 | + |
| 306 | + - name: Package archive (unix) |
| 307 | + if: runner.os != 'Windows' |
| 308 | + run: | |
| 309 | + dir="polyglot-sql-ffi-${{ matrix.archive_name }}" |
| 310 | + mkdir -p "$dir" |
| 311 | + cp crates/polyglot-sql-ffi/polyglot_sql.h "$dir/" |
| 312 | + cp "target/${{ matrix.target }}/ffi_release/${{ matrix.shared_lib }}" "$dir/" |
| 313 | + cp "target/${{ matrix.target }}/ffi_release/${{ matrix.static_lib }}" "$dir/" |
| 314 | + cp LICENSE "$dir/" |
| 315 | + tar -czf "${dir}.tar.gz" "$dir" |
| 316 | +
|
| 317 | + - name: Package archive (windows) |
| 318 | + if: runner.os == 'Windows' |
| 319 | + shell: pwsh |
| 320 | + run: | |
| 321 | + $dir = "polyglot-sql-ffi-${{ matrix.archive_name }}" |
| 322 | + New-Item -ItemType Directory -Path $dir -Force | Out-Null |
| 323 | + Copy-Item "crates/polyglot-sql-ffi/polyglot_sql.h" "$dir/" |
| 324 | + Copy-Item "target/${{ matrix.target }}/ffi_release/${{ matrix.shared_lib }}" "$dir/" |
| 325 | + Copy-Item "target/${{ matrix.target }}/ffi_release/${{ matrix.static_lib }}" "$dir/" |
| 326 | + Copy-Item "LICENSE" "$dir/" |
| 327 | + Compress-Archive -Path $dir -DestinationPath "$dir.zip" -Force |
| 328 | +
|
| 329 | + - name: Upload archive artifact |
| 330 | + uses: actions/upload-artifact@v4 |
| 331 | + with: |
| 332 | + name: ffi-${{ matrix.archive_name }} |
| 333 | + path: polyglot-sql-ffi-${{ matrix.archive_name }}.${{ matrix.archive_ext }} |
| 334 | + |
| 335 | + publish-ffi-assets: |
| 336 | + if: startsWith(github.ref, 'refs/tags/v') |
| 337 | + needs: [ffi-build-artifacts, publish-crate, publish-npm] |
| 338 | + runs-on: ubuntu-latest |
| 339 | + permissions: |
| 340 | + contents: write |
| 341 | + steps: |
| 342 | + - name: Download all FFI archives |
| 343 | + uses: actions/download-artifact@v4 |
| 344 | + with: |
| 345 | + pattern: ffi-* |
| 346 | + path: dist |
| 347 | + merge-multiple: true |
| 348 | + |
| 349 | + - name: Generate checksums |
| 350 | + run: | |
| 351 | + cd dist |
| 352 | + shopt -s nullglob |
| 353 | + files=(*.tar.gz *.zip) |
| 354 | + if [ ${#files[@]} -eq 0 ]; then |
| 355 | + echo "No FFI archives found" |
| 356 | + exit 1 |
| 357 | + fi |
| 358 | + sha256sum "${files[@]}" > checksums.sha256 |
| 359 | +
|
| 360 | + - name: Attach assets to GitHub release |
| 361 | + uses: softprops/action-gh-release@v2 |
| 362 | + with: |
| 363 | + files: | |
| 364 | + dist/*.tar.gz |
| 365 | + dist/*.zip |
| 366 | + dist/checksums.sha256 |
| 367 | +
|
235 | 368 | deploy-docs: |
236 | 369 | if: startsWith(github.ref, 'refs/tags/v') |
237 | | - needs: [publish-crate, publish-npm] |
| 370 | + needs: [publish-crate, publish-npm, publish-ffi-assets] |
238 | 371 | runs-on: ubuntu-latest |
239 | 372 | steps: |
240 | 373 | - uses: actions/checkout@v4 |
@@ -286,7 +419,7 @@ jobs: |
286 | 419 |
|
287 | 420 | deploy-playground: |
288 | 421 | if: startsWith(github.ref, 'refs/tags/v') |
289 | | - needs: [publish-crate, publish-npm] |
| 422 | + needs: [publish-crate, publish-npm, publish-ffi-assets] |
290 | 423 | runs-on: ubuntu-latest |
291 | 424 | steps: |
292 | 425 | - uses: actions/checkout@v4 |
|
0 commit comments