Skip to content

Commit 2071e41

Browse files
committed
👷 Add GitHub Actions
1 parent 951459d commit 2071e41

16 files changed

+382
-13
lines changed

.github/dependabot.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: bundler
4+
directory: "/"
5+
schedule:
6+
interval: "daily"
7+
open-pull-requests-limit: 10
8+
ignore:
9+
- dependency-name: "rubocop-lts"
10+
- package-ecosystem: "github-actions"
11+
directory: "/"
12+
schedule:
13+
interval: "daily"

.github/workflows/coverage.yml

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Ruby - Coverage
2+
3+
env:
4+
K_SOUP_COV_MIN_BRANCH: 71
5+
K_SOUP_COV_MIN_LINE: 89
6+
K_SOUP_COV_MIN_HARD: true
7+
K_SOUP_COV_DO: true
8+
K_SOUP_COV_COMMAND_NAME: "MiniTest Coverage"
9+
10+
on:
11+
push:
12+
branches:
13+
- 'main'
14+
tags:
15+
- '!*' # Do not execute on tags
16+
pull_request:
17+
branches:
18+
- '*'
19+
# Allow manually triggering the workflow.
20+
workflow_dispatch:
21+
22+
permissions:
23+
contents: read
24+
25+
# Cancels all previous workflow runs for the same branch that have not yet completed.
26+
concurrency:
27+
# The concurrency group contains the workflow name and the branch name.
28+
group: "${{ github.workflow }}-${{ github.ref }}"
29+
cancel-in-progress: true
30+
31+
jobs:
32+
test:
33+
name: Specs with Coverage - Ruby ${{ matrix.ruby }} ${{ matrix.name_extra || '' }}
34+
if: "!contains(github.event.commits[0].message, '[ci skip]') && !contains(github.event.commits[0].message, '[skip ci]')"
35+
env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
36+
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
37+
runs-on: ubuntu-latest
38+
strategy:
39+
matrix:
40+
rubygems:
41+
- latest
42+
bundler:
43+
- latest
44+
gemfile:
45+
- coverage
46+
ruby:
47+
- '3.1'
48+
49+
steps:
50+
- name: Checkout
51+
uses: actions/checkout@v4
52+
53+
- name: Setup Ruby & RubyGems
54+
uses: ruby/setup-ruby@v1
55+
with:
56+
ruby-version: "${{ matrix.ruby }}"
57+
rubygems: "${{ matrix.rubygems }}"
58+
bundler: "${{ matrix.bundler }}"
59+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
60+
61+
- name: Run tests
62+
run: bundle exec rake test
63+
64+
- name: Code Coverage Summary Report
65+
uses: irongut/[email protected]
66+
if: ${{ github.event_name == 'pull_request' }}
67+
with:
68+
filename: ./coverage/coverage.xml
69+
badge: true
70+
fail_below_min: true
71+
format: markdown
72+
hide_branch_rate: false
73+
hide_complexity: true
74+
indicators: true
75+
output: both
76+
thresholds: '93 82'
77+
continue-on-error: ${{ matrix.experimental != 'false' }}
78+
79+
- name: Add Coverage PR Comment
80+
uses: marocchino/sticky-pull-request-comment@v2
81+
if: ${{ github.event_name == 'pull_request' }}
82+
with:
83+
recreate: true
84+
path: code-coverage-results.md
85+
continue-on-error: ${{ matrix.experimental != 'false' }}

