-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Ruby 3.1 and 3.2 #533
Changes from all commits
bdf0f40
f471526
cae55bf
0b21d89
37b4572
fb5b456
bbd8aee
801f16c
cb98ec1
69a6dbd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,30 +39,47 @@ jobs: | |
docker exec cimg_ruby bash -c './test/bin/setup_tinytds_db.sh' | ||
|
||
- run: | ||
name: compile openssl library | ||
name: bundle install gems | ||
command: | | ||
docker exec cimg_ruby bash -c 'sudo -E ./test/bin/install-openssl.sh' | ||
docker exec cimg_ruby bash -c 'bundle install' | ||
|
||
- run: | ||
name: compile freetds library | ||
name: Write used versions into file | ||
command: | | ||
docker exec cimg_ruby bash -c 'sudo -E ./test/bin/install-freetds.sh' | ||
docker exec cimg_ruby bash -c 'bundle exec rake ports:version_file' | ||
|
||
- restore_cache: | ||
name: restore ports cache | ||
keys: | ||
- ports-<< parameters.ruby_version >>-{{ checksum ".ports_versions" }} | ||
- ports-<< parameters.ruby_version >>- | ||
|
||
- run: | ||
name: bundle install gems | ||
name: compile ports | ||
command: | | ||
docker exec cimg_ruby bash -c 'bundle install' | ||
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 >>-{{ checksum ".ports_versions" }} | ||
|
||
- store_test_results: | ||
path: test/reports | ||
|
||
|
@@ -197,53 +214,49 @@ jobs: | |
path: test/reports | ||
|
||
cross_compile_gem: | ||
machine: | ||
image: ubuntu-2004:current | ||
parameters: | ||
platform: | ||
description: "Platform to compile the gem resources" | ||
type: string | ||
|
||
docker: | ||
- image: "ghcr.io/rake-compiler/rake-compiler-dock-image:1.3.0-mri-<< parameters.platform >>" | ||
|
||
steps: | ||
- ruby/install: | ||
version: '2.7' | ||
- checkout | ||
- restore_cache: | ||
name: restore gem cache | ||
keys: | ||
- v1-bundle-{{ .Branch }}-{{ checksum "tiny_tds.gemspec" }} | ||
- v1-bundle-{{ .Branch }}- | ||
- v1-bundle- | ||
|
||
- run: | ||
name: bundle install gems | ||
command: | | ||
bundle install --path vendor/bundle | ||
|
||
- save_cache: | ||
name: save gem cache | ||
paths: | ||
- ./vendor/bundle | ||
key: v1-bundle-{{ .Branch }}-{{ checksum "tiny_tds.gemspec" }} | ||
bundle install | ||
|
||
- run: | ||
name: Write used versions for ports into file | ||
command: | | ||
bundle exec rake ports:version_file | ||
rake ports:version_file[<< parameters.platform >>] | ||
|
||
- restore_cache: | ||
name: restore ports cache | ||
keys: | ||
- ports-{{ checksum ".ports_versions" }} | ||
- ports- | ||
- ports-win-{{ checksum ".ports_versions" }} | ||
- ports-win- | ||
|
||
- run: | ||
name: Build gems | ||
name: Build gem | ||
command: | | ||
bundle exec rake gem | ||
bundle exec rake gem:native | ||
rake gem:for_platform[<< parameters.platform >>] | ||
|
||
- run: | ||
name: Move gems into separate directory before caching | ||
command: | | ||
mkdir -p artifacts/gems | ||
mv pkg/*.gem artifacts/gems | ||
mkdir -p artifacts-<< parameters.platform >>/gems | ||
mv pkg/*.gem artifacts-<< parameters.platform >>/gems | ||
|
||
- run: | ||
name: Remove non-native gem to avoid conflict in workspace | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this mean there's unexpected shared state between the CI jobs? Addressing that might be a better approach than "delete everything that's not me" 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is a rather undesired side-effect of |
||
command: | | ||
gemVersion=$(cat VERSION | tr -d "[:space:]") | ||
rm -rf artifacts-<< parameters.platform >>/gems/tiny_tds-$gemVersion.gem | ||
|
||
- store_artifacts: | ||
path: artifacts/gems | ||
|
@@ -252,18 +265,24 @@ jobs: | |
name: save ports cache | ||
paths: | ||
- ./ports | ||
key: ports-{{ checksum ".ports_versions" }} | ||
key: ports-win-{{ checksum ".ports_versions" }} | ||
|
||
- persist_to_workspace: | ||
name: save gems into workspace | ||
root: artifacts | ||
root: artifacts-<< parameters.platform >> | ||
paths: | ||
- gems | ||
|
||
workflows: | ||
test_supported_ruby_versions: | ||
jobs: | ||
- cross_compile_gem | ||
- cross_compile_gem: | ||
matrix: | ||
parameters: | ||
platform: | ||
- "x86-mingw32" | ||
- "x64-mingw32" | ||
- "x64-mingw-ucrt" | ||
- test_windows: | ||
requires: | ||
- cross_compile_gem | ||
|
@@ -275,5 +294,7 @@ workflows: | |
- '2.6' | ||
- '2.7' | ||
- '3.0' | ||
- '3.1' | ||
- '3.2' | ||
- test_linux: | ||
matrix: *ruby_versions |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,20 +6,33 @@ require 'rake/extensiontask' | |
require_relative './ext/tiny_tds/extconsts' | ||
|
||
SPEC = Gem::Specification.load(File.expand_path('../tiny_tds.gemspec', __FILE__)) | ||
|
||
ruby_cc_ucrt_versions = "3.2.0:3.1.0".freeze | ||
ruby_cc_mingw32_versions = "3.0.0:2.7.0:2.6.0:2.5.0:2.4.0".freeze | ||
|
||
GEM_PLATFORM_HOSTS = { | ||
'x86-mingw32' => 'i686-w64-mingw32', | ||
'x64-mingw32' => 'x86_64-w64-mingw32' | ||
'x86-mingw32' => { | ||
host: 'i686-w64-mingw32', | ||
ruby_versions: ruby_cc_mingw32_versions | ||
}, | ||
'x64-mingw32' => { | ||
host: 'x86_64-w64-mingw32', | ||
ruby_versions: ruby_cc_mingw32_versions | ||
}, | ||
'x64-mingw-ucrt' => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like this commit is also introducing a ucrt based build, can you update the commit message with an additional explanation on this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added a reference to the commit in cae55bf. |
||
host: 'x86_64-w64-mingw32', | ||
ruby_versions: ruby_cc_ucrt_versions | ||
}, | ||
} | ||
RUBY_CC_VERSION="3.0.0:2.7.0:2.6.0:2.5.0:2.4.0".freeze | ||
|
||
# Add our project specific files to clean for a rebuild | ||
CLEAN.include FileList["{ext,lib}/**/*.{so,#{RbConfig::CONFIG['DLEXT']},o}"], | ||
FileList["exe/*"] | ||
FileList["exe/*"] | ||
|
||
# Clobber all our temp files and ports files including .install files | ||
# and archives | ||
CLOBBER.include FileList["tmp/**/*"], | ||
FileList["ports/**/*"].exclude(%r{^ports/archives}) | ||
FileList["ports/**/*"].exclude(%r{^ports/archives}) | ||
|
||
Dir['tasks/*.rake'].sort.each { |f| load f } | ||
|
||
|
@@ -33,15 +46,11 @@ Rake::ExtensionTask.new('tiny_tds', SPEC) do |ext| | |
# The fat binary gem doesn't depend on the freetds package, since it bundles the library. | ||
spec.metadata.delete('msys2_mingw_dependencies') | ||
|
||
platform_host_map = GEM_PLATFORM_HOSTS | ||
gemplat = spec.platform.to_s | ||
host = platform_host_map[gemplat] | ||
|
||
# We don't need the sources in a fat binary gem | ||
spec.files = spec.files.reject { |f| f =~ %r{^ports\/archives/} } | ||
|
||
# Make sure to include the ports binaries and libraries | ||
spec.files += FileList["ports/#{host}/**/**/{bin,lib}/*"].exclude do |f| | ||
spec.files += FileList["ports/#{spec.platform.to_s}/**/**/{bin,lib}/*"].exclude do |f| | ||
File.directory? f | ||
end | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,9 +21,11 @@ def do_help | |
do_help if arg_config('--help') | ||
|
||
# Make sure to check the ports path for the configured host | ||
host = RbConfig::CONFIG['host'] | ||
architecture = RbConfig::CONFIG['arch'] | ||
architecture = "x86-mingw32" if architecture == "i386-mingw32" | ||
|
||
project_dir = File.expand_path("../../..", __FILE__) | ||
freetds_ports_dir = File.join(project_dir, 'ports', host, 'freetds', FREETDS_VERSION) | ||
freetds_ports_dir = File.join(project_dir, 'ports', architecture, 'freetds', FREETDS_VERSION) | ||
Comment on lines
-24
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't completely understand the swap from "host" to "architecture", other than that I generally agree the latter makes sense. Is switching this matching rake compiler patterns, or is it something bespoke for this project's config? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not really on us, but rather on rake-compiler-dock. I edited the description, so it's hopefully more clear. |
||
freetds_ports_dir = File.expand_path(freetds_ports_dir) | ||
|
||
# Add all the special path searching from the original tiny_tds build | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switching the base image here is a little surprising, can you share more why this is needed? Also, rather than pinning to 1.3.0, is there a tag for the latest release?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's been a while since I implemented this. But basically, we previously had this one Ubuntu job which compiled the ports for
x86-mingw32
,x64-mingw32
. Now with this PR, we need to introduce another platform withx64-mingw-ucrt
.To speed to process up, I instead opt to run a separate job for each architecture. I do not recall how much time it saves, but I assume we talk about ~10 minutes per pipeline run.
Looking into GitHub packages, there is a snapshot version available, which might be unstable. Then 1.3.0 is already the latest release.
I think it makes sense to pin this version to align it with the
rake-compiler-dock
gem.