From b00d7731bb62a63d96d1188af684ee62256ecfb4 Mon Sep 17 00:00:00 2001 From: Andy Pfister Date: Sun, 14 Apr 2024 22:42:08 +0200 Subject: [PATCH 01/13] Remove CircleCI configuration --- .circleci/config.yml | 417 ------------------------------------------- README.md | 1 - 2 files changed, 418 deletions(-) delete mode 100755 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100755 index d7d20226..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,417 +0,0 @@ -version: 2.1 - -orbs: - win: circleci/windows@4.1 - ruby: circleci/ruby@2.0.0 - -commands: - install-ruby-windows: - description: "Install Ruby on Windows" - parameters: - ruby_version: - description: 'version tag for the cimg/ruby container' - type: string - steps: - - run: - name: remove pre-installed ruby - command: | - Get-ChildItem -path 'C:\tools\' -filter Ruby* | Remove-Item -Force -Recurse - - - run: - name: download and install ruby devkit - command: | - $ProgressPreference='SilentlyContinue' - - $uri = 'https://api.github.com/repos/oneclick/rubyinstaller2/tags?per_page=200' - $releases = ((Invoke-WebRequest $uri) | ConvertFrom-Json).name | select-string (-join("RubyInstaller-" , "<< parameters.ruby_version >>" )) - $target_release = (($releases | Sort-Object -Descending)[0] | Out-String).Trim() - $target_version = $target_release.Substring($target_release.Length - 7) - $download_uri = "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-$target_version/rubyinstaller-devkit-$target_version-x64.exe" - echo "Ruby Target Version Found: $target_version" - - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 - Invoke-WebRequest -UseBasicParsing -uri $download_uri -OutFile C:\ruby-setup.exe - - echo "Download finished, starting installation of $target_version" - C:\ruby-setup.exe /VERYSILENT /NORESTART /ALLUSERS /DIR=C:/Ruby<< parameters.ruby_version >>-x64 - - - run: - name: ruby diagnostics - command: | - $Env:PATH = "C:\\Ruby<< parameters.ruby_version >>-x64\\bin;$Env:PATH" - echo "Perl Version:" - perl --version - echo "Ruby Version:" - ruby --version - echo "Gem Version:" - gem --version - - - run: - name: install bundler - command: | - $Env:PATH = "C:\\Ruby<< parameters.ruby_version >>-x64\\bin;$Env:PATH" - gem install bundler -v 2.3.26 - -jobs: - test_linux: - parameters: - mssql_version: - description: 'Version of MSSQL to be used' - type: string - - ruby_version: - description: 'version tag for the cimg/ruby container' - type: string - - machine: - image: ubuntu-2004:current - - # be sure to update the ./setup_cimgruby_dev.sh if changes are made to steps below - steps: - - checkout - - - run: - name: start docker-compose build environment - command: | - sudo ./test/bin/setup_volume_permissions.sh - docker-compose up -d - echo "Waiting for containers to start..." - sleep 10 - environment: - MSSQL_VERSION: << parameters.mssql_version >> - RUBY_VERSION: << parameters.ruby_version >> - - - run: - name: install sql prereqs - command: | - docker exec cimg_ruby bash -c 'sudo -E ./test/bin/install-mssqltools.sh' - - - run: - name: setup tiny_tds test database - command: | - docker exec cimg_ruby bash -c './test/bin/setup_tinytds_db.sh' - - - run: - name: bundle install gems - command: | - docker exec cimg_ruby bash -c 'bundle install' - - - run: - name: Write used versions into file - command: | - docker exec cimg_ruby bash -c 'bundle exec rake ports:version_file' - - - restore_cache: - name: restore ports cache - keys: - - ports-<< parameters.ruby_version >>-{{ arch }}-{{ checksum ".ports_versions" }} - - ports-<< parameters.ruby_version >>-{{ arch }}- - - - run: - name: compile ports - command: | - docker exec cimg_ruby bash -c 'bundle exec rake ports' - - - run: - name: build gem - command: | - docker exec cimg_ruby bash -c 'bundle exec rake build' - - - run: - name: Fix permissions on ports directory - command: | - docker exec cimg_ruby bash -c 'sudo chown -R $(id -u):$(id -g) ports' - - - run: - name: test gem - command: | - docker exec cimg_ruby bash -c 'bundle exec rake test' - - - save_cache: - name: save ports cache - paths: - - ./ports - key: ports-<< parameters.ruby_version >>-{{ arch }}-{{ arch }}-{{ checksum ".ports_versions" }} - - - store_test_results: - path: test/reports - - test_windows: - parameters: - mssql_version: - description: 'Version of MSSQL to be used' - type: string - - ruby_version: - description: 'version tag for rubydev environment' - type: string - - executor: - name: win/server-2022 - shell: powershell.exe - - environment: - RAKEOPT: '-rdevkit' - TESTOPTS: '-v' - MAKE: 'make V=1 -j2' - - steps: - - install-ruby-windows: - ruby_version: << parameters.ruby_version >> - - - checkout - - - restore_cache: - name: restore gem cache - keys: - - v1-bundle-<< parameters.ruby_version >>-{{ arch }}-{{ .Branch }}-{{ checksum "tiny_tds.gemspec" }} - - v1-bundle-<< parameters.ruby_version >>-{{ arch }}-{{ .Branch }}- - - v1-bundle-<< parameters.ruby_version >>-{{ arch }}- - - - run: - name: bundle install gems - command: | - $Env:PATH = "C:\\Ruby<< parameters.ruby_version >>-x64\\bin;$Env:PATH" - bundle install --path vendor/bundle - - - save_cache: - name: save gem cache - paths: - - ./vendor/bundle - key: v1-bundle-<< parameters.ruby_version >>-{{ arch }}-{{ .Branch }}-{{ checksum "tiny_tds.gemspec" }} - - - attach_workspace: - at: artifacts - - - run: - name: install native gem and restore cross-compiled code from gem - command: | - $Env:PATH = "C:\\Ruby<< parameters.ruby_version >>-x64\\bin;$Env:PATH" - $rubyArchitecture = (ruby -e 'puts RUBY_PLATFORM').Trim() - $gemVersion = (Get-Content VERSION).Trim() - - gem install --local --install-dir=./tmp "artifacts/gems/tiny_tds-$gemVersion-$rubyArchitecture.gem" - - # Restore precompiled code - $source = (Resolve-Path ".\tmp\gems\tiny_tds-$gemVersion-$rubyArchitecture\lib\tiny_tds").Path - $destination = (Resolve-Path ".\lib\tiny_tds").Path - Get-ChildItem $source -Recurse -Exclude "*.rb" | Copy-Item -Destination {Join-Path $destination $_.FullName.Substring($source.length)} - - # Restore ports - Copy-Item -Path ".\tmp\gems\tiny_tds-$gemVersion-$rubyArchitecture\ports" -Destination "." -Recurse - - - restore_cache: - name: restore mssql installation file - key: downloads-<< parameters.mssql_version >>-{{ checksum "test/bin/install-mssql.ps1" }} - - - run: - name: setup mssql - command: | - .\test\bin\install-mssql.ps1 -Version << parameters.mssql_version >> - - - save_cache: - name: save downloads cache - paths: - - C:\Downloads - key: downloads-<< parameters.mssql_version >>-{{ checksum "test/bin/install-mssql.ps1" }} - - - run: - name: install toxiproxy-server - command: | - choco install toxiproxy-server --version=2.5.0 -y - Start-Process toxiproxy-server - - - run: - name: test gem - command: | - $Env:PATH = "C:\\Ruby<< parameters.ruby_version >>-x64\\bin;$Env:PATH" - bundle exec rake test - environment: - TOXIPROXY_HOST: "localhost" - - - store_test_results: - path: test/reports - - - run: - name: Rename gem to a consistent name to store artifact - command: | - $Env:PATH = "C:\\Ruby<< parameters.ruby_version >>-x64\\bin;$Env:PATH" - $rubyArchitecture = (ruby -e 'puts RUBY_PLATFORM').Trim() - $gemVersion = (Get-Content VERSION).Trim() - - New-Item -Path . -Name "tested_artifact" -ItemType "directory" - Move-Item "artifacts/gems/tiny_tds-$gemVersion-$rubyArchitecture.gem" "tested_artifact" - - - store_artifacts: - path: tested_artifact - - cross_compile_gem: - parameters: - platform: - description: "Platform to compile the gem resources" - type: string - - docker: - - image: "ghcr.io/rake-compiler/rake-compiler-dock-image:1.4.0-mri-<< parameters.platform >>" - - steps: - - checkout - - - run: - name: bundle install gems - command: | - bundle install - - - run: - name: Write used versions for ports into file - command: | - rake ports:version_file[<< parameters.platform >>] - - - restore_cache: - name: restore ports cache - keys: - - ports-win-{{ arch }}-{{ checksum ".ports_versions" }} - - ports-win-{{ arch }}- - - - run: - name: Build gem - command: | - rake gem:for_platform[<< parameters.platform >>] - - - run: - name: Move gems into separate directory before caching - command: | - mkdir -p artifacts-<< parameters.platform >>/gems - mv pkg/*.gem artifacts-<< parameters.platform >>/gems - - - run: - name: Remove non-native gem to avoid conflict in workspace - command: | - gemVersion=$(cat VERSION | tr -d "[:space:]") - rm -rf artifacts-<< parameters.platform >>/gems/tiny_tds-$gemVersion.gem - - - store_artifacts: - path: artifacts-<< parameters.platform >>/gems - - - save_cache: - name: save ports cache - paths: - - ./ports - key: ports-win-{{ arch }}-{{ checksum ".ports_versions" }} - - - persist_to_workspace: - name: save gems into workspace - root: artifacts-<< parameters.platform >> - paths: - - gems - - install_windows: - parameters: - ruby_version: - description: 'version tag for rubydev environment' - type: string - - executor: - name: win/server-2022 - shell: powershell.exe - - environment: - RAKEOPT: '-rdevkit' - TESTOPTS: '-v' - MAKE: 'make V=1 -j2' - - steps: - - install-ruby-windows: - ruby_version: << parameters.ruby_version >> - - - run: - name: Ensure msys2 installation is complete - command: | - $Env:PATH = "C:\\Ruby<< parameters.ruby_version >>-x64\\bin;$Env:PATH" - - # on older Ruby version, the msys version shipped with RubyInstaller is quite old - # and RubyInstaller will be unable to install anything because of outdated keys - # With this those commands, we force to get a new set of keys - # see https://www.msys2.org/docs/updating/#potential-issues - ridk exec pacman-key --init - ridk exec pacman-key --refresh-keys - ridk install 1 2 3 - - - checkout - - - restore_cache: - name: restore gem cache - keys: - - v1-bundle-<< parameters.ruby_version >>-{{ arch }}-{{ .Branch }}-{{ checksum "tiny_tds.gemspec" }} - - v1-bundle-<< parameters.ruby_version >>-{{ arch }}-{{ .Branch }}- - - v1-bundle-<< parameters.ruby_version >>-{{ arch }}- - - - run: - name: bundle install gems - command: | - $Env:PATH = "C:\\Ruby<< parameters.ruby_version >>-x64\\bin;$Env:PATH" - bundle install --path vendor/bundle - - - save_cache: - name: save gem cache - paths: - - ./vendor/bundle - key: v1-bundle-<< parameters.ruby_version >>-{{ arch }}-{{ .Branch }}-{{ checksum "tiny_tds.gemspec" }} - - - run: - name: build gem - command: | - $Env:PATH = "C:\\Ruby<< parameters.ruby_version >>-x64\\bin;$Env:PATH" - gem build tiny_tds.gemspec - - - run: - name: Install gem - command: | - $Env:PATH = "C:\\Ruby<< parameters.ruby_version >>-x64\\bin;$Env:PATH" - $gemVersion = (Get-Content VERSION).Trim() - gem install --local "tiny_tds-$gemVersion.gem" - - - run: - name: Check if gem loads correctly - command: | - $Env:PATH = "C:\\Ruby<< parameters.ruby_version >>-x64\\bin;$Env:PATH" - ruby -e "require 'tiny_tds'; puts TinyTds::Gem.root_path" - exit $LASTEXITCODE - -workflows: - test_supported_ruby_versions: - jobs: - - cross_compile_gem: - matrix: - parameters: - platform: - - "x86-mingw32" - - "x64-mingw32" - - "x64-mingw-ucrt" - - test_windows: - requires: - - cross_compile_gem - matrix: - parameters: - mssql_version: &mssql_versions - - '2017' - - '2019' - - '2022' - - ruby_version: &ruby_versions - - '2.7' - - '3.0' - - '3.1' - - '3.2' - - '3.3' - - - test_linux: - matrix: - parameters: - mssql_version: *mssql_versions - ruby_version: *ruby_versions - - - install_windows: - matrix: - parameters: - ruby_version: *ruby_versions diff --git a/README.md b/README.md index 0789467d..4aa68e69 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ # TinyTDS - Simple and fast FreeTDS bindings for Ruby using DB-Library. -* [![CircleCI](https://circleci.com/gh/rails-sqlserver/tiny_tds.svg?style=svg)](https://app.circleci.com/pipelines/github/rails-sqlserver/tiny_tds) - CircleCi * [![Gem Version](https://img.shields.io/gem/v/tiny_tds.svg)](https://rubygems.org/gems/tiny_tds) - Gem Version * [![Gitter chat](https://img.shields.io/badge/%E2%8A%AA%20GITTER%20-JOIN%20CHAT%20%E2%86%92-brightgreen.svg?style=flat)](https://gitter.im/rails-sqlserver/activerecord-sqlserver-adapter) - Community From 2416b1d4e7c23f5d5054f380d4bac8b2214b5464 Mon Sep 17 00:00:00 2001 From: Andy Pfister Date: Sun, 14 Apr 2024 22:48:18 +0200 Subject: [PATCH 02/13] Setup GitHub Actions --- .github/workflows/ci.yml | 390 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 390 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..b38bab5d --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,390 @@ +name: Build and test gem + +on: + push: + pull_request: + workflow_dispatch: + +jobs: + cross-compile: + strategy: + matrix: + platform: + - "x64-mingw32" + - "x86-mingw32" + - "x64-mingw-ucrt" + name: Cross-compile gem + runs-on: ubuntu-latest + container: + image: "ghcr.io/rake-compiler/rake-compiler-dock-image:1.4.0-mri-${{ matrix.platform }}" + steps: + - uses: actions/checkout@v4 + - run: git config --global --add safe.directory /__w/tiny_tds/tiny_tds # shrug + - name: Install gems + shell: bash + run: bundle install + - name: Write used versions into file + shell: bash + run: bundle exec rake ports:version_file[${{ matrix.platform }}] + - name: Cache ports + uses: actions/cache@v4 + with: + path: ports + key: cross-compiled-${{ hashFiles('**/.ports_versions') }} + restore-keys: | + cross-compiled-${{ hashFiles('**/.ports_versions') }} + cross-compiled-v2- + - name: Build gem + shell: bash + run: bundle exec rake gem:for_platform[${{ matrix.platform }}] + - name: Move gems into separate directory before persisting + run: | + mkdir -p artifacts/gem + mv pkg/*.gem artifacts/gem + - uses: actions/upload-artifact@v4 + with: + name: gem-${{ matrix.platform }} + path: artifacts/gem + + install-windows-mingw: + needs: + - cross-compile + strategy: + fail-fast: false + matrix: + ruby-version: + - 2.7 + - '3.0' + + name: Install on Windows (MingW) + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + + - name: Download precompiled gem + uses: actions/download-artifact@v4 + with: + name: gem-x64-mingw32 + + - name: Install native gem and test if TinyTDS loads + shell: pwsh + run: | + $rubyArchitecture = (ruby -e "puts RbConfig::CONFIG['arch']").Trim() + $gemVersion = (Get-Content VERSION).Trim() + $gemToInstall = "./tiny_tds-$gemVersion-$rubyArchitecture.gem" + + Write-Host "Looking to install $gemToInstall" + gem install --local "$gemToInstall" + + ruby -e "require 'tiny_tds'; puts TinyTds::Gem.root_path" + exit $LASTEXITCODE + + test-windows-mingw: + needs: + - cross-compile + strategy: + fail-fast: false + matrix: + mssql-version: + - 2017 + - 2019 + - 2022 + ruby-version: + - 2.7 + - '3.0' + + name: Test on Windows (MingW) + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + bundler-cache: true + + - name: Download precompiled gem + uses: actions/download-artifact@v4 + with: + name: gem-x64-mingw32 + + - name: Install native gem and restore cross-compiled code from it + shell: pwsh + run: | + $rubyArchitecture = (ruby -e "puts RbConfig::CONFIG['arch']").Trim() + $gemVersion = (Get-Content VERSION).Trim() + $gemToInstall = "./tiny_tds-$gemVersion-$rubyArchitecture.gem" + + Write-Host "Looking to install $gemToInstall" + gem install --local --install-dir=./tmp "$gemToInstall" + + # Restore precompiled code + $source = (Resolve-Path ".\tmp\gems\tiny_tds-$gemVersion-$rubyArchitecture\lib\tiny_tds").Path + $destination = (Resolve-Path ".\lib\tiny_tds").Path + Get-ChildItem $source -Recurse -Exclude "*.rb" | Copy-Item -Destination {Join-Path $destination $_.FullName.Substring($source.length)} + + # Restore ports + Copy-Item -Path ".\tmp\gems\tiny_tds-$gemVersion-$rubyArchitecture\ports" -Destination "." -Recurse + + - name: Setup MSSQL + uses: potatoqualitee/mssqlsuite@v1.7 + with: + install: sqlengine, sqlclient + version: ${{ matrix.mssql-version }} + sa-password: c0MplicatedP@ssword + show-log: true + + - name: Setup MSSQL database + shell: pwsh + run: | + & sqlcmd -S localhost -U sa -P "c0MplicatedP@ssword" -i ./test/sql/db-create.sql + & sqlcmd -S localhost -U sa -P "c0MplicatedP@ssword" -i ./test/sql/db-login.sql + + - name: Install toxiproxy-server + shell: pwsh + run: | + choco install toxiproxy-server --version=2.5.0 -y + Start-Process toxiproxy-server + + - name: Test gem + shell: pwsh + run: bundle exec rake test + env: + TOXIPROXY_HOST: "localhost" + + install-windows-ucrt: + needs: + - cross-compile + strategy: + fail-fast: false + matrix: + ruby-version: + - 3.1 + - 3.2 + - 3.3 + + name: Install on Windows (UCRT) + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + + - name: Download precompiled gem + uses: actions/download-artifact@v4 + with: + name: gem-x64-mingw-ucrt + + - name: Install native gem and test if TinyTDS loads + shell: pwsh + run: | + $rubyArchitecture = (ruby -e "puts RbConfig::CONFIG['arch']").Trim() + $gemVersion = (Get-Content VERSION).Trim() + $gemToInstall = "./tiny_tds-$gemVersion-$rubyArchitecture.gem" + + Write-Host "Looking to install $gemToInstall" + gem install --local "$gemToInstall" + + ruby -e "require 'tiny_tds'; puts TinyTds::Gem.root_path" + exit $LASTEXITCODE + + test-windows-ucrt: + needs: + - cross-compile + strategy: + fail-fast: false + matrix: + mssql-version: + - 2017 + - 2019 + - 2022 + ruby-version: + - 3.1 + - 3.2 + - 3.3 + name: Test on Windows (UCRT) + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + bundler-cache: true + + - name: Download precompiled gem + uses: actions/download-artifact@v4 + with: + name: gem-x64-mingw-ucrt + + - name: Install native gem and restore cross-compiled code from it + shell: pwsh + run: | + $rubyArchitecture = (ruby -e "puts RbConfig::CONFIG['arch']").Trim() + $gemVersion = (Get-Content VERSION).Trim() + $gemToInstall = "./tiny_tds-$gemVersion-$rubyArchitecture.gem" + + Write-Host "Looking to install $gemToInstall" + gem install --local --install-dir=./tmp "$gemToInstall" + + # Restore precompiled code + $source = (Resolve-Path ".\tmp\gems\tiny_tds-$gemVersion-$rubyArchitecture\lib\tiny_tds").Path + $destination = (Resolve-Path ".\lib\tiny_tds").Path + Get-ChildItem $source -Recurse -Exclude "*.rb" | Copy-Item -Destination {Join-Path $destination $_.FullName.Substring($source.length)} + + # Restore ports + Copy-Item -Path ".\tmp\gems\tiny_tds-$gemVersion-$rubyArchitecture\ports" -Destination "." -Recurse + + - name: Setup MSSQL + uses: potatoqualitee/mssqlsuite@v1.7 + with: + install: sqlengine, sqlclient + version: ${{ matrix.mssql-version }} + sa-password: c0MplicatedP@ssword + show-log: true + + - name: Setup MSSQL database + shell: pwsh + run: | + & sqlcmd -S localhost -U sa -P "c0MplicatedP@ssword" -i ./test/sql/db-create.sql + & sqlcmd -S localhost -U sa -P "c0MplicatedP@ssword" -i ./test/sql/db-login.sql + + - name: Install toxiproxy-server + shell: pwsh + run: | + choco install toxiproxy-server --version=2.5.0 -y + Start-Process toxiproxy-server + + - name: Test gem + shell: pwsh + run: bundle exec rake test + env: + TOXIPROXY_HOST: "localhost" + + install-windows-native: + strategy: + fail-fast: false + matrix: + ruby-version: + - 2.7 + - "3.0" + - 3.1 + - 3.2 + - 3.3 + + name: Install on Windows (Native) + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + + - name: Build gem + shell: pwsh + run: gem build tiny_tds.gemspec + + - name: Install gem and test if TinyTDS loads + shell: pwsh + run: | + $gemVersion = (Get-Content VERSION).Trim() + gem install --local "tiny_tds-$gemVersion.gem" + + ruby -e "require 'tiny_tds'; puts TinyTds::Gem.root_path" + exit $LASTEXITCODE + + compile-native-ports: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.3 + bundler-cache: true + + - name: Write used versions into file + run: bundle exec rake ports:version_file + + - name: Cache ports + uses: actions/cache@v4 + with: + path: ports + key: native-v2-${{ hashFiles('**/.ports_versions') }} + restore-keys: | + native-${{ hashFiles('* */.ports_versions') }} + native-v2- + + - name: Build required libraries + run: | + bundle exec rake ports + + test-linux: + needs: + - compile-native-ports + strategy: + matrix: + mssql-version: + - 2017 + - 2019 + - 2022 + ruby-version: + - 2.7 + - '3.0' + - 3.1 + - 3.2 + - 3.3 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + bundler-cache: true + + - name: Write used versions into file + run: | + bundle exec rake ports:version_file + + - name: Cache ports + uses: actions/cache@v4 + with: + path: ports + key: native-v2-${{ hashFiles('**/.ports_versions') }} + fail-on-cache-miss: true + + - name: Build gem + run: | + bundle exec rake build + + - name: Setup MSSQL + uses: potatoqualitee/mssqlsuite@v1.7 + with: + install: sqlengine, sqlclient + version: ${{ matrix.mssql-version }} + sa-password: "c0MplicatedP@ssword" + show-log: true + + - name: Setup MSSQL database + run: | + sqlcmd -S localhost -U sa -P "c0MplicatedP@ssword" -i ./test/sql/db-create.sql + sqlcmd -S localhost -U sa -P "c0MplicatedP@ssword" -i ./test/sql/db-login.sql + + - name: Install toxiproxy-server + run: | + wget -O toxiproxy-2.5.0.deb https://github.com/Shopify/toxiproxy/releases/download/v2.5.0/toxiproxy_2.5.0_linux_amd64.deb + sudo dpkg -i toxiproxy-2.5.0.deb + sudo toxiproxy-server & + + - name: Run tests + run: bundle exec rake test + env: + TOXIPROXY_HOST: "localhost" From 7dcd4fa8e7445db83cb0c0fc27233335547ed401 Mon Sep 17 00:00:00 2001 From: Andy Pfister Date: Wed, 17 Apr 2024 21:53:48 +0200 Subject: [PATCH 03/13] Setup test summary --- .github/workflows/ci.yml | 18 ++++++++++++++++++ test/test_helper.rb | 3 +++ tiny_tds.gemspec | 2 +- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b38bab5d..af8c8174 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -156,6 +156,12 @@ jobs: env: TOXIPROXY_HOST: "localhost" + - name: Test Summary + uses: test-summary/action@v2 + with: + paths: "test/reports/TEST-*.xml" + if: always() + install-windows-ucrt: needs: - cross-compile @@ -267,6 +273,12 @@ jobs: env: TOXIPROXY_HOST: "localhost" + - name: Test Summary + uses: test-summary/action@v2 + with: + paths: "test/reports/TEST-*.xml" + if: always() + install-windows-native: strategy: fail-fast: false @@ -388,3 +400,9 @@ jobs: run: bundle exec rake test env: TOXIPROXY_HOST: "localhost" + + - name: Test Summary + uses: test-summary/action@v2 + with: + paths: "test/reports/TEST-*.xml" + if: always() diff --git a/test/test_helper.rb b/test/test_helper.rb index 7de3d924..82ca1a6d 100755 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -4,6 +4,9 @@ require 'minitest/autorun' require 'toxiproxy' +require "minitest/reporters" +Minitest::Reporters.use! [Minitest::Reporters::SpecReporter.new, Minitest::Reporters::JUnitReporter.new] + TINYTDS_SCHEMAS = ['sqlserver_2017', 'sqlserver_azure'].freeze module TinyTds diff --git a/tiny_tds.gemspec b/tiny_tds.gemspec index efc3284b..be86ee1d 100644 --- a/tiny_tds.gemspec +++ b/tiny_tds.gemspec @@ -25,7 +25,7 @@ Gem::Specification.new do |s| s.add_development_dependency 'rake-compiler', '~> 1.2' s.add_development_dependency 'rake-compiler-dock', '~> 1.4.0' s.add_development_dependency 'minitest', '~> 5.14.0' - s.add_development_dependency 'minitest-ci', '~> 3.4.0' + s.add_development_dependency 'minitest-reporters', '~> 1.6.1' s.add_development_dependency 'connection_pool', '~> 2.2.0' s.add_development_dependency 'toxiproxy', '~> 2.0.0' end From b6ca78840abce00ee5c7752c18aecefd082c8d37 Mon Sep 17 00:00:00 2001 From: Andy Pfister Date: Wed, 17 Apr 2024 22:03:08 +0200 Subject: [PATCH 04/13] Test installation on M1 Mac This is a test specifically for #545, which we were unable to run on CircleCI since we did not have paid runners. --- .github/workflows/ci.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index af8c8174..7ad4f910 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -406,3 +406,38 @@ jobs: with: paths: "test/reports/TEST-*.xml" if: always() + + install_macos: + strategy: + fail-fast: false + matrix: + ruby-version: + - 2.7 + - "3.0" + - 3.1 + - 3.2 + - 3.3 + + name: Install on Mac OS (M1) + runs-on: macos-14 + steps: + - uses: actions/checkout@v4 + + - name: Install FreeTDS + run: brew install freetds + shell: bash + + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + + - name: Build gem + shell: bash + run: gem build tiny_tds.gemspec + + - name: Install gem and test if TinyTDS loads + shell: bash + run: | + gemVersion=$( Date: Tue, 23 Apr 2024 22:27:46 +0200 Subject: [PATCH 05/13] Disable tests with Windows and MSSQL 2017 (for now) --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7ad4f910..23a27163 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -90,7 +90,7 @@ jobs: fail-fast: false matrix: mssql-version: - - 2017 + #- 2017 - 2019 - 2022 ruby-version: @@ -207,7 +207,7 @@ jobs: fail-fast: false matrix: mssql-version: - - 2017 + #- 2017 - 2019 - 2022 ruby-version: From 1d9a7c9983cd90d2946b612ccf2b66908b435d20 Mon Sep 17 00:00:00 2001 From: Andy Pfister Date: Tue, 30 Apr 2024 20:44:53 +0200 Subject: [PATCH 06/13] Remove moving built gems into separate directory --- .github/workflows/ci.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 23a27163..e2740199 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,14 +37,10 @@ jobs: - name: Build gem shell: bash run: bundle exec rake gem:for_platform[${{ matrix.platform }}] - - name: Move gems into separate directory before persisting - run: | - mkdir -p artifacts/gem - mv pkg/*.gem artifacts/gem - uses: actions/upload-artifact@v4 with: name: gem-${{ matrix.platform }} - path: artifacts/gem + path: pkg/*.gem install-windows-mingw: needs: From 6c4e6436f8e03c828ed60e1ab299458b5dd876a5 Mon Sep 17 00:00:00 2001 From: Andy Pfister Date: Tue, 30 Apr 2024 20:55:09 +0200 Subject: [PATCH 07/13] Adjust name --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e2740199..3f7e2fc0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: Build and test gem +name: CI on: push: From e994b637e3d7bd339cdceca3b159794a35f39310 Mon Sep 17 00:00:00 2001 From: Andy Pfister Date: Tue, 30 Apr 2024 20:57:16 +0200 Subject: [PATCH 08/13] Add more space --- .github/workflows/ci.yml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3f7e2fc0..a3ff0d31 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,13 +19,17 @@ jobs: image: "ghcr.io/rake-compiler/rake-compiler-dock-image:1.4.0-mri-${{ matrix.platform }}" steps: - uses: actions/checkout@v4 + - run: git config --global --add safe.directory /__w/tiny_tds/tiny_tds # shrug + - name: Install gems shell: bash run: bundle install + - name: Write used versions into file shell: bash run: bundle exec rake ports:version_file[${{ matrix.platform }}] + - name: Cache ports uses: actions/cache@v4 with: @@ -34,9 +38,11 @@ jobs: restore-keys: | cross-compiled-${{ hashFiles('**/.ports_versions') }} cross-compiled-v2- + - name: Build gem shell: bash run: bundle exec rake gem:for_platform[${{ matrix.platform }}] + - uses: actions/upload-artifact@v4 with: name: gem-${{ matrix.platform }} @@ -50,7 +56,7 @@ jobs: matrix: ruby-version: - 2.7 - - '3.0' + - "3.0" name: Install on Windows (MingW) runs-on: windows-latest @@ -72,10 +78,10 @@ jobs: $rubyArchitecture = (ruby -e "puts RbConfig::CONFIG['arch']").Trim() $gemVersion = (Get-Content VERSION).Trim() $gemToInstall = "./tiny_tds-$gemVersion-$rubyArchitecture.gem" - + Write-Host "Looking to install $gemToInstall" gem install --local "$gemToInstall" - + ruby -e "require 'tiny_tds'; puts TinyTds::Gem.root_path" exit $LASTEXITCODE @@ -91,7 +97,7 @@ jobs: - 2022 ruby-version: - 2.7 - - '3.0' + - "3.0" name: Test on Windows (MingW) runs-on: windows-latest @@ -239,7 +245,7 @@ jobs: $source = (Resolve-Path ".\tmp\gems\tiny_tds-$gemVersion-$rubyArchitecture\lib\tiny_tds").Path $destination = (Resolve-Path ".\lib\tiny_tds").Path Get-ChildItem $source -Recurse -Exclude "*.rb" | Copy-Item -Destination {Join-Path $destination $_.FullName.Substring($source.length)} - + # Restore ports Copy-Item -Path ".\tmp\gems\tiny_tds-$gemVersion-$rubyArchitecture\ports" -Destination "." -Recurse @@ -345,7 +351,7 @@ jobs: - 2022 ruby-version: - 2.7 - - '3.0' + - "3.0" - 3.1 - 3.2 - 3.3 From c7ae011d5909bf852cd4486459aba4f82a3b90b9 Mon Sep 17 00:00:00 2001 From: Andy Pfister Date: Tue, 30 Apr 2024 20:59:02 +0200 Subject: [PATCH 09/13] Quote all Ruby version values --- .github/workflows/ci.yml | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a3ff0d31..cb0b80b8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,7 +55,7 @@ jobs: fail-fast: false matrix: ruby-version: - - 2.7 + - "2.7" - "3.0" name: Install on Windows (MingW) @@ -96,7 +96,7 @@ jobs: - 2019 - 2022 ruby-version: - - 2.7 + - "2.7" - "3.0" name: Test on Windows (MingW) @@ -171,9 +171,9 @@ jobs: fail-fast: false matrix: ruby-version: - - 3.1 - - 3.2 - - 3.3 + - "3.1" + - "3.2" + - "3.3" name: Install on Windows (UCRT) runs-on: windows-latest @@ -213,9 +213,9 @@ jobs: - 2019 - 2022 ruby-version: - - 3.1 - - 3.2 - - 3.3 + - "3.1" + - "3.2" + - "3.3" name: Test on Windows (UCRT) runs-on: windows-latest steps: @@ -286,11 +286,11 @@ jobs: fail-fast: false matrix: ruby-version: - - 2.7 + - "2.7" - "3.0" - - 3.1 - - 3.2 - - 3.3 + - "3.1" + - "3.2" + - "3.3" name: Install on Windows (Native) runs-on: windows-latest @@ -350,11 +350,11 @@ jobs: - 2019 - 2022 ruby-version: - - 2.7 + - "2.7" - "3.0" - - 3.1 - - 3.2 - - 3.3 + - "3.1" + - "3.2" + - "3.3" runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -414,11 +414,11 @@ jobs: fail-fast: false matrix: ruby-version: - - 2.7 + - "2.7" - "3.0" - - 3.1 - - 3.2 - - 3.3 + - "3.1" + - "3.2" + - "3.3" name: Install on Mac OS (M1) runs-on: macos-14 From dc3b1e4747749a8249531d04d425c42022f5bc7c Mon Sep 17 00:00:00 2001 From: Andy Pfister Date: Tue, 30 Apr 2024 21:03:29 +0200 Subject: [PATCH 10/13] Move "Test if TinyTDS loads" into separate steps --- .github/workflows/ci.yml | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cb0b80b8..5d5a871d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,7 +72,7 @@ jobs: with: name: gem-x64-mingw32 - - name: Install native gem and test if TinyTDS loads + - name: Install native gem shell: pwsh run: | $rubyArchitecture = (ruby -e "puts RbConfig::CONFIG['arch']").Trim() @@ -82,6 +82,9 @@ jobs: Write-Host "Looking to install $gemToInstall" gem install --local "$gemToInstall" + - name: Test if TinyTDS loads + shell: pwsh + run: | ruby -e "require 'tiny_tds'; puts TinyTds::Gem.root_path" exit $LASTEXITCODE @@ -189,7 +192,7 @@ jobs: with: name: gem-x64-mingw-ucrt - - name: Install native gem and test if TinyTDS loads + - name: Install native gem shell: pwsh run: | $rubyArchitecture = (ruby -e "puts RbConfig::CONFIG['arch']").Trim() @@ -199,6 +202,9 @@ jobs: Write-Host "Looking to install $gemToInstall" gem install --local "$gemToInstall" + - name: Test if TinyTDS loads + shell: pwsh + run: | ruby -e "require 'tiny_tds'; puts TinyTds::Gem.root_path" exit $LASTEXITCODE @@ -305,12 +311,15 @@ jobs: shell: pwsh run: gem build tiny_tds.gemspec - - name: Install gem and test if TinyTDS loads + - name: Install gem shell: pwsh run: | $gemVersion = (Get-Content VERSION).Trim() gem install --local "tiny_tds-$gemVersion.gem" + - name: Test if TinyTDS loads + shell: pwsh + run: | ruby -e "require 'tiny_tds'; puts TinyTds::Gem.root_path" exit $LASTEXITCODE @@ -442,4 +451,8 @@ jobs: run: | gemVersion=$( Date: Tue, 30 Apr 2024 21:06:25 +0200 Subject: [PATCH 11/13] Harmonize job names --- .github/workflows/ci.yml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5d5a871d..4fccfd20 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: - "x64-mingw32" - "x86-mingw32" - "x64-mingw-ucrt" - name: Cross-compile gem + name: cross-compile-windows runs-on: ubuntu-latest container: image: "ghcr.io/rake-compiler/rake-compiler-dock-image:1.4.0-mri-${{ matrix.platform }}" @@ -58,7 +58,7 @@ jobs: - "2.7" - "3.0" - name: Install on Windows (MingW) + name: install-windows-mingw runs-on: windows-latest steps: - uses: actions/checkout@v4 @@ -102,7 +102,7 @@ jobs: - "2.7" - "3.0" - name: Test on Windows (MingW) + name: test-windows-mingw runs-on: windows-latest steps: - uses: actions/checkout@v4 @@ -178,7 +178,7 @@ jobs: - "3.2" - "3.3" - name: Install on Windows (UCRT) + name: install-windows-ucrt runs-on: windows-latest steps: - uses: actions/checkout@v4 @@ -222,7 +222,7 @@ jobs: - "3.1" - "3.2" - "3.3" - name: Test on Windows (UCRT) + name: test-windows-ucrt runs-on: windows-latest steps: - uses: actions/checkout@v4 @@ -298,7 +298,7 @@ jobs: - "3.2" - "3.3" - name: Install on Windows (Native) + name: install-windows-native runs-on: windows-latest steps: - uses: actions/checkout@v4 @@ -325,6 +325,7 @@ jobs: compile-native-ports: runs-on: ubuntu-latest + name: cross-compile-linux steps: - uses: actions/checkout@v4 @@ -352,6 +353,7 @@ jobs: test-linux: needs: - compile-native-ports + name: test-linux strategy: matrix: mssql-version: @@ -429,7 +431,7 @@ jobs: - "3.2" - "3.3" - name: Install on Mac OS (M1) + name: install-macos-m1 runs-on: macos-14 steps: - uses: actions/checkout@v4 From 49c557d08e91648554b757f44faecd5ff0c643f1 Mon Sep 17 00:00:00 2001 From: Andy Pfister Date: Tue, 30 Apr 2024 21:23:10 +0200 Subject: [PATCH 12/13] Setup bundler cache for all Ruby installation jobs --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4fccfd20..c4711049 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,6 +66,7 @@ jobs: - uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby-version }} + bundler-cache: true - name: Download precompiled gem uses: actions/download-artifact@v4 @@ -186,6 +187,7 @@ jobs: - uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby-version }} + bundler-cache: true - name: Download precompiled gem uses: actions/download-artifact@v4 @@ -306,6 +308,7 @@ jobs: - uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby-version }} + bundler-cache: true - name: Build gem shell: pwsh @@ -443,6 +446,7 @@ jobs: - uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby-version }} + bundler-cache: true - name: Build gem shell: bash From 6a33e075abc64fb15e68d72584e0b1a0a3cd2a2c Mon Sep 17 00:00:00 2001 From: Andy Pfister Date: Wed, 8 May 2024 22:32:20 +0200 Subject: [PATCH 13/13] Disable `fail-fast` --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c4711049..f72503ad 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,6 +8,7 @@ on: jobs: cross-compile: strategy: + fail-fast: false matrix: platform: - "x64-mingw32" @@ -358,6 +359,7 @@ jobs: - compile-native-ports name: test-linux strategy: + fail-fast: false matrix: mssql-version: - 2017