.github/workflows/heads.yml

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Ruby Heads Matrix
2+
3+
env:
4+
K_SOUP_COV_DO: false
5+
6+
on:
7+
push:
8+
branches:
9+
- 'main'
10+
tags:
11+
- '!*' # Do not execute on tags
12+
pull_request:
13+
branches:
14+
- '*'
15+
# Allow manually triggering the workflow.
16+
workflow_dispatch:
17+
18+
permissions:
19+
contents: read
20+
21+
# Cancels all previous workflow runs for the same branch that have not yet completed.
22+
concurrency:
23+
# The concurrency group contains the workflow name and the branch name.
24+
group: "${{ github.workflow }}-${{ github.ref }}"
25+
cancel-in-progress: true
26+
27+
jobs:
28+
test:
29+
name: Specs - Ruby ${{ matrix.ruby }} ${{ matrix.name_extra || '' }}
30+
if: "!contains(github.event.commits[0].message, '[ci skip]') && !contains(github.event.commits[0].message, '[skip ci]')"
31+
env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
32+
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
33+
runs-on: ubuntu-latest
34+
continue-on-error: ${{ matrix.experimental || endsWith(matrix.ruby, 'head') }}
35+
strategy:
36+
fail-fast: true
37+
matrix:
38+
rubygems:
39+
- latest
40+
bundler:
41+
- latest
42+
gemfile:
43+
- vanilla
44+
ruby:
45+
- head
46+
47+
steps:
48+
- name: Checkout
49+
uses: actions/checkout@v4
50+
51+
- name: Setup Ruby & RubyGems
52+
uses: ruby/setup-ruby@v1
53+
with:
54+
ruby-version: "${{ matrix.ruby }}"
55+
rubygems: "${{ matrix.rubygems }}"
56+
bundler: "${{ matrix.bundler }}"
57+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
58+
59+
- name: Run tests
60+
run: bundle exec rake test

.github/workflows/style.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Ruby - Style
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
tags:
8+
- '!*' # Do not execute on tags
9+
pull_request:
10+
branches:
11+
- '*'
12+
13+
jobs:
14+
rubocop:
15+
name: RuboCop
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
rubygems:
20+
- latest
21+
bundler:
22+
- latest
23+
gemfile:
24+
- style
25+
ruby:
26+
- "3.2"
27+
runs-on: ubuntu-latest
28+
continue-on-error: ${{ matrix.experimental || endsWith(matrix.ruby, 'head') }}
29+
env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
30+
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v4
34+
- name: Setup Ruby & RubyGems
35+
uses: ruby/setup-ruby@v1
36+
with:
37+
ruby-version: ${{ matrix.ruby }}
38+
rubygems: ${{ matrix.rubygems }}
39+
bundler: ${{ matrix.bundler }}
40+
bundler-cache: true
41+
- name: Run RuboCop
42+
run: bundle exec rake rubocop_gradual:check

.github/workflows/supported.yml

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Supported Ruby Matrix
2+
3+
env:
4+
K_SOUP_COV_DO: false
5+
6+
on:
7+
push:
8+
branches:
9+
- 'main'
10+
tags:
11+
- '!*' # Do not execute on tags
12+
pull_request:
13+
branches:
14+
- '*'
15+
# Allow manually triggering the workflow.
16+
workflow_dispatch:
17+
18+
permissions:
19+
contents: read
20+
21+
# Cancels all previous workflow runs for the same branch that have not yet completed.
22+
concurrency:
23+
# The concurrency group contains the workflow name and the branch name.
24+
group: "${{ github.workflow }}-${{ github.ref }}"
25+
cancel-in-progress: true
26+
27+
jobs:
28+
test:
29+
name: Specs - Ruby ${{ matrix.ruby }}${{ matrix.name_extra || '' }}
30+
if: "!contains(github.event.commits[0].message, '[ci skip]') && !contains(github.event.commits[0].message, '[skip ci]')"
31+
env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
32+
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
33+
runs-on: ubuntu-latest
34+
strategy:
35+
matrix:
36+
include:
37+
- ruby: "3.3"
38+
rubygems: latest
39+
bundler: latest
40+
gemfile: vanilla
41+
- ruby: "3.2"
42+
rubygems: latest
43+
bundler: latest
44+
gemfile: vanilla
45+
#- Ruby 3.1 tests are run by coverage.yml
46+
steps:
47+
- name: Checkout
48+
uses: actions/checkout@v4
49+
- name: Setup Ruby & RubyGems
50+
uses: ruby/setup-ruby@v1
51+
with:
52+
ruby-version: "${{ matrix.ruby }}"
53+
rubygems: "${{ matrix.rubygems }}"
54+
bundler: "${{ matrix.bundler }}"
55+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
56+
- name: Run tests
57+
run: bundle exec rake test

