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

Add Github Action for code quality and unit test using rspec #1

Merged
merged 12 commits into from
Sep 7, 2021
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
24 changes: 24 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
RAILS_ENV=test
GMAIL_PASSWORD_DEV=midtrans1234
GMAIL_USERNAME_DEV=vision@veritrans.co.id
GOOGLE_API_KEY=697614417708-o2cl7lbhvp5jeejvli54lt780uk9dmbd.apps.googleusercontent.com
GOOGLE_API_SECRET=mXIFtnM7gYtHPAVqgDLfJQBN
USERNAME=vision@veritrans.co.id
PASSWORD=midtrans1234
TZ=Asia/Jakarta
SLACK_API_TOKEN=xoxb-388262484311-416876075360-4gULptPcRCry05uxSoGVXtsC
SLACK_VERIFICATION_TOKEN=K0k4kNBRgR5zAex6RA8V8SX7
DEPLOY_CALENDAR_ID=veritrans.co.id_u8h6tgnhgedrt0c2ognpe7q3q0@group.calendar.google.com
JIRA_URL=https://veritrans.atlassian.net/
JIRA_USERNAME=agile.tool@midtrans.com
JIRA_PASSWORD=Testing12
INCIDENT_LEVEL_GUIDELINE=https://drive.google.com/file/d/1i3SuJ85OmvIrzqzpYTzIPQzu3gAgS2no/preview
ENTITY_SOURCES=midtrans,spots,gojek
CONTACT_EMAIL=vision@veritrans.co.id
APPROVER_EMAIL=ika.muiz@midtrans.com
VALID_EMAIL=midtrans.com,veritrans.co.id,associate.midtrans.com,spots.co.id,go-jek.com
VISION_EMAIL=vision@midtrans.com
DB_HOST=localhost
DB_USERNAME=postgres
DB_PASSWORD=
DB_NAME=vision_test
89 changes: 89 additions & 0 deletions .github/workflows/code_quality_and_unit_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Code Quality and Unit Test

on:
pull_request:
branches: [ development ]

jobs:
code_quality:
name: Run Code Quality
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up Ruby
uses: ruby/setup-ruby@477b21f02be01bcb8030d50f37cfec92bfa615b6
with:
ruby-version: 2.4.5

- name: Install dependencies
run: bundle install

- name: Rubycritic (Static Analysis)
run: rubycritic -s 80.00 --no-browser app lib

- name: Rubocop (Code Quality)
run: bundle exec rubocop

# - name: Brakeman (Code Security) # TODO: ENABLED WHEN MIGRATE TO RAILS 5.2
# run: brakeman LANG="C" LC_ALL="en_US.UTF-8" .

unit_test:
name: Run Unit Test
runs-on: ubuntu-latest

services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
solr:
image: solr
ports:
- 8983:8983
mailcatcher:
image: tophfr/mailcatcher
ports:
- 1025:1025

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up Ruby
uses: ruby/setup-ruby@477b21f02be01bcb8030d50f37cfec92bfa615b6
with:
ruby-version: 2.4.5

- name: Setup node 12
uses: actions/setup-node@v2
with:
node-version: 12.x

- name: Install dependencies
run: |
bundle install
npm install
- name: Rspec (Unit Test)
run: |-
mv config/database.test.yml config/database.yml
# ./solr create_core -c test
RAILS_ENV=test bundle exec rake db:create
RAILS_ENV=test bundle exec rake db:migrate
RAILS_ENV=test bundle exec rspec --tty
env:
APPROVER_EMAIL: ika.muiz@midtrans.com
ENTITY_SOURCES: midtrans,spots,gojek
JIRA_URL: https://veritrans.atlassian.net/
JIRA_USERNAME: agile.tool@midtrans.com
JIRA_PASSWORD: Testing12
DB_PASSWORD: postgres
SLACK_IR_CHANNEL: midtrans-test,spots-test,gojek-test,anything
SLACK_CR_CHANNEL: midtrans-test,spots-test,gojek-test,anything
SOLR_HOSTNAME: localhost
SOLR_PORT: 8983
VALID_EMAIL: midtrans.com,veritrans.co.id,associate.midtrans.com,spots.co.id,go-jek.com,gmail.com
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ solr/development/*
solr/test/*
!solr/test/core.properties

/node_modules
/node_modules
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
gem 'cucumber-rails', require: false
gem 'dotenv-rails'
gem 'factory_girl_rails', '~> 4.2.1'
gem 'faker'
gem 'rspec-rails', '~> 3.5.2'
Expand All @@ -116,6 +117,7 @@ group :development, :test do

# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'rubocop', '~> 0.63.1', require: false
gem 'rubycritic', require: false
gem 'spring'
end

Expand Down
54 changes: 54 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ GEM
public_suffix (>= 2.0.2, < 4.0)
arel (6.0.4)
ast (2.4.0)
axiom-types (0.1.1)
descendants_tracker (~> 0.0.4)
ice_nine (~> 0.11.0)
thread_safe (~> 0.3, >= 0.3.1)
backports (3.12.0)
bcrypt (3.1.12)
binding_of_caller (0.8.0)
Expand All @@ -69,7 +73,11 @@ GEM
childprocess (0.9.0)
ffi (~> 1.0, >= 1.0.11)
cocoon (1.2.12)
codeclimate-engine-rb (0.4.1)
virtus (~> 1.0)
coderay (1.1.2)
coercible (1.0.0)
descendants_tracker (~> 0.0.1)
coffee-rails (4.1.1)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.1.x)
Expand Down Expand Up @@ -112,6 +120,8 @@ GEM
debug_inspector (0.0.3)
declarative (0.0.10)
declarative-option (0.1.0)
descendants_tracker (0.0.4)
thread_safe (~> 0.3, >= 0.3.1)
devise (4.2.1)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
Expand All @@ -122,6 +132,10 @@ GEM
diffy (3.3.0)
docile (1.3.1)
dotenv (2.7.6)
dotenv-rails (2.7.6)
dotenv (= 2.7.6)
railties (>= 3.2)
equalizer (0.0.11)
erubis (2.7.0)
exception_notification (4.3.0)
actionmailer (>= 4.0, < 6)
Expand All @@ -141,6 +155,15 @@ GEM
ffi (1.10.0)
figaro (1.1.1)
thor (~> 0.14)
flay (2.12.1)
erubis (~> 2.7.0)
path_expander (~> 1.0)
ruby_parser (~> 3.0)
sexp_processor (~> 4.0)
flog (4.6.4)
path_expander (~> 1.0)
ruby_parser (~> 3.1, > 3.1.0)
sexp_processor (~> 4.8)
foreman (0.82.0)
thor (~> 0.19.1)
fullcalendar-rails (3.9.0.0)
Expand Down Expand Up @@ -174,6 +197,7 @@ GEM
httpclient (2.8.3)
i18n (0.9.5)
concurrent-ruby (~> 1.0)
ice_nine (0.11.2)
jaro_winkler (1.5.2)
jbuilder (2.8.0)
activesupport (>= 4.2.0)
Expand Down Expand Up @@ -206,6 +230,7 @@ GEM
activerecord
kaminari-core (= 1.1.1)
kaminari-core (1.1.1)
kwalify (0.7.2)
launchy (2.4.3)
addressable (~> 2.3)
loofah (2.2.3)
Expand Down Expand Up @@ -258,6 +283,7 @@ GEM
parallel (1.13.0)
parser (2.6.0.0)
ast (~> 2.4.0)
path_expander (1.1.0)
pg (0.21.0)
powerpack (0.1.2)
pr_geohash (1.0.0)
Expand All @@ -267,6 +293,7 @@ GEM
pry-byebug (3.6.0)
byebug (~> 10.0)
pry (~> 0.10)
psych (3.1.0)
public_suffix (3.0.3)
puma (3.12.0)
rack (1.6.11)
Expand Down Expand Up @@ -312,6 +339,12 @@ GEM
rb-inotify (0.10.0)
ffi (~> 1.0)
rdoc (4.3.0)
reek (5.6.0)
codeclimate-engine-rb (~> 0.4.0)
kwalify (~> 0.7.0)
parser (>= 2.5.0.0, < 2.8, != 2.5.1.1)
psych (~> 3.1.0)
rainbow (>= 2.0, < 4.0)
regexp_parser (1.3.0)
representable (3.0.4)
declarative (< 0.1.0)
Expand Down Expand Up @@ -353,6 +386,18 @@ GEM
unicode-display_width (~> 1.4.0)
ruby-ole (1.2.12.1)
ruby-progressbar (1.10.0)
ruby_parser (3.17.0)
sexp_processor (~> 4.15, >= 4.15.1)
rubycritic (4.1.0)
flay (~> 2.8)
flog (~> 4.4)
launchy (= 2.4.3)
parser (~> 2.6.0)
rainbow (~> 3.0)
reek (~> 5.0, < 6.0)
ruby_parser (~> 3.8)
tty-which (~> 0.4.0)
virtus (~> 1.0)
rubyzip (1.2.2)
safe_yaml (1.0.4)
sanitize (5.0.0)
Expand All @@ -377,6 +422,7 @@ GEM
childprocess (~> 0.5)
rubyzip (~> 1.0)
websocket (~> 1.0)
sexp_processor (4.15.3)
shoulda-matchers (3.1.3)
activesupport (>= 4.0.0)
signet (0.11.0)
Expand Down Expand Up @@ -432,6 +478,7 @@ GEM
railties (>= 3.1.1)
to_xls-rails (1.3.1)
spreadsheet (>= 0.8.5)
tty-which (0.4.2)
turbolinks (2.5.4)
coffee-rails
tzinfo (1.2.5)
Expand All @@ -442,6 +489,11 @@ GEM
unicode-display_width (1.4.1)
unread (0.10.1)
activerecord (>= 3)
virtus (1.0.5)
axiom-types (~> 0.1)
coercible (~> 1.0)
descendants_tracker (~> 0.0, >= 0.0.3)
equalizer (~> 0.0, >= 0.0.9)
warden (1.2.7)
rack (>= 1.0)
web-console (2.3.0)
Expand Down Expand Up @@ -482,6 +534,7 @@ DEPENDENCIES
devise (~> 4.2.0)
diffy
dotenv (~> 2.7)
dotenv-rails
exception_notification
factory_girl_rails (~> 4.2.1)
faker
Expand Down Expand Up @@ -514,6 +567,7 @@ DEPENDENCIES
ransack
rspec-rails (~> 3.5.2)
rubocop (~> 0.63.1)
rubycritic
sanitize
sass-rails (~> 5.0)
sdoc (~> 0.4.0)
Expand Down
9 changes: 9 additions & 0 deletions config/database.test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<%= ENV['RAILS_ENV'] %>:
adapter: postgresql
encoding: utf8
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
host: <%= ENV.fetch("DB_HOST") { 'localhost' } %>
port: <%= ENV.fetch("DB_PORT") { "5432" } %>
database: vision_test
username: <%= ENV["DB_USERNAME"] %>
password: <%= ENV["DB_PASSWORD"] %>
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"postinstall": "bower install"
"postinstall": "bower install"
},
"repository": {
"type": "git",
Expand Down
Loading