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

Green CI PoC #833

Merged
merged 7 commits into from
Feb 24, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
Expand Down
29 changes: 12 additions & 17 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,20 @@ jobs:
fail-fast: false
matrix:
ruby-version:
- '2.6'
- '2.7'
- '3.0'
- '3.1'
- '3.2'
- "2.6"
- "2.7"
- "3.0"
- "3.1"
- "3.2"
os:
- ubuntu
- windows

# Tempfile behavior has changed on Ruby 3.1 such that tests
# fail with permission denied. Would welcome a PR with a fix.
exclude:
- ruby-version: '3.1'
os: windows
- ruby-version: '3.2'
os: windows
# At the moment of this commit various specs fail on Windows.
# Any contributor is welcome to fix them and enable the Windows build.
# Please see Issue #836 for more details.
# - windows

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up Ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@v1
Expand All @@ -47,7 +42,7 @@ jobs:
bundle exec rspec

- name: Code coverage reporting
uses: coverallsapp/github-action@master
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.github_token }}
flag-name: ruby${{ matrix.ruby-version }}-${{ matrix.os }}
Expand All @@ -59,7 +54,7 @@ jobs:

steps:
- name: Finalize code coverage report
uses: coverallsapp/github-action@master
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.github_token }}
parallel-finished: true
6 changes: 5 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ gem 'simplecov', '~> 0.21.0'
gem 'simplecov-lcov', '~> 0.8.0'

# Pin RuboCop for CI builds
gem 'rubocop', '1.59.0'
if RUBY_VERSION < '2.7.0'
gem 'rubocop', '1.50.0'
else
gem 'rubocop', '1.59.0'
end

gem 'ffi' if Gem.win_platform?
2 changes: 1 addition & 1 deletion lib/overcommit/hook/pre_commit/rails_schema_up_to_date.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def schema_files
end

def schema
@schema ||= schema_files.map { |file| File.read(file, encoding) }.join
@schema ||= schema_files.map { |file| File.read(file, **(encoding || {})) }.join
@schema.tr('_', '')
end

Expand Down
20 changes: 12 additions & 8 deletions spec/overcommit/git_repo_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@
end

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

repo do
`git submodule add #{submodule} sub 2>&1 > #{File::NULL}`
`git -c protocol.file.allow=always submodule add #{submodule} sub 2>&1 > #{File::NULL}`
example.run
end
end
Expand Down Expand Up @@ -150,7 +151,7 @@
end

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

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

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

Expand Down Expand Up @@ -282,7 +284,7 @@
touch 'tracked'
`git add tracked`
`git commit -m "Initial commit"`
`git submodule add #{submodule} sub 2>&1 > #{File::NULL}`
`git -c protocol.file.allow=always submodule add #{submodule} sub 2>&1 > #{File::NULL}`
touch 'staged'
`git add staged`
example.run
Expand Down Expand Up @@ -327,7 +329,7 @@
end

repo do
`git submodule add #{submodule} sub-repo 2>&1 > #{File::NULL}`
`git -c protocol.file.allow=always submodule add #{submodule} sub-repo 2>&1 > #{File::NULL}`
`git commit -m "Initial commit"`
example.run
end
Expand All @@ -343,7 +345,8 @@
`git commit --allow-empty -m "Another submodule"`
end

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

it { should be_empty }
Expand All @@ -369,7 +372,8 @@
`git commit --allow-empty -m "Another submodule"`
end

`git submodule add #{another_submodule} yet-another-sub-repo 2>&1 > #{File::NULL}`
`git -c protocol.file.allow=always submodule add \
#{another_submodule} yet-another-sub-repo 2>&1 > #{File::NULL}`
`git commit -m "Add yet another submodule"`
`git rm sub-repo`
`git rm yet-another-sub-repo`
Expand Down
6 changes: 3 additions & 3 deletions spec/overcommit/hook/prepare_commit_msg/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
contents + "bravo\n"
end
end
Thread.new { hook_1.run }
Thread.new { hook_2.run }
Thread.list.each { |t| t.join unless t == Thread.current }
t1 = Thread.new { hook_1.run }
t2 = Thread.new { hook_2.run }
[t1, t2].each(&:join)
expect(File.read(tempfile)).to match(/alpha\n#{initial_content}bravo\n/m)
end
end
Expand Down
10 changes: 5 additions & 5 deletions spec/overcommit/hook_context/commit_msg_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@
end

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

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

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

repo do
`git submodule add #{submodule} sub > #{File::NULL} 2>&1`
`git -c protocol.file.allow=always submodule add #{submodule} sub > #{File::NULL} 2>&1`
`git commit -m "Add submodule"`
`git rm sub`
example.run
Expand Down Expand Up @@ -561,7 +561,7 @@
end

repo do
`git submodule add #{submodule} test-sub 2>&1 > #{File::NULL}`
`git -c protocol.file.allow=always submodule add #{submodule} test-sub 2>&1 > #{File::NULL}`
expect(subject).to_not include File.expand_path('test-sub')
end
end
Expand Down
10 changes: 5 additions & 5 deletions spec/overcommit/hook_context/pre_commit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@
end

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

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

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

repo do
`git submodule add #{submodule} sub > #{File::NULL} 2>&1`
`git -c protocol.file.allow=always submodule add #{submodule} sub > #{File::NULL} 2>&1`
`git commit -m "Add submodule"`
`git rm sub`
example.run
Expand Down Expand Up @@ -470,7 +470,7 @@
end

repo do
`git submodule add #{submodule} test-sub 2>&1 > #{File::NULL}`
`git -c protocol.file.allow=always submodule add #{submodule} test-sub 2>&1 > #{File::NULL}`
expect(subject).to_not include File.expand_path('test-sub')
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/overcommit/installer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ def hook_files_installed?(hooks_dir)
context 'which has an external git dir' do
let(:submodule) { File.join(target, 'submodule') }
before do
system 'git', 'submodule', 'add', target, 'submodule',
chdir: target, out: :close, err: :close
system 'git', '-c', 'protocol.file.allow=always', 'submodule', 'add', target,
'submodule', chdir: target, out: :close, err: :close
end
let(:submodule_git_file) { File.join(submodule, '.git') }
let(:submodule_git_dir) do
Expand Down