.github/workflows/unsupported.yml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Unsupported (EOL) Ruby Matrix
2+
3+
env:
4+
K_SOUP_COV_DO: false
5+
6+
on:
7+
push:
8+
branches:
9+
- 'main'
10+
tags:
11+
- '!*' # Do not execute on tags
12+
pull_request:
13+
branches:
14+
- '*'
15+
# Allow manually triggering the workflow.
16+
workflow_dispatch:
17+
18+
# Cancels all previous workflow runs for the same branch that have not yet completed.
19+
concurrency:
20+
# The concurrency group contains the workflow name and the branch name.
21+
group: "${{ github.workflow }}-${{ github.ref }}"
22+
cancel-in-progress: true
23+
24+
jobs:
25+
test:
26+
name: Specs - Ruby ${{ matrix.ruby }}${{ matrix.name_extra || '' }}
27+
if: "!contains(github.event.commits[0].message, '[ci skip]') && !contains(github.event.commits[0].message, '[skip ci]')"
28+
env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
29+
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
30+
strategy:
31+
fail-fast: false
32+
matrix:
33+
include:
34+
- ruby: "3.0"
35+
rubygems: "3.3.27"
36+
bundler: none
37+
gemfile: vanilla
38+
- ruby: "2.7"
39+
rubygems: "3.3.27"
40+
bundler: none
41+
gemfile: vanilla
42+
runs-on: ubuntu-20.04
43+
continue-on-error: ${{ matrix.experimental || endsWith(matrix.ruby, 'head') }}
44+
steps:
45+
- name: Checkout
46+
uses: actions/checkout@v4
47+
- name: Setup Ruby & RubyGems
48+
uses: ruby/setup-ruby@v1
49+
with:
50+
ruby-version: "${{ matrix.ruby }}"
51+
rubygems: "${{ matrix.rubygems }}"
52+
bundler: "${{ matrix.bundler }}"
53+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
54+
- name: Run tests
55+
run: bundle exec rake test

.rubocop_gradual.lock

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"bin/bundle:4028066867": [
3+
[64, 5, 20, "ThreadSafety/InstanceVariableInClassMethod: Avoid instance variables in class methods.", 2485198147]
4+
]
5+
}

.simplecov

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
require "kettle/soup/cover/config"
2+
3+
SimpleCov.start

bin/bundle

+5-5
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ m = Module.new do
3030
if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
3131
bundler_version = a
3232
end
33-
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
33+
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/o
3434
bundler_version = $1
3535
update_index = i
3636
end
@@ -56,7 +56,7 @@ m = Module.new do
5656
def lockfile_version
5757
return unless File.file?(lockfile)
5858
lockfile_contents = File.read(lockfile)
59-
return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
59+
return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/o
6060
Regexp.last_match(1)
6161
end
6262

@@ -83,15 +83,15 @@ m = Module.new do
8383

8484
def activate_bundler
8585
gem_error = activation_error_handling do
86-
gem "bundler", bundler_requirement
86+
gem("bundler", bundler_requirement)
8787
end
8888
return if gem_error.nil?
8989
require_error = activation_error_handling do
9090
require "bundler/version"
9191
end
9292
return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
93-
warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
94-
exit 42
93+
warn("Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`")
94+
exit(42)
9595
end
9696

9797
def activation_error_handling

gemfiles/coverage.gemfile

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
2+
3+
source "https://rubygems.org"
4+
5+
# Root Gemfile is only for local development only. It is not loaded on CI.
6+
# On CI we only need the gemspecs' dependencies (including development dependencies).
7+
# Exceptions, if any, will be found in gemfiles/*.gemfile
8+
gem "kettle-soup-cover", "~> 1.0", ">= 1.0.2"
9+
10+
gem "rots", github: "roman/rots"
11+
12+
gemspec path: "../"

gemfiles/style.gemfile

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
2+
3+
source "https://rubygems.org"
4+
5+
# Root Gemfile is only for local development only. It is not loaded on CI.
6+
# On CI we only need the gemspecs' dependencies (including development dependencies).
7+
# Exceptions, if any, will be found in gemfiles/*.gemfile
8+
gem "rubocop-packaging", "~> 0.5", ">= 0.5.2"
9+
10+
gemspec path: "../"

0 commit comments

Comments
 (0)