Skip to content

Commit ffe373b

Browse files
authored
github workflows (#1)
* rspec workflow * benchmark and rubocop workflows * gem build workflow * codeql workflow * fix rubocop workflow * rubocop-factory_bot * forgot rubocop config require * testing removal of rubocop action * basic rubocop workflow * exclude vendor/bundle * linting cleanup
1 parent 28c25ed commit ffe373b

File tree

12 files changed

+159
-45
lines changed

12 files changed

+159
-45
lines changed

.github/workflows/benchmark.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#
2+
# Github benchmark test workflow
3+
#
4+
name: CI Benchmark Test
5+
on: [pull_request]
6+
jobs:
7+
test:
8+
runs-on: ubuntu-latest
9+
strategy:
10+
matrix:
11+
ruby:
12+
- '3.2.0'
13+
services:
14+
redis:
15+
image: redis
16+
ports: ["6379:6379"]
17+
steps:
18+
- uses: actions/checkout@v4
19+
- uses: ruby/setup-ruby@v1
20+
with:
21+
ruby-version: ${{ matrix.ruby }}
22+
bundler-cache: true
23+
- name: Run benchmark tests
24+
run: bundle exec ruby benchmark.rb

.github/workflows/build.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#
2+
# Github ruby gem build workflow
3+
#
4+
name: CI Ruby Gem Build
5+
on: [pull_request]
6+
jobs:
7+
release-please:
8+
runs-on: ubuntu-latest
9+
strategy:
10+
matrix:
11+
ruby:
12+
- '3.2.0'
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: ruby/setup-ruby@v1
16+
with:
17+
ruby-version: ${{ matrix.ruby }}
18+
bundler-cache: true
19+
- name: Build Ruby Gem
20+
run: gem build *.gemspec
21+
# - name: publish gem
22+
# run: |
23+
# mkdir -p $HOME/.gem
24+
# touch $HOME/.gem/credentials
25+
# chmod 0600 $HOME/.gem/credentials
26+
# printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
27+
# gem push *.gem
28+
# env:
29+
# GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_AUTH_TOKEN }}

.github/workflows/codeql.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#
2+
# Github codeql analysis workflow
3+
#
4+
name: CI CodeQL Analysis
5+
on: [pull_request]
6+
jobs:
7+
analyze:
8+
name: Analyze
9+
runs-on: ubuntu-latest
10+
permissions:
11+
actions: read
12+
contents: read
13+
security-events: write
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
language: ['ruby']
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
- name: Initialize CodeQL
22+
uses: github/codeql-action/init@v3
23+
with:
24+
languages: ${{matrix.language}}
25+
- name: Perform CodeQL Analysis
26+
uses: github/codeql-action/analyze@v3

.github/workflows/main.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

.github/workflows/rspec.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#
2+
# Github rspec unit test workflow
3+
#
4+
name: CI RSpec Tests
5+
on: [pull_request]
6+
jobs:
7+
test:
8+
runs-on: ubuntu-latest
9+
strategy:
10+
matrix:
11+
ruby:
12+
- '3.2.0'
13+
services:
14+
redis:
15+
image: redis
16+
ports: ["6379:6379"]
17+
steps:
18+
- uses: actions/checkout@v4
19+
- uses: ruby/setup-ruby@v1
20+
with:
21+
ruby-version: ${{ matrix.ruby }}
22+
bundler-cache: true
23+
- name: Run unit tests
24+
run: bundle exec rspec

.github/workflows/rubocop.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#
2+
# Github rubocop linting workflow
3+
#
4+
name: CI Rubocop Linting
5+
on: [pull_request]
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
strategy:
10+
matrix:
11+
ruby:
12+
- '3.2.0'
13+
# steps:
14+
# - uses: actions/checkout@v2
15+
# - name: Rubocop Linter Action
16+
# uses: andrewmcodes/[email protected]
17+
# env:
18+
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
steps:
20+
- uses: actions/checkout@v4
21+
- uses: ruby/setup-ruby@v1
22+
with:
23+
ruby-version: ${{ matrix.ruby }}
24+
bundler-cache: true
25+
- name: Rubocop Linter Action
26+
run: |
27+
bundle exec rubocop \
28+
--parallel \
29+
--fail-level convention \
30+
--display-only-fail-level-offenses \
31+
--display-style-guide \
32+
--force-exclusion \
33+
--format progress \
34+
--format github

.rubocop.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
require:
22
- rubocop-rake
33
- rubocop-rspec
4+
- rubocop-factory_bot
45

56
AllCops:
67
NewCops: enable
7-
TargetRubyVersion: 3.1
8+
TargetRubyVersion: 3.2
89
Exclude:
910
- 'test.rb'
11+
- 'vendor/bundle/**/*'
1012

1113
Metrics/MethodLength:
1214
Enabled: false

Gemfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ source 'https://rubygems.org'
55
# Specify your gem's dependencies in redis_single_file.gemspec
66
gemspec
77

8+
gem 'benchmark', '~> 0.4.0'
9+
gem 'benchmark-ips', '~> 2.14.0'
10+
gem 'mock_redis', '~> 0.49.0'
811
gem 'pry', '~> 0.15.2'
912
gem 'rake', '~> 13.0'
1013
gem 'rspec', '~> 3.0'
1114
gem 'rubocop', '~> 1.21'
15+
gem 'rubocop-factory_bot', '~> 2.26.1'
1216
gem 'rubocop-rake', '~> 0.6.0'
1317
gem 'rubocop-rspec', '~> 3.4.0 '
14-
gem 'mock_redis', '~> 0.49.0'
15-
gem 'benchmark', '~> 0.4.0'
16-
gem 'benchmark-ips', '~> 2.14.0'

Gemfile.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ GEM
5858
unicode-display_width (>= 2.4.0, < 4.0)
5959
rubocop-ast (1.38.0)
6060
parser (>= 3.3.1.0)
61+
rubocop-factory_bot (2.26.1)
62+
rubocop (~> 1.61)
6163
rubocop-rake (0.6.0)
6264
rubocop (~> 1.0)
6365
rubocop-rspec (3.4.0)
@@ -80,6 +82,7 @@ DEPENDENCIES
8082
redis-single-file!
8183
rspec (~> 3.0)
8284
rubocop (~> 1.21)
85+
rubocop-factory_bot (~> 2.26.1)
8386
rubocop-rake (~> 0.6.0)
8487
rubocop-rspec (~> 3.4.0)
8588

benchmark.rb

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
require 'benchmark/ips'
44
require 'redis_single_file'
55

6-
scenario_1_semaphore = RedisSingleFile.new(name: :scenario_1)
7-
scenario_2_semaphore = RedisSingleFile.new(name: :scenario_2)
6+
scenario_1_semaphore = RedisSingleFile.new(name: :scenario1)
7+
scenario_2_semaphore = RedisSingleFile.new(name: :scenario2)
88

99
Benchmark.ips do |x|
1010
x.report('synchronize') do
@@ -18,20 +18,18 @@
1818
x.report('threaded (10x)') do
1919
threads = 10.times.map do
2020
Thread.new do
21-
scenario_3_semaphore = RedisSingleFile.new(name: :scenario_3)
21+
scenario_3_semaphore = RedisSingleFile.new(name: :scenario3)
2222
scenario_3_semaphore.synchronize { nil }
2323
end
2424
end
2525

26-
while threads.any?(&:alive?) do
27-
threads.each { _1.join(0.5) }
28-
end
26+
threads.each { _1.join(0.05) } while threads.any?(&:alive?)
2927
end
3028

3129
x.report('forked (10x)') do
3230
10.times.each do
3331
fork do
34-
scenario_4_semaphore = RedisSingleFile.new(name: :scenario_4)
32+
scenario_4_semaphore = RedisSingleFile.new(name: :scenario4)
3533
scenario_4_semaphore.synchronize { nil }
3634
end
3735
end

0 commit comments

Comments
 (0)