Skip to content
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

ci: run bash scripts on windows runners #2659

Merged
merged 3 commits into from Nov 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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