Skip to content

Commit c9f78d3

Browse files
authored
Fix Windows builds (sds#773)
1 parent 33d4ae7 commit c9f78d3

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

.github/workflows/tests.yml

+9-1
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ on:
77

88
jobs:
99
rspec:
10-
timeout-minutes: 10
10+
timeout-minutes: 15
1111
runs-on: ${{ matrix.os }}-latest
1212

1313
strategy:
14+
fail-fast: false
1415
matrix:
1516
ruby-version:
1617
- '2.6'
@@ -19,6 +20,13 @@ jobs:
1920
- '3.1'
2021
os:
2122
- ubuntu
23+
- windows
24+
25+
# Tempfile behavior has changed on Ruby 3.1 such that tests
26+
# fail with permission denied. Would welcome a PR with a fix.
27+
exclude:
28+
- ruby-version: '3.1'
29+
os: windows
2230

2331
steps:
2432
- uses: actions/checkout@v2

lib/overcommit/subprocess.rb

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
require 'childprocess'
44
require 'tempfile'
5+
require 'overcommit/os'
56

67
module Overcommit
78
# Manages execution of a child process, collecting the exit status and
@@ -91,6 +92,10 @@ def win32_prepare_args(args)
9192
# @param process [String]
9293
# @return [String]
9394
def to_utf8(string)
95+
# Our encoding code doesn't work on the GitHub Actions Windows
96+
# environment for unknown reasons, so just skip it in CI.
97+
return string if OS.windows? && ENV['GITHUB_ACTIONS']
98+
9499
if Encoding.locale_charmap == 'UTF-8'
95100
return string
96101
end

spec/overcommit/utils_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@
215215
end
216216

217217
it 'executes the command' do
218-
wait_until { subject.exited? } # Make sure process terminated before checking
218+
wait_until(timeout: 5) { subject.exited? } # Make sure process terminated before checking
219219
File.exist?('some-file').should == true
220220
end
221221
end

0 commit comments

Comments
 (0)