Skip to content

Commit

Permalink
Merge pull request #2659 from sparklemotion/flavorjones-try-bash-on-w…
Browse files Browse the repository at this point in the history
…indows-runners

ci: run bash scripts on windows runners
  • Loading branch information
flavorjones committed Nov 17, 2022
2 parents f98f7f3 + bec9da5 commit e9bafd0
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 29 deletions.
30 changes: 14 additions & 16 deletions .github/workflows/ci.yml
Expand Up @@ -459,10 +459,8 @@ jobs:
with:
name: generic-gem
path: gems
- run: |
gem install --verbose --no-document gems/*.gem -- --${{matrix.sys}}-system-libraries
gem list -d nokogiri
nokogiri -v
- run: ./scripts/test-gem-install gems --${{matrix.sys}}-system-libraries
shell: bash

generic-windows-install-ucrt:
needs: ["generic-package"]
Expand All @@ -483,10 +481,8 @@ jobs:
with:
name: generic-gem
path: gems
- run: |
gem install --verbose --no-document gems/*.gem -- --${{matrix.sys}}-system-libraries
gem list -d nokogiri
nokogiri -v
- run: ./scripts/test-gem-install gems --${{matrix.sys}}-system-libraries
shell: bash

cruby-package:
needs: ["rcd_image_version"]
Expand Down Expand Up @@ -654,17 +650,18 @@ jobs:
ruby: ["2.6", "2.7", "3.0"]
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: ruby/setup-ruby@v1
with:
ruby-version: "${{matrix.ruby}}"
- uses: actions/download-artifact@v3
with:
name: cruby-x64-mingw32-gem
path: gems
- run: |
gem install --verbose --no-document gems/*.gem
gem list -d nokogiri
nokogiri -v
- run: ./scripts/test-gem-install gems
shell: bash

cruby-x64-mingw-ucrt-install:
needs: ["cruby-package"]
Expand All @@ -674,17 +671,18 @@ jobs:
ruby: ["3.1"]
runs-on: windows-2022
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: ruby/setup-ruby@v1
with:
ruby-version: "${{matrix.ruby}}"
- uses: actions/download-artifact@v3
with:
name: cruby-x64-mingw-ucrt-gem
path: gems
- run: |
gem install --verbose --no-document gems/*.gem
gem list -d nokogiri
nokogiri -v
- run: ./scripts/test-gem-install gems
shell: bash

jruby-package:
needs: ["rcd_image_version"]
Expand Down
16 changes: 8 additions & 8 deletions lib/nokogiri/version/info.rb
Expand Up @@ -105,16 +105,16 @@ def to_hash
if libxml2_using_packaged?
cppflags << "-I#{File.join(header_directory, "include").shellescape}"
cppflags << "-I#{File.join(header_directory, "include/libxml2").shellescape}"
end

if windows?
# on windows, nokogumbo needs to link against nokogiri.so to resolve symbols. see #2167
lib_directory = File.expand_path(File.join(File.dirname(__FILE__), "../#{ruby_minor}"))
unless File.exist?(lib_directory)
lib_directory = File.expand_path(File.join(File.dirname(__FILE__), ".."))
end
ldflags << "-L#{lib_directory.shellescape}"
ldflags << "-l:nokogiri.so"
if windows?
# on windows, nokogumbo needs to link against nokogiri.so to resolve symbols. see #2167
lib_directory = File.expand_path(File.join(File.dirname(__FILE__), "../#{ruby_minor}"))
unless File.exist?(lib_directory)
lib_directory = File.expand_path(File.join(File.dirname(__FILE__), ".."))
end
ldflags << "-L#{lib_directory.shellescape}"
ldflags << "-l:nokogiri.so"
end

nokogiri["cppflags"] = cppflags
Expand Down
2 changes: 1 addition & 1 deletion scripts/test-gem-installation
Expand Up @@ -115,7 +115,7 @@ describe gemspec.full_name do
it "has ldflags pointing to the shared object file" do
ldflags = Nokogiri::VERSION_INFO["nokogiri"]["ldflags"]
if ::RUBY_PLATFORM.match?(/mingw|mswin/)
if gemspec.platform.cpu
if gemspec.platform.is_a?(Gem::Platform) && gemspec.platform.cpu
assert_includes(ldflags, "-L#{File.join(nokogiri_lib_dir, ruby_maj_min)}")
else
assert_includes(ldflags, "-L#{nokogiri_lib_dir}")
Expand Down
14 changes: 10 additions & 4 deletions scripts/test-nokogumbo-compatibility
Expand Up @@ -20,6 +20,16 @@ if Gem::Requirement.new(">= 3.2.0").satisfied_by?(Gem::Version.new(RUBY_VERSION)
exit 0
end

nokogumbo_version = if /\d+\.\d+\.\d+/.match?(ARGV[0])
ARGV[0]
end

NOKOGUMBO_WINDOWS_CONSTRAINT = ">= 2.0.5"
if Gem.win_platform? && !Gem::Requirement.new(NOKOGUMBO_WINDOWS_CONSTRAINT).satisfied_by?(Gem::Version.new(nokogumbo_version))
puts "Skip: Nokogumbo must be #{NOKOGUMBO_WINDOWS_CONSTRAINT} on Windows"
exit 0
end

# this line needs to come before the bundler bit, to assert that we're running against an
# already-installed version (and not some other version that bundler/inline might install if it came
# first)
Expand All @@ -28,10 +38,6 @@ raise "could not find installed gem" unless gemspec

require "bundler/inline"

nokogumbo_version = if /\d+\.\d+\.\d+/.match?(ARGV[0])
ARGV[0]
end

gemfile(true) do
source "https://rubygems.org"
gem "minitest"
Expand Down

0 comments on commit e9bafd0

Please sign in to comment.