@@ -13,17 +13,22 @@ jobs:
1313 platform :
1414 - " x64-mingw32"
1515 - " x64-mingw-ucrt"
16- name : cross-compile-windows
16+ - " x86_64-linux-gnu"
17+ - " x86_64-linux-musl"
18+ - " aarch64-linux-gnu"
19+ - " aarch64-linux-musl"
20+
21+ name : cross-compile
1722 runs-on : ubuntu-22.04
18- container :
19- image : " ghcr.io/rake-compiler/rake-compiler-dock-image:1.7.0-mri-${{ matrix.platform }}"
2023 steps :
2124 - uses : actions/checkout@v4
2225
23- - run : git config --global --add safe.directory /__w/tiny_tds/tiny_tds # shrug
26+ - name : Set up Ruby
27+ uses : ruby/setup-ruby@v1
28+ with :
29+ ruby-version : " 2.7"
2430
25- - name : Install gems
26- shell : bash
31+ - name : " Install dependencies"
2732 run : bundle install
2833
2934 - name : Write used versions into file
@@ -34,14 +39,14 @@ jobs:
3439 uses : actions/cache@v4
3540 with :
3641 path : ports
37- key : cross-compiled-v3 -${{ matrix.platform }}-${{ hashFiles('**/.ports_versions') }}
42+ key : cross-compiled-v1 -${{ matrix.platform }}-${{ hashFiles('**/.ports_versions') }}
3843 restore-keys : |
39- cross-compiled-v3 -${{ matrix.platform }}-${{ hashFiles('**/.ports_versions') }}
40- cross-compiled-v3 -${{ matrix.platform }}-
44+ cross-compiled-v1 -${{ matrix.platform }}-${{ hashFiles('**/.ports_versions') }}
45+ cross-compiled-v1 -${{ matrix.platform }}-
4146
4247 - name : Build gem
4348 shell : bash
44- run : bundle exec rake gem:for_platform[ ${{ matrix.platform }}]
49+ run : bundle exec rake gem:native: ${{ matrix.platform }}
4550
4651 - uses : actions/upload-artifact@v4
4752 with :
8994 ruby -e "require 'tiny_tds'; puts TinyTds::Gem.root_path"
9095 exit $LASTEXITCODE
9196
97+ - name : Test if tsql wrapper works
98+ shell : pwsh
99+ run : |
100+ tsql-ttds -C
101+ exit $LASTEXITCODE
102+
103+ - name : Test if defncopy wrapper works
104+ shell : pwsh
105+ run : |
106+ defncopy-ttds -v
107+ exit $LASTEXITCODE
108+
92109 test-windows-mingw :
93110 needs :
94111 - cross-compile
@@ -123,21 +140,9 @@ jobs:
123140
124141 - name : Install native gem and restore cross-compiled code from it
125142 shell : pwsh
126- run : |
127- $rubyArchitecture = (ruby -e "puts RbConfig::CONFIG['arch']").Trim()
128- $gemVersion = (Get-Content VERSION).Trim()
129- $gemToUnpack = "./tiny_tds-$gemVersion-$rubyArchitecture.gem"
130-
131- Write-Host "Looking to unpack $gemToUnpack"
132- gem unpack --target ./tmp "$gemToUnpack"
133-
134- # Restore precompiled code
135- $source = (Resolve-Path ".\tmp\tiny_tds-$gemVersion-$rubyArchitecture\lib\tiny_tds").Path
136- $destination = (Resolve-Path ".\lib\tiny_tds").Path
137- Get-ChildItem $source -Recurse -Exclude "*.rb" | Copy-Item -Destination {Join-Path $destination $_.FullName.Substring($source.length)}
138-
139- # Restore ports
140- Copy-Item -Path ".\tmp\tiny_tds-$gemVersion-$rubyArchitecture\ports" -Destination "." -Recurse
143+ run : " & ./test/bin/restore-from-native-gem.ps1"
144+ env :
145+ RUBY_ARCHITECTURE : " x64-mingw32"
141146
142147 - name : Setup MSSQL
143148 uses : rails-sqlserver/setup-mssql@v1
@@ -214,6 +219,18 @@ jobs:
214219 ruby -e "require 'tiny_tds'; puts TinyTds::Gem.root_path"
215220 exit $LASTEXITCODE
216221
222+ - name : Test if tsql wrapper works
223+ shell : pwsh
224+ run : |
225+ tsql-ttds -C
226+ exit $LASTEXITCODE
227+
228+ - name : Test if defncopy wrapper works
229+ shell : pwsh
230+ run : |
231+ defncopy-ttds -v
232+ exit $LASTEXITCODE
233+
217234 test-windows-ucrt :
218235 needs :
219236 - cross-compile
@@ -250,21 +267,9 @@ jobs:
250267
251268 - name : Install native gem and restore cross-compiled code from it
252269 shell : pwsh
253- run : |
254- $rubyArchitecture = (ruby -e "puts RbConfig::CONFIG['arch']").Trim()
255- $gemVersion = (Get-Content VERSION).Trim()
256- $gemToUnpack = "./tiny_tds-$gemVersion-$rubyArchitecture.gem"
257-
258- Write-Host "Looking to unpack $gemToUnpack"
259- gem unpack --target ./tmp "$gemToUnpack"
260-
261- # Restore precompiled code
262- $source = (Resolve-Path ".\tmp\tiny_tds-$gemVersion-$rubyArchitecture\lib\tiny_tds").Path
263- $destination = (Resolve-Path ".\lib\tiny_tds").Path
264- Get-ChildItem $source -Recurse -Exclude "*.rb" | Copy-Item -Destination {Join-Path $destination $_.FullName.Substring($source.length)}
265-
266- # Restore ports
267- Copy-Item -Path ".\tmp\tiny_tds-$gemVersion-$rubyArchitecture\ports" -Destination "." -Recurse
270+ run : " & ./test/bin/restore-from-native-gem.ps1"
271+ env :
272+ RUBY_ARCHITECTURE : " x64-mingw-ucrt"
268273
269274 - name : Setup MSSQL
270275 uses : rails-sqlserver/setup-mssql@v1
@@ -336,44 +341,94 @@ jobs:
336341 ruby -e "require 'tiny_tds'; puts TinyTds::Gem.root_path"
337342 exit $LASTEXITCODE
338343
339- compile-native-ports :
344+ - name : Test if tsql wrapper works
345+ shell : pwsh
346+ run : |
347+ tsql-ttds -C
348+ exit $LASTEXITCODE
349+
350+ - name : Test if defncopy wrapper works
351+ shell : pwsh
352+ run : |
353+ defncopy-ttds -v
354+ exit $LASTEXITCODE
355+
356+ install-linux :
357+ needs :
358+ - cross-compile
359+ strategy :
360+ fail-fast : false
361+ matrix :
362+ platform :
363+ - " x86_64-linux-gnu"
364+ - " x86_64-linux-musl"
365+ - " aarch64-linux-gnu"
366+ - " aarch64-linux-musl"
367+
368+ ruby-version :
369+ - " 2.7"
370+ - " 3.0"
371+ - " 3.1"
372+ - " 3.2"
373+ - " 3.3"
374+ - " 3.4"
375+
376+ include :
377+ - platform : x86_64-linux-musl
378+ docker_tag : " -alpine"
379+ bootstrap : " apk add -U build-base &&" # required to compile bigdecimal on Ruby 2.7
380+
381+ - platform : aarch64-linux-gnu
382+ docker_platform : " --platform=linux/arm64"
383+
384+ - platform : aarch64-linux-musl
385+ docker_platform : " --platform=linux/arm64"
386+ docker_tag : " -alpine"
387+ bootstrap : " apk add -U build-base &&"
388+
389+ name : install-linux
340390 runs-on : ubuntu-22.04
341- name : cross-compile-linux
342391 steps :
343392 - uses : actions/checkout@v4
344393
345- - uses : ruby/setup-ruby@v1
346- with :
347- ruby-version : 3.4
348- bundler-cache : true
349-
350- - name : Write used versions into file
351- run : bundle exec rake ports:version_file
352-
353- - name : Cache ports
354- uses : actions/cache@v4
394+ - name : Download precompiled gem
395+ uses : actions/download-artifact@v4
355396 with :
356- path : ports
357- key : native-v3-${{ hashFiles('**/.ports_versions') }}
358- restore-keys : |
359- native-v3-${{ hashFiles('* */.ports_versions') }}
360- native-v3-
361-
362- - name : Build required libraries
363- run : |
364- bundle exec rake ports
397+ name : gem-${{ matrix.platform }}
398+ path : precompiled/gems
399+
400+ - name : Setup QEMU for docker
401+ uses : docker/setup-qemu-action@v3
402+ if : ${{ matrix.docker_platform }} != ''
403+
404+ - run : |
405+ docker run --rm -v $PWD/precompiled:/precompiled -w /precompiled \
406+ ${{ matrix.docker_platform }} ruby:${{ matrix.ruby-version }}${{ matrix.docker_tag }} \
407+ sh -c "
408+ gem update --system 3.3.22 &&
409+ ${{ matrix.bootstrap }}
410+ gem install --no-document ./gems/tiny_tds-$(cat VERSION)-${{ matrix.platform }}.gem &&
411+ ruby -e \"require 'tiny_tds'; puts TinyTds::Gem.root_path\" &&
412+ tsql-ttds -C &&
413+ defncopy-ttds -v
414+ "
365415
366416 test-linux :
367417 needs :
368- - compile-native-ports
418+ - cross-compile
369419 name : test-linux
370420 strategy :
371421 fail-fast : false
372422 matrix :
423+ force-encryption :
424+ - false
425+ - true
426+
373427 mssql-version :
374428 - 2017
375429 - 2019
376430 - 2022
431+
377432 ruby-version :
378433 - " 2.7"
379434 - " 3.0"
@@ -391,27 +446,24 @@ jobs:
391446 ruby-version : ${{ matrix.ruby-version }}
392447 bundler-cache : true
393448
394- - name : Write used versions into file
395- run : |
396- bundle exec rake ports:version_file
397-
398- - name : Cache ports
399- uses : actions/cache@v4
449+ - name : Download precompiled gem
450+ uses : actions/download-artifact@v4
400451 with :
401- path : ports
402- key : native-v3-${{ hashFiles('**/.ports_versions') }}
403- fail-on-cache-miss : true
452+ name : gem-x86_64-linux-gnu
404453
405- - name : Build gem
406- run : |
407- bundle exec rake build
454+ - name : Install native gem and restore cross-compiled code from it
455+ shell : pwsh
456+ run : " & ./test/bin/restore-from-native-gem.ps1"
457+ env :
458+ RUBY_ARCHITECTURE : " x86_64-linux-gnu"
408459
409460 - name : Setup MSSQL
410461 uses : rails-sqlserver/setup-mssql@v1
411462 with :
412463 components : sqlcmd,sqlengine
413464 version : ${{ matrix.mssql-version }}
414465 sa-password : " c0MplicatedP@ssword"
466+ force-encryption : ${{ matrix.force-encryption }}
415467
416468 - name : Setup MSSQL database
417469 run : |
@@ -435,6 +487,52 @@ jobs:
435487 paths : " test/reports/TEST-*.xml"
436488 if : always()
437489
490+ install-linux-native :
491+ strategy :
492+ fail-fast : false
493+ matrix :
494+ ruby-version :
495+ - " 2.7"
496+ - " 3.0"
497+ - " 3.1"
498+ - " 3.2"
499+ - " 3.3"
500+ - " 3.4"
501+
502+ name : install-linux-native
503+ runs-on : ubuntu-22.04
504+ steps :
505+ - uses : actions/checkout@v4
506+
507+ - uses : ruby/setup-ruby@v1
508+ with :
509+ ruby-version : ${{ matrix.ruby-version }}
510+ bundler-cache : true
511+
512+ - name : Install FreeTDS
513+ shell : bash
514+ run : ./test/bin/install-freetds.sh
515+
516+ - name : Build gem
517+ shell : bash
518+ run : gem build tiny_tds.gemspec
519+
520+ - name : Install gem
521+ shell : bash
522+ run : gem install "tiny_tds-$(cat VERSION).gem"
523+
524+ - name : Test if TinyTDS loads
525+ shell : bash
526+ run : ruby -e "require 'tiny_tds'; puts TinyTds::Gem.root_path"
527+
528+ - name : Test if tsql wrapper works
529+ shell : bash
530+ run : tsql-ttds -C
531+
532+ - name : Test if defncopy wrapper works
533+ shell : bash
534+ run : defncopy-ttds -v
535+
438536 install_macos :
439537 strategy :
440538 fail-fast : false
0 commit comments