Skip to content

Commit 9c3d118

Browse files
authored
Green CI PoC (#833)
Cherry-picked commits from #830, #831, #832, #835, #837 and #839.
1 parent 65e2114 commit 9c3d118

File tree

9 files changed

+46
-43
lines changed

9 files changed

+46
-43
lines changed

.github/workflows/lint.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212

1313
steps:
14-
- uses: actions/checkout@v2
14+
- uses: actions/checkout@v4
1515

1616
- name: Set up Ruby
1717
uses: ruby/setup-ruby@v1

.github/workflows/tests.yml

+12-17
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,20 @@ jobs:
1414
fail-fast: false
1515
matrix:
1616
ruby-version:
17-
- '2.6'
18-
- '2.7'
19-
- '3.0'
20-
- '3.1'
21-
- '3.2'
17+
- "2.6"
18+
- "2.7"
19+
- "3.0"
20+
- "3.1"
21+
- "3.2"
2222
os:
2323
- ubuntu
24-
- windows
25-
26-
# Tempfile behavior has changed on Ruby 3.1 such that tests
27-
# fail with permission denied. Would welcome a PR with a fix.
28-
exclude:
29-
- ruby-version: '3.1'
30-
os: windows
31-
- ruby-version: '3.2'
32-
os: windows
24+
# At the moment of this commit various specs fail on Windows.
25+
# Any contributor is welcome to fix them and enable the Windows build.
26+
# Please see Issue #836 for more details.
27+
# - windows
3328

3429
steps:
35-
- uses: actions/checkout@v2
30+
- uses: actions/checkout@v4
3631

3732
- name: Set up Ruby ${{ matrix.ruby-version }}
3833
uses: ruby/setup-ruby@v1
@@ -47,7 +42,7 @@ jobs:
4742
bundle exec rspec
4843
4944
- name: Code coverage reporting
50-
uses: coverallsapp/github-action@master
45+
uses: coverallsapp/github-action@v2
5146
with:
5247
github-token: ${{ secrets.github_token }}
5348
flag-name: ruby${{ matrix.ruby-version }}-${{ matrix.os }}
@@ -59,7 +54,7 @@ jobs:
5954

6055
steps:
6156
- name: Finalize code coverage report
62-
uses: coverallsapp/github-action@master
57+
uses: coverallsapp/github-action@v2
6358
with:
6459
github-token: ${{ secrets.github_token }}
6560
parallel-finished: true

Gemfile

+5-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ gem 'simplecov', '~> 0.21.0'
1212
gem 'simplecov-lcov', '~> 0.8.0'
1313

1414
# Pin RuboCop for CI builds
15-
gem 'rubocop', '1.59.0'
15+
if RUBY_VERSION < '2.7.0'
16+
gem 'rubocop', '1.50.0'
17+
else
18+
gem 'rubocop', '1.59.0'
19+
end
1620

1721
gem 'ffi' if Gem.win_platform?

lib/overcommit/hook/pre_commit/rails_schema_up_to_date.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def schema_files
5353
end
5454

5555
def schema
56-
@schema ||= schema_files.map { |file| File.read(file, encoding) }.join
56+
@schema ||= schema_files.map { |file| File.read(file, **(encoding || {})) }.join
5757
@schema.tr('_', '')
5858
end
5959

spec/overcommit/git_repo_spec.rb

+12-8
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@
2424
end
2525

2626
submodule = repo do
27-
`git submodule add #{nested_submodule} nested-sub 2>&1 > #{File::NULL}`
27+
`git -c protocol.file.allow=always submodule add \
28+
#{nested_submodule} nested-sub 2>&1 > #{File::NULL}`
2829
`git commit -m "Add nested submodule"`
2930
end
3031

3132
repo do
32-
`git submodule add #{submodule} sub 2>&1 > #{File::NULL}`
33+
`git -c protocol.file.allow=always submodule add #{submodule} sub 2>&1 > #{File::NULL}`
3334
example.run
3435
end
3536
end
@@ -150,7 +151,7 @@
150151
end
151152

152153
before do
153-
`git submodule add #{submodule} sub 2>&1 > #{File::NULL}`
154+
`git -c protocol.file.allow=always submodule add #{submodule} sub 2>&1 > #{File::NULL}`
154155
end
155156

156157
it { should_not include File.expand_path('sub') }
@@ -178,7 +179,8 @@
178179
`git commit --allow-empty -m "Submodule commit"`
179180
end
180181

181-
`git submodule add #{submodule} #{submodule_dir} 2>&1 > #{File::NULL}`
182+
`git -c protocol.file.allow=always submodule add \
183+
#{submodule} #{submodule_dir} 2>&1 > #{File::NULL}`
182184
`git commit -m "Add submodule"`
183185
end
184186

@@ -282,7 +284,7 @@
282284
touch 'tracked'
283285
`git add tracked`
284286
`git commit -m "Initial commit"`
285-
`git submodule add #{submodule} sub 2>&1 > #{File::NULL}`
287+
`git -c protocol.file.allow=always submodule add #{submodule} sub 2>&1 > #{File::NULL}`
286288
touch 'staged'
287289
`git add staged`
288290
example.run
@@ -327,7 +329,7 @@
327329
end
328330

329331
repo do
330-
`git submodule add #{submodule} sub-repo 2>&1 > #{File::NULL}`
332+
`git -c protocol.file.allow=always submodule add #{submodule} sub-repo 2>&1 > #{File::NULL}`
331333
`git commit -m "Initial commit"`
332334
example.run
333335
end
@@ -343,7 +345,8 @@
343345
`git commit --allow-empty -m "Another submodule"`
344346
end
345347

346-
`git submodule add #{another_submodule} another-sub-repo 2>&1 > #{File::NULL}`
348+
`git -c protocol.file.allow=always submodule add \
349+
#{another_submodule} another-sub-repo 2>&1 > #{File::NULL}`
347350
end
348351

349352
it { should be_empty }
@@ -369,7 +372,8 @@
369372
`git commit --allow-empty -m "Another submodule"`
370373
end
371374

372-
`git submodule add #{another_submodule} yet-another-sub-repo 2>&1 > #{File::NULL}`
375+
`git -c protocol.file.allow=always submodule add \
376+
#{another_submodule} yet-another-sub-repo 2>&1 > #{File::NULL}`
373377
`git commit -m "Add yet another submodule"`
374378
`git rm sub-repo`
375379
`git rm yet-another-sub-repo`

spec/overcommit/hook/prepare_commit_msg/base_spec.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@
3838
contents + "bravo\n"
3939
end
4040
end
41-
Thread.new { hook_1.run }
42-
Thread.new { hook_2.run }
43-
Thread.list.each { |t| t.join unless t == Thread.current }
41+
t1 = Thread.new { hook_1.run }
42+
t2 = Thread.new { hook_2.run }
43+
[t1, t2].each(&:join)
4444
expect(File.read(tempfile)).to match(/alpha\n#{initial_content}bravo\n/m)
4545
end
4646
end

spec/overcommit/hook_context/commit_msg_spec.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@
298298
end
299299

300300
repo do
301-
`git submodule add #{submodule} sub > #{File::NULL} 2>&1`
301+
`git -c protocol.file.allow=always submodule add #{submodule} sub > #{File::NULL} 2>&1`
302302
`git commit -m "Add submodule"`
303303
echo('Hello World', 'sub/submodule-file')
304304
`git submodule foreach "git add submodule-file" < #{File::NULL}`
@@ -474,7 +474,7 @@
474474
end
475475

476476
repo do
477-
`git submodule add #{submodule} sub > #{File::NULL} 2>&1`
477+
`git -c protocol.file.allow=always submodule add #{submodule} sub > #{File::NULL} 2>&1`
478478
`git commit -m "Add submodule"`
479479
echo('Hello World', 'sub/submodule-file')
480480
`git submodule foreach "git add submodule-file" < #{File::NULL}`
@@ -500,7 +500,7 @@
500500
end
501501

502502
repo do
503-
`git submodule add #{submodule} sub > #{File::NULL} 2>&1`
503+
`git -c protocol.file.allow=always submodule add #{submodule} sub > #{File::NULL} 2>&1`
504504
`git commit -m "Add submodule"`
505505
echo('Hello World', 'sub/submodule-file')
506506
`git submodule foreach "git add submodule-file" < #{File::NULL}`
@@ -532,7 +532,7 @@
532532
end
533533

534534
repo do
535-
`git submodule add #{submodule} sub > #{File::NULL} 2>&1`
535+
`git -c protocol.file.allow=always submodule add #{submodule} sub > #{File::NULL} 2>&1`
536536
`git commit -m "Add submodule"`
537537
`git rm sub`
538538
example.run
@@ -561,7 +561,7 @@
561561
end
562562

563563
repo do
564-
`git submodule add #{submodule} test-sub 2>&1 > #{File::NULL}`
564+
`git -c protocol.file.allow=always submodule add #{submodule} test-sub 2>&1 > #{File::NULL}`
565565
expect(subject).to_not include File.expand_path('test-sub')
566566
end
567567
end

spec/overcommit/hook_context/pre_commit_spec.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@
207207
end
208208

209209
repo do
210-
`git submodule add #{submodule} sub > #{File::NULL} 2>&1`
210+
`git -c protocol.file.allow=always submodule add #{submodule} sub > #{File::NULL} 2>&1`
211211
`git commit -m "Add submodule"`
212212
echo('Hello World', 'sub/submodule-file')
213213
`git submodule foreach "git add submodule-file" < #{File::NULL}`
@@ -383,7 +383,7 @@
383383
end
384384

385385
repo do
386-
`git submodule add #{submodule} sub > #{File::NULL} 2>&1`
386+
`git -c protocol.file.allow=always submodule add #{submodule} sub > #{File::NULL} 2>&1`
387387
`git commit -m "Add submodule"`
388388
echo('Hello World', 'sub/submodule-file')
389389
`git submodule foreach "git add submodule-file" < #{File::NULL}`
@@ -409,7 +409,7 @@
409409
end
410410

411411
repo do
412-
`git submodule add #{submodule} sub > #{File::NULL} 2>&1`
412+
`git -c protocol.file.allow=always submodule add #{submodule} sub > #{File::NULL} 2>&1`
413413
`git commit -m "Add submodule"`
414414
echo('Hello World', 'sub/submodule-file')
415415
`git submodule foreach "git add submodule-file" < #{File::NULL}`
@@ -441,7 +441,7 @@
441441
end
442442

443443
repo do
444-
`git submodule add #{submodule} sub > #{File::NULL} 2>&1`
444+
`git -c protocol.file.allow=always submodule add #{submodule} sub > #{File::NULL} 2>&1`
445445
`git commit -m "Add submodule"`
446446
`git rm sub`
447447
example.run
@@ -470,7 +470,7 @@
470470
end
471471

472472
repo do
473-
`git submodule add #{submodule} test-sub 2>&1 > #{File::NULL}`
473+
`git -c protocol.file.allow=always submodule add #{submodule} test-sub 2>&1 > #{File::NULL}`
474474
expect(subject).to_not include File.expand_path('test-sub')
475475
end
476476
end

spec/overcommit/installer_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ def hook_files_installed?(hooks_dir)
231231
context 'which has an external git dir' do
232232
let(:submodule) { File.join(target, 'submodule') }
233233
before do
234-
system 'git', 'submodule', 'add', target, 'submodule',
235-
chdir: target, out: :close, err: :close
234+
system 'git', '-c', 'protocol.file.allow=always', 'submodule', 'add', target,
235+
'submodule', chdir: target, out: :close, err: :close
236236
end
237237
let(:submodule_git_file) { File.join(submodule, '.git') }
238238
let(:submodule_git_dir) do

0 commit comments

Comments
 (0)