Skip to content

Commit

Permalink
chore: add linter and tests to the github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosgz committed Nov 21, 2024
1 parent d712326 commit 698fef9
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 31 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Build

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
rubocop:
name: "Rubocop"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.0"
bundler-cache: true
- name: Run rubocop
run: |
bundle exec rubocop --parallel
tests:
name: Tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ruby-version:
- "3.0"
- "3.1"
- "3.2"
- "3.3"
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Ruby and install gems
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true
- name: Install dependencies
run: bundle install --jobs 4 --retry 3
- name: Run tests
run: bundle exec rspec

1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ AllCops:
- "db/**/*"
- "tmp/**/*"
- "vendor/**/*"
- "spec/support/hooks/notification.rb" # I'll refactor this rspec matcher to allow use things like an_instance_of
NewCops: enable

RSpec/MultipleExpectations:
Expand Down
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruby 2.7.8
ruby 3.3.5
3 changes: 0 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

source "https://rubygems.org"

gem "puma"
gem "sqlite3"
gem "activesupport", "~> 6.0"
gem "nokogiri"
gem "webmock"
gem "aws-sdk-s3"
Expand Down
22 changes: 1 addition & 21 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ PATH
GEM
remote: https://rubygems.org/
specs:
activesupport (6.1.7.10)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
ast (2.4.2)
Expand Down Expand Up @@ -46,17 +40,12 @@ GEM
diff-lcs (1.5.1)
dotenv (2.8.1)
hashdiff (1.1.1)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
jmespath (1.6.2)
json (2.8.1)
language_server-protocol (3.17.0.3)
lint_roller (1.1.0)
method_source (1.1.0)
mini_portile2 (2.8.7)
minitest (5.25.1)
nio4r (2.7.4)
nokogiri (1.15.6-x86_64-linux)
nokogiri (1.16.7-x86_64-linux)
racc (~> 1.4)
parallel (1.26.3)
parser (3.3.6.0)
Expand All @@ -66,8 +55,6 @@ GEM
coderay (~> 1.1)
method_source (~> 1.0)
public_suffix (5.1.1)
puma (6.4.3)
nio4r (~> 2.0)
racc (1.8.1)
rack (3.1.8)
rainbow (3.1.1)
Expand Down Expand Up @@ -105,8 +92,6 @@ GEM
rubocop-rspec (3.2.0)
rubocop (~> 1.61)
ruby-progressbar (1.13.0)
sqlite3 (1.7.3)
mini_portile2 (~> 2.8.0)
standard (1.37.0)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.0)
Expand All @@ -121,8 +106,6 @@ GEM
rubocop-performance (~> 1.21.0)
thor (1.3.2)
timecop (0.9.10)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.6.0)
webmock (3.24.0)
addressable (>= 2.8.0)
Expand All @@ -134,18 +117,15 @@ PLATFORMS
x86_64-linux

DEPENDENCIES
activesupport (~> 6.0)
aws-sdk-s3
dotenv
nokogiri
pry
puma
rspec
rubocop
rubocop-performance
rubocop-rspec
site_maps!
sqlite3
standard
timecop
webmock
Expand Down
10 changes: 5 additions & 5 deletions spec/site_maps/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
subject(:generate!) { cli.generate }

it "enqueues all processes" do
runner = double("runner", enqueue_all: nil, run: nil)
runner = instance_double(SiteMaps::Runner, enqueue_all: nil, run: nil)
allow(SiteMaps).to receive(:generate).and_return(runner)

generate!
Expand All @@ -35,13 +35,13 @@
let(:processes) { "default,categories" }

it "enqueues the given processes" do
runner = double("runner", enqueue: nil, run: nil)
runner = instance_double(SiteMaps::Runner, enqueue: nil, run: nil)
allow(SiteMaps).to receive(:generate).and_return(runner)

generate!

expect(runner).to have_received(:enqueue).with(:default, {})
expect(runner).to have_received(:enqueue).with(:categories, {})
expect(runner).to have_received(:enqueue).with(:default, **{})
expect(runner).to have_received(:enqueue).with(:categories, **{})
expect(runner).to have_received(:run)
end
end
Expand All @@ -64,7 +64,7 @@
end

it "passes the options to the runner" do
runner = double("runner", enqueue: nil, run: nil)
runner = instance_double(SiteMaps::Runner, enqueue: nil, run: nil)
allow(SiteMaps).to receive(:generate).and_return(runner)

generate!
Expand Down
2 changes: 1 addition & 1 deletion spec/site_maps/railtie_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def application
end
end

RSpec.describe SiteMaps::Runner do
RSpec.describe "SiteMaps::Railtie" do
before do
stub_const("Rails", DummyRails)
allow(Kernel).to receive(:require).with("rails/railtie").and_return(true)
Expand Down

0 comments on commit 698fef9

Please sign in to comment.