Skip to content

Commit eb2b425

Browse files
MSP-Gregk0kubun
authored andcommitted
MinGW on Actions (#2791)
* MinGW - skip spec in spec/ruby/optional/capi/thread_spec.rb C-API Thread function rb_thread_call_without_gvl -- runs a C function with the global lock unlocked and unlocks IO with the generic RUBY_UBF_IO stops/freezes spec tests See https://bugs.ruby-lang.org/issues/16265 * MinGW - skip test test/resolv/test_dns.rb Test times out in CI (both AppVeyor & Actions), cannot repo locally * MinGW - skip test test/ruby/test_thread_queue.rb * Add Actions mingw.yml
1 parent 79c4202 commit eb2b425

File tree

4 files changed

+165
-17
lines changed

4 files changed

+165
-17
lines changed

.github/workflows/mingw.yml

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
name: Windows
2+
on:
3+
push:
4+
branches:
5+
- '*'
6+
pull_request:
7+
branches:
8+
- '*'
9+
10+
# Notes:
11+
# Action ENV TEMP and TMP are short 8.3 paths, but the long path differs.
12+
# Code uses TMPDIR, which is Ruby's 'first' check
13+
#
14+
# Console encoding causes issues, see test-all & test-spec steps
15+
#
16+
jobs:
17+
mingw:
18+
runs-on: windows-2019
19+
env:
20+
MSYSTEM: MINGW64
21+
MSYSTEM_PREFIX: /mingw64
22+
MSYS2_ARCH: x86_64
23+
CHOST: "x86_64-w64-mingw32"
24+
CFLAGS: "-march=x86-64 -mtune=generic -O3 -pipe -fstack-protector-strong"
25+
CXXFLAGS: "-march=x86-64 -mtune=generic -O3 -pipe"
26+
CPPFLAGS: "-D_FORTIFY_SOURCE=2 -D__USE_MINGW_ANSI_STDIO=1 -DFD_SETSIZE=2048"
27+
LDFLAGS: "-pipe -fstack-protector-strong"
28+
UPDATE_UNICODE: "UNICODE_FILES=. UNICODE_PROPERTY_FILES=. UNICODE_AUXILIARY_FILES=. UNICODE_EMOJI_FILES=."
29+
strategy:
30+
fail-fast: false
31+
if: "!contains(github.event.head_commit.message, '[ci skip]')"
32+
steps:
33+
- name: git config
34+
run: |
35+
git config --system core.autocrlf false
36+
git config --system core.eol lf
37+
- name: Checkout repo
38+
uses: actions/checkout@v2
39+
with:
40+
path: src
41+
- run: ./src/tool/actions-commit-info.sh
42+
shell: bash
43+
id: commit_info
44+
- name: Set up Ruby & MSYS2
45+
uses: MSP-Greg/actions-ruby@master
46+
with:
47+
ruby-version: 2.6.x
48+
base: update
49+
mingw: gdbm gmp libffi libyaml openssl ragel readline
50+
msys2: automake1.16 bison
51+
- name: where check
52+
run: |
53+
# show where
54+
Write-Host
55+
$where = 'gcc.exe', 'ragel.exe', 'make.exe', 'bison.exe', 'libcrypto-1_1-x64.dll', 'libssl-1_1-x64.dll'
56+
foreach ($e in $where) {
57+
$rslt = where.exe $e 2>&1 | Out-String
58+
if ($rslt.contains($e)) { Write-Host $rslt }
59+
else { Write-Host "`nCan't find $e" }
60+
}
61+
- name: misc setup, autoreconf
62+
run: |
63+
mkdir build
64+
mkdir install
65+
mkdir temp
66+
cd src
67+
sh -c "autoreconf -fi"
68+
69+
- name: configure
70+
run: |
71+
# Actions uses UTF8, causes test failures, similar to normal OS setup
72+
$PSDefaultParameterValues['*:Encoding'] = 'utf8'
73+
[Console]::OutputEncoding = [System.Text.Encoding]::GetEncoding("IBM437")
74+
[Console]::InputEncoding = [System.Text.Encoding]::GetEncoding("IBM437")
75+
cd build
76+
$config_args = "--build=$env:CHOST --host=$env:CHOST --target=$env:CHOST"
77+
Write-Host $config_args
78+
sh -c "../src/configure --disable-install-doc --prefix=/install $config_args"
79+
# Write-Host "-------------------------------------- config.log"
80+
# Get-Content ./config.log | foreach {Write-Output $_}
81+
82+
- name: download unicode, gems, etc
83+
run: |
84+
$jobs = [int]$env:NUMBER_OF_PROCESSORS + 1
85+
cd build
86+
make -j $jobs update-unicode
87+
make -j $jobs update-gems
88+
89+
- name: make compile
90+
timeout-minutes: 20
91+
run: |
92+
$jobs = [int]$env:NUMBER_OF_PROCESSORS + 1
93+
make -C build -j $jobs V=1
94+
95+
- name: make install
96+
run: |
97+
# Actions uses UTF8, causes test failures, similar to normal OS setup
98+
$PSDefaultParameterValues['*:Encoding'] = 'utf8'
99+
[Console]::OutputEncoding = [System.Text.Encoding]::GetEncoding("IBM437")
100+
[Console]::InputEncoding = [System.Text.Encoding]::GetEncoding("IBM437")
101+
make -C build DESTDIR=.. install-nodoc
102+
103+
- name: test
104+
timeout-minutes: 5
105+
run: |
106+
$env:TMPDIR = "$pwd/temp"
107+
make -C build test
108+
109+
- name: test-spec
110+
if: success() || failure()
111+
timeout-minutes: 10
112+
run: |
113+
$env:TMPDIR = "$pwd/temp"
114+
$env:PATH = "$pwd/install/bin;$env:PATH"
115+
# Actions uses UTF8, causes test failures, similar to normal OS setup
116+
$PSDefaultParameterValues['*:Encoding'] = 'utf8'
117+
[Console]::OutputEncoding = [System.Text.Encoding]::GetEncoding("IBM437")
118+
[Console]::InputEncoding = [System.Text.Encoding]::GetEncoding("IBM437")
119+
ruby -v
120+
cd src/spec/ruby
121+
ruby ../mspec/bin/mspec -j
122+
123+
- name: test-all
124+
if: success() || failure()
125+
timeout-minutes: 25
126+
run: |
127+
$env:TMPDIR = "$pwd/temp"
128+
# Actions uses UTF8, causes test failures, similar to normal OS setup
129+
$PSDefaultParameterValues['*:Encoding'] = 'utf8'
130+
[Console]::OutputEncoding = [System.Text.Encoding]::GetEncoding("IBM437")
131+
[Console]::InputEncoding = [System.Text.Encoding]::GetEncoding("IBM437")
132+
$jobs = [int]$env:NUMBER_OF_PROCESSORS
133+
make -C build test-all TESTOPTS="--retry --job-status=normal --show-skip --timeout-scale=1.5 --excludes=../src/test/excludes -n !/memory_leak/ -j $jobs"

spec/ruby/optional/capi/thread_spec.rb

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -121,23 +121,25 @@ def call_capi_rb_thread_wakeup
121121
thr.value.should be_true
122122
end
123123

124-
it "runs a C function with the global lock unlocked and unlocks IO with the generic RUBY_UBF_IO" do
125-
thr = Thread.new do
126-
@t.rb_thread_call_without_gvl_with_ubf_io
127-
end
124+
guard -> { platform_is :mingw and ruby_version_is ""..."2.7" } do
125+
it "runs a C function with the global lock unlocked and unlocks IO with the generic RUBY_UBF_IO" do
126+
thr = Thread.new do
127+
@t.rb_thread_call_without_gvl_with_ubf_io
128+
end
128129

129-
# Wait until it's blocking...
130-
Thread.pass while thr.status and thr.status != "sleep"
130+
# Wait until it's blocking...
131+
Thread.pass while thr.status and thr.status != "sleep"
131132

132-
# The thread status is set to sleep by rb_thread_call_without_gvl(),
133-
# but the thread might not be in the blocking read(2) yet, so wait a bit.
134-
sleep 0.1
133+
# The thread status is set to sleep by rb_thread_call_without_gvl(),
134+
# but the thread might not be in the blocking read(2) yet, so wait a bit.
135+
sleep 0.1
135136

136-
# Wake it up, causing the unblock function to be run.
137-
thr.wakeup
137+
# Wake it up, causing the unblock function to be run.
138+
thr.wakeup
138139

139-
# Make sure it stopped and we got a proper value
140-
thr.value.should be_true
140+
# Make sure it stopped and we got a proper value
141+
thr.value.should be_true
142+
end
141143
end
142144
end
143145
end

test/resolv/test_dns.rb

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,19 @@ def test_no_server
162162
# A race condition here.
163163
# Another program may use the port.
164164
# But no way to prevent it.
165-
Timeout.timeout(5) do
166-
Resolv::DNS.open(:nameserver_port => [[host, port]]) {|dns|
167-
assert_equal([], dns.getresources("test-no-server.example.org", Resolv::DNS::Resource::IN::A))
168-
}
165+
begin
166+
Timeout.timeout(5) do
167+
Resolv::DNS.open(:nameserver_port => [[host, port]]) {|dns|
168+
assert_equal([], dns.getresources("test-no-server.example.org", Resolv::DNS::Resource::IN::A))
169+
}
170+
end
171+
rescue Timeout::Error
172+
if RUBY_PLATFORM.match?(/mingw/)
173+
# cannot repo locally
174+
skip 'Timeout Error on MinGW CI'
175+
else
176+
raise Timeout::Error
177+
end
169178
end
170179
end
171180

test/ruby/test_thread_queue.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,10 @@ def test_queue_with_trap
560560
if ENV['APPVEYOR'] == 'True' && RUBY_PLATFORM.match?(/mswin/)
561561
skip 'This test fails too often on AppVeyor vs140'
562562
end
563+
if RUBY_PLATFORM.match?(/mingw/)
564+
skip 'This test fails too often on MinGW'
565+
end
566+
563567
assert_in_out_err([], <<-INPUT, %w(INT INT exit), [])
564568
q = Queue.new
565569
trap(:INT){

0 commit comments

Comments
 (0)