From b7da4af85bcbe3ef2c932a83dfbbe7ee840c0e49 Mon Sep 17 00:00:00 2001 From: Bryan Wiegand Date: Tue, 29 Nov 2022 19:45:45 -0600 Subject: [PATCH 1/2] ruby 3x support --- .circleci/config.yml | 7 +++++-- clean_dev.sh | 10 ++++++++++ docker-compose.yml | 4 ++-- start_dev.sh | 13 +++++++++++-- tasks/native_gem.rake | 2 +- tasks/test.rake | 1 - test/bin/setup_volume_permissions.sh | 21 ++++++++++++++++----- 7 files changed, 45 insertions(+), 13 deletions(-) create mode 100755 clean_dev.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index eaf03ccd..b1212cfb 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -19,8 +19,9 @@ jobs: - run: name: start docker-compose build environment - command: | - sudo ./test/bin/setup_volume_permissions.sh + command: | + export ruby_version=<< parameters.ruby_version >> + sudo -E ./test/bin/setup_volume_permissions.sh docker-compose up -d echo "Waiting for containers to start..." sleep 10 @@ -173,6 +174,7 @@ workflows: - '2.5' - '2.6' - '2.7' + - '3.0' - test_windows: matrix: @@ -181,3 +183,4 @@ workflows: - '2.5' - '2.6' - '2.7' + - '3.0' diff --git a/clean_dev.sh b/clean_dev.sh new file mode 100755 index 00000000..ac65c70b --- /dev/null +++ b/clean_dev.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +# stop local dockerized development environment and clean build files + +set -x +set +e + +docker compose down + +sudo rm ./Gemfile.lock +sudo rm -rf ./tmp diff --git a/docker-compose.yml b/docker-compose.yml index 3a1afd30..be87dd1b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,7 +5,7 @@ networks: services: mssql: - image: metaskills/mssql-server-linux-tinytds:2017-GA + image: mcr.microsoft.com/mssql/server:2022-RTM-ubuntu-20.04 container_name: sqlserver environment: ACCEPT_EULA: Y @@ -21,7 +21,7 @@ services: network_mode: "host" cimgruby: - image: cimg/ruby:2.7.0 + image: cimg/ruby:${ruby_version} container_name: cimg_ruby environment: TESTOPTS: '-v' diff --git a/start_dev.sh b/start_dev.sh index 724fc72c..94980461 100755 --- a/start_dev.sh +++ b/start_dev.sh @@ -1,12 +1,21 @@ #!/usr/bin/env bash +# will spin up a local dockerized development environment set -x set -e +if [ -z "$ruby_version" ] +then + echo "set a value for environment variable ruby_version" + exit 1 +else + echo "ruby_version is $ruby_version" +fi + # set volume read/write permissions to work both outside and inside container -sudo ./test/bin/setup_volume_permissions.sh +sudo -E ./test/bin/setup_volume_permissions.sh -docker-compose up -d +docker compose up -d echo "Waiting for containers to start..." sleep 10 diff --git a/tasks/native_gem.rake b/tasks/native_gem.rake index d19cdb85..0cb09de8 100644 --- a/tasks/native_gem.rake +++ b/tasks/native_gem.rake @@ -8,7 +8,7 @@ task 'gem:windows' => ['ports:cross'] do build = ['bundle'] # and finally build the native gem - build << 'rake cross native gem RUBY_CC_VERSION=2.7.0:2.6.0:2.5.0:2.4.0 CFLAGS="-Wall" MAKE="make -j`nproc`"' + build << 'rake cross native gem RUBY_CC_VERSION=3.0.0:2.7.0:2.6.0:2.5.0 CFLAGS="-Wall" MAKE="make -j`nproc`"' RakeCompilerDock.sh build.join(' && ') end diff --git a/tasks/test.rake b/tasks/test.rake index 10ecac47..bc6f87cf 100644 --- a/tasks/test.rake +++ b/tasks/test.rake @@ -6,4 +6,3 @@ Rake::TestTask.new do |t| t.test_files = FileList['test/**/*_test.rb'] t.verbose = true end - diff --git a/test/bin/setup_volume_permissions.sh b/test/bin/setup_volume_permissions.sh index bb1e246d..dbb131f5 100755 --- a/test/bin/setup_volume_permissions.sh +++ b/test/bin/setup_volume_permissions.sh @@ -1,10 +1,21 @@ #!/usr/bin/env bash +# grants circlci docker uid and gid required write permissions to project file system set -x -sudo groupadd -g 3434 circleci_tinytds -sudo usermod -a -G circleci_tinytds $USER -sudo useradd circleci_tinytds -u 3434 -g 3434 -sudo usermod -a -G circleci_tinytds circleci_tinytds -sudo chgrp -R circleci_tinytds . +if $(dpkg --compare-versions $ruby_version lt 3.1) +then + sudo groupadd -g 3434 circleci_tinytds30 + sudo useradd circleci_tinytds30 -u 3434 -g 3434 + sudo usermod -a -G circleci_tinytds30 circleci_tinytds30 + sudo usermod -a -G circleci_tinytds30 $USER + sudo chgrp -R circleci_tinytds30 . +else + sudo groupadd -g 1002 circleci_tinytds31 + sudo useradd circleci_tinytds31 -u 1001 -g 1002 + sudo usermod -a -G circleci_tinytds31 circleci_tinytds31 + sudo usermod -a -G circleci_tinytds31 $USER + sudo chgrp -R circleci_tinytds31 . +fi + sudo chmod -R g+rwx . From 3c42cfd56ec0637f832046af03890ce1ba767e5d Mon Sep 17 00:00:00 2001 From: Bryan Wiegand Date: Fri, 6 Jan 2023 19:20:35 +0000 Subject: [PATCH 2/2] starting on ruby 3.1 support clearly, something changes in ruby 3.1 and tls. freetds receives an error "Adaptive Server connection failed", which turns out to be ssl related. updating dependencies version did not fix the issue. but further research found it is a known issue with other projects that depend on the freetds library. i tried updating openssl to the latest version, that didn't work. the only thing that has given progress so far is setting freetds to build with gnutls instead of openssl, which seem to be solution accepted by most people. as a result, it may be needed to switch tinytds to gnutls --- VERSION | 2 +- ext/tiny_tds/extconsts.rb | 4 ++-- start_dev.sh | 31 +++++++++++++++---------------- tasks/ports/freetds.rb | 2 +- test/bin/install-freetds.sh | 4 ++-- tiny_tds.gemspec | 10 +++++----- 6 files changed, 26 insertions(+), 27 deletions(-) diff --git a/VERSION b/VERSION index cd57a8b9..e3a4f193 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.1.5 +2.2.0 \ No newline at end of file diff --git a/ext/tiny_tds/extconsts.rb b/ext/tiny_tds/extconsts.rb index 1e1c1bf2..94e9911e 100644 --- a/ext/tiny_tds/extconsts.rb +++ b/ext/tiny_tds/extconsts.rb @@ -2,10 +2,10 @@ ICONV_VERSION = ENV['TINYTDS_ICONV_VERSION'] || "1.15" ICONV_SOURCE_URI = "http://ftp.gnu.org/pub/gnu/libiconv/libiconv-#{ICONV_VERSION}.tar.gz" -OPENSSL_VERSION = ENV['TINYTDS_OPENSSL_VERSION'] || '1.1.1d' +OPENSSL_VERSION = ENV['TINYTDS_OPENSSL_VERSION'] || '1.1.1s' OPENSSL_SOURCE_URI = "https://www.openssl.org/source/openssl-#{OPENSSL_VERSION}.tar.gz" -FREETDS_VERSION = ENV['TINYTDS_FREETDS_VERSION'] || "1.1.24" +FREETDS_VERSION = ENV['TINYTDS_FREETDS_VERSION'] || "1.3.16" FREETDS_VERSION_INFO = Hash.new { |h,k| h[k] = {files: "http://www.freetds.org/files/stable/freetds-#{k}.tar.bz2"} } diff --git a/start_dev.sh b/start_dev.sh index 94980461..ba9b56d6 100755 --- a/start_dev.sh +++ b/start_dev.sh @@ -1,30 +1,29 @@ #!/usr/bin/env bash # will spin up a local dockerized development environment -set -x +set +x set -e if [ -z "$ruby_version" ] then echo "set a value for environment variable ruby_version" - exit 1 else echo "ruby_version is $ruby_version" -fi -# set volume read/write permissions to work both outside and inside container -sudo -E ./test/bin/setup_volume_permissions.sh + # set volume read/write permissions to work both outside and inside container + sudo -E ./test/bin/setup_volume_permissions.sh -docker compose up -d -echo "Waiting for containers to start..." -sleep 10 + docker compose up -d + echo "Waiting for containers to start..." + sleep 10 -# setup circleci ruby container for development -docker exec cimg_ruby bash -c './setup_cimgruby_dev.sh' + # setup circleci ruby container for development + docker exec cimg_ruby bash -c './setup_cimgruby_dev.sh' -# enter container -set +x -echo "cimg/ruby container is ready for tiny_tds development.........." -echo "To enter container run: docker exec -it cimg_ruby /bin/bash" -echo "To build solution run: docker exec cimg_ruby bash -c 'bundle exec rake build'" -echo "To test solution run: docker exec cimg_ruby bash -c 'bundle exec rake test'" + # enter container + set +x + echo "cimg/ruby container is ready for tiny_tds development.........." + echo "To enter container run: docker exec -it cimg_ruby /bin/bash" + echo "To build solution run: docker exec cimg_ruby bash -c 'bundle exec rake build'" + echo "To test solution run: docker exec cimg_ruby bash -c 'bundle exec rake test'" +fi diff --git a/tasks/ports/freetds.rb b/tasks/ports/freetds.rb index baf4f1f6..911e1f76 100644 --- a/tasks/ports/freetds.rb +++ b/tasks/ports/freetds.rb @@ -19,7 +19,7 @@ def configure_defaults if version =~ /0\.91/ opts << '--with-tdsver=7.1' else - opts << '--with-tdsver=7.3' + opts << '--with-tdsver=7.4' end if windows? diff --git a/test/bin/install-freetds.sh b/test/bin/install-freetds.sh index d4ba3955..51298d76 100755 --- a/test/bin/install-freetds.sh +++ b/test/bin/install-freetds.sh @@ -11,8 +11,8 @@ wget http://www.freetds.org/files/stable/freetds-$FREETDS_VERSION.tar.gz tar -xzf freetds-$FREETDS_VERSION.tar.gz cd freetds-$FREETDS_VERSION ./configure --prefix=/opt/local \ - --with-openssl=/opt/local \ - --with-tdsver=7.3 + --with-gnutls \ + --with-tdsver=7.4 make make install cd .. diff --git a/tiny_tds.gemspec b/tiny_tds.gemspec index fa50d942..9b44be9d 100644 --- a/tiny_tds.gemspec +++ b/tiny_tds.gemspec @@ -18,13 +18,13 @@ Gem::Specification.new do |s| s.rdoc_options = ['--charset=UTF-8'] s.extensions = ['ext/tiny_tds/extconf.rb'] s.license = 'MIT' - s.required_ruby_version = '>= 2.0.0' + s.required_ruby_version = '>= 3.1.0' s.metadata['msys2_mingw_dependencies'] = 'freetds' - s.add_development_dependency 'mini_portile2', '~> 2.5.0' + s.add_development_dependency 'mini_portile2', '~> 2.8.1' s.add_development_dependency 'rake', '~> 13.0.0' s.add_development_dependency 'rake-compiler', '~> 1.1.0' s.add_development_dependency 'rake-compiler-dock', '~> 1.1.0' - s.add_development_dependency 'minitest', '~> 5.14.0' - s.add_development_dependency 'connection_pool', '~> 2.2.0' - s.add_development_dependency 'toxiproxy', '~> 2.0.0' + s.add_development_dependency 'minitest', '~> 5.17.0' + s.add_development_dependency 'connection_pool', '~> 2.3.0' + s.add_development_dependency 'toxiproxy', '~> 2.0.2' end