Skip to content

Commit

Permalink
Merge pull request #113 from bookmebus/112-ci-cd
Browse files Browse the repository at this point in the history
Close #112 add Github action
  • Loading branch information
channainfo authored Feb 14, 2023
2 parents 4252a88 + 7f13379 commit eb6b70d
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 22 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-ruby
name: Spree Vpago Gem

on:
pull_request:
branches:
- master
- develop
push:
branches:
- 112-ci-cd
jobs:
test:
runs-on: ubuntu-latest

services:
db:
image: postgres:12
env:
POSTGRES_HOST_AUTH_METHOD: trust
POSTGRES_USER: myuser
POSTGRES_PASSWORD: mypassword
POSTGRES_DB: test_db

ports: ["5432:5432"]
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v3

# - uses: borales/[email protected]
# with:
# cmd: install

- uses: ruby/setup-ruby@v1
with:
ruby-version: "2.7.6"

# bundle-cache might cause problem when upgrading ruby. Disable it when upgrading to solve the problem.
# bundler-cache: true

- name: Install dependencies
run: |
sudo apt-get -yqq install libpq-dev
gem install bundler
bundle install --jobs 4 --retry 3
- name: Quality
env:
DATABASE_URL: postgres://myuser:mypassword@localhost:5432/test_db
run: |
bundle exec rubocop
# TODO: fix no child process error
# - name: Security
# env:
# DATABASE_URL: postgres://myuser:mypassword@localhost:5432/test_db
# run: |
# bundle exec brakeman

- name: Run test
env:
DATABASE_URL: postgres://myuser:mypassword@localhost:5432/test_db
run: |
bundle exec rake
20 changes: 7 additions & 13 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
AllCops:
NewCops: enable
DisplayCopNames: true
TargetRubyVersion: 2.5
Include:
- '**/Gemfile'
- '**/Rakefile'
- '**/Appraisals'
- "**/Gemfile"
- "**/Rakefile"
- "**/Appraisals"
Exclude:
- 'spec/dummy/**/*'
- 'lib/generators/**/*'

Rails:
Enabled: true

Metrics/LineLength:
Max: 150

# DISABLED
- "spec/dummy/**/*"
- "lib/generators/**/*"
- "bin/**/*"

Style/Documentation:
Enabled: false
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ end
gem 'spree', github: 'spree/spree', branch: '4-2-stable'

group :development, :test do
gem 'brakeman'
gem 'rails-controller-testing'
end

Expand Down
16 changes: 10 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ GEM
autoprefixer-rails (>= 9.1.0)
popper_js (>= 1.14.3, < 2)
sassc-rails (>= 2.0.0)
brakeman (5.4.0)
builder (3.2.4)
byebug (11.1.3)
camertron-eprun (1.1.1)
Expand Down Expand Up @@ -307,7 +308,7 @@ GEM
kaminari-core (1.2.2)
launchy (2.5.0)
addressable (~> 2.7)
loofah (2.16.0)
loofah (2.19.1)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
Expand All @@ -317,7 +318,7 @@ GEM
method_source (1.0.0)
mini_magick (4.11.0)
mini_mime (1.1.2)
mini_portile2 (2.8.0)
mini_portile2 (2.8.1)
minitest (5.15.0)
monetize (1.12.0)
money (~> 6.12)
Expand All @@ -326,7 +327,7 @@ GEM
multi_json (1.15.0)
multipart-post (2.1.1)
nio4r (2.5.8)
nokogiri (1.13.3)
nokogiri (1.14.2)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
octokit (4.22.0)
Expand All @@ -337,6 +338,7 @@ GEM
activerecord (>= 5.1, < 7.1)
parser (3.1.1.0)
ast (~> 2.4.1)
pg (1.4.5)
popper_js (1.16.0)
premailer (1.15.0)
addressable
Expand All @@ -360,7 +362,7 @@ GEM
nio4r (~> 2.0)
rabl (0.15.0)
activesupport (>= 2.3.14)
racc (1.6.0)
racc (1.6.2)
rack (2.2.3)
rack-test (1.1.0)
rack (>= 1.0, < 3)
Expand All @@ -386,8 +388,8 @@ GEM
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.4.2)
loofah (~> 2.3)
rails-html-sanitizer (1.5.0)
loofah (~> 2.19, >= 2.19.1)
railties (6.1.5)
actionpack (= 6.1.5)
activesupport (= 6.1.5)
Expand Down Expand Up @@ -551,7 +553,9 @@ PLATFORMS
ruby

DEPENDENCIES
brakeman
byebug
pg
rails-controller-testing
spree!
spree_dev_tools
Expand Down
5 changes: 2 additions & 3 deletions spec/lib/vpago/payway/payment_status_marker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
updated_reason: 'manually-updated'
}

updated_by_user_at = Time.zone.now
allow(Time.zone).to receive(:now).and_return(updated_by_user_at)
old_updated_by_user_at = payment_source.updated_by_user_at

status_updater = Vpago::Payway::PaymentStatusMarker.new(payment, options)

Expand All @@ -30,7 +29,7 @@
expect(payment_source.payment_status).to eq 'success'
expect(payment_source.updated_by_user_id).to eq user.id
expect(payment_source.updated_reason).to eq 'manually-updated'
expect(payment_source.updated_by_user_at).to eq updated_by_user_at
expect(payment_source.updated_by_user_at).to_not eq old_updated_by_user_at
end
end

Expand Down
1 change: 1 addition & 0 deletions spree_vpago.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ Gem::Specification.new do |s|
s.add_development_dependency 'spree_dev_tools'
s.add_development_dependency 'byebug'
s.add_development_dependency 'sqlite3'
s.add_development_dependency 'pg'

end

0 comments on commit eb6b70d

Please sign in to comment.