Skip to content

Commit

Permalink
Separate tests workflows (#530)
Browse files Browse the repository at this point in the history
This commit create a separate workflow for each test:
	* rspec tests
	* lint
	* js_tests
  • Loading branch information
Yassa-hue committed Jul 28, 2023
1 parent 1b5ad34 commit ec78519
Show file tree
Hide file tree
Showing 4 changed files with 227 additions and 0 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/js_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# This workflow uses actions that are not certified by GitHub. They are
# provided by a third-party and are governed by separate terms of service,
# privacy policy, and support documentation.
#
# This workflow will install a prebuilt Ruby version, install dependencies, and
# run js tests.
name: "JS CI"
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
services:
postgres:
image: postgres:11-alpine
ports:
- "5432:5432"
env:
POSTGRES_DB: rails_test
POSTGRES_USER: rails
POSTGRES_PASSWORD: password
env:
RAILS_ENV: test
NODE_ENV: test
DATABASE_URL: "postgres://rails:password@localhost:5432/rails_test"
DRIVER: selenium_chrome
CHROME_BIN: /usr/bin/google-chrome
USE_COVERALLS: true
steps:
- name: Install Chrome
uses: browser-actions/setup-chrome@latest

- name: Check Chrome version
run: chrome --version

- name: Check Chrome version
run: google-chrome --version

- name: Set Display environment variable
run: "export DISPLAY=:99"

- name: Checkout code
uses: actions/checkout@v3

- name: Install Ruby and gems
uses: ruby/setup-ruby@0a29871fe2b0200a17a4497bae54fe5df0d973aa # v1.115.3
with:
bundler-cache: true

- name: Use Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Install Node Packages
run: npm install --legacy-peer-deps

- name: Set up database schema
run: bin/rails db:schema:load

- name: Build i18n libraries
run: bundle exec rake react_on_rails:locale

- name: Build shakapacker chunks
run: NODE_ENV=development bundle exec bin/shakapacker

- name: Run js tests with xvfb
uses: GabrielBB/xvfb-action@v1
with:
run: bundle exec rake ci_js_tests
working-directory: ./ #optional
options: ":99 -ac -screen scn 1600x1200x16"
51 changes: 51 additions & 0 deletions .github/workflows/lint_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# This workflow uses actions that are not certified by GitHub. They are
# provided by a third-party and are governed by separate terms of service,
# privacy policy, and support documentation.
#
# This workflow will install a prebuilt Ruby version, install dependencies, and
# run rspec tests.
name: "Lint CI"
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
env:
RAILS_ENV: test
NODE_ENV: test
steps:
- name: Set Display environment variable
run: "export DISPLAY=:99"

- name: Checkout code
uses: actions/checkout@v3

- name: Install Ruby and gems
uses: ruby/setup-ruby@0a29871fe2b0200a17a4497bae54fe5df0d973aa # v1.115.3
with:
bundler-cache: true

- name: Use Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Install Node Packages
run: npm install --legacy-peer-deps

- name: Build i18n libraries
run: bundle exec rake react_on_rails:locale

- name: Build shakapacker chunks
run: NODE_ENV=development bundle exec bin/shakapacker

- name: Run lint tests with xvfb
uses: GabrielBB/xvfb-action@v1
with:
run: bundle exec rake lint
working-directory: ./ #optional
options: ":99 -ac -screen scn 1600x1200x16"
76 changes: 76 additions & 0 deletions .github/workflows/rspec_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# This workflow uses actions that are not certified by GitHub. They are
# provided by a third-party and are governed by separate terms of service,
# privacy policy, and support documentation.
#
# This workflow will install a prebuilt Ruby version, install dependencies, and
# run rspec tests.
name: "rspec CI"
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
services:
postgres:
image: postgres:11-alpine
ports:
- "5432:5432"
env:
POSTGRES_DB: rails_test
POSTGRES_USER: rails
POSTGRES_PASSWORD: password
env:
RAILS_ENV: test
NODE_ENV: test
DATABASE_URL: "postgres://rails:password@localhost:5432/rails_test"
DRIVER: selenium_chrome
CHROME_BIN: /usr/bin/google-chrome
USE_COVERALLS: true
steps:
- name: Install Chrome
uses: browser-actions/setup-chrome@latest

- name: Check Chrome version
run: chrome --version

- name: Check Chrome version
run: google-chrome --version

- name: Set Display environment variable
run: "export DISPLAY=:99"

- name: Checkout code
uses: actions/checkout@v3

- name: Install Ruby and gems
uses: ruby/setup-ruby@0a29871fe2b0200a17a4497bae54fe5df0d973aa # v1.115.3
with:
bundler-cache: true

- name: Use Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Install Node Packages
run: npm install --legacy-peer-deps

- name: Set up database schema
run: bin/rails db:schema:load

- name: Build i18n libraries
run: bundle exec rake react_on_rails:locale

- name: Build shakapacker chunks
run: NODE_ENV=development bundle exec bin/shakapacker

- name: Run rspec tests with xvfb
uses: GabrielBB/xvfb-action@v1
with:
run: bundle exec rake ci_rspec_tests
working-directory: ./ #optional
options: ":99 -ac -screen scn 1600x1200x16"
24 changes: 24 additions & 0 deletions lib/tasks/ci.rake
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,30 @@ if Rails.env.development? || Rails.env.test?
sh "rspec"
end

desc "Run CI rspec tests"
task ci_rspec_tests: %i[environment rspec_tests] do
puts "CI rspec tests"
puts Rainbow("PASSED").green
puts ""
rescue StandardError => e
puts e.to_s
puts Rainbow("FAILED").red
puts ""
raise(e)
end

desc "Run CI js_tests"
task ci_js_tests: %i[environment js_tests] do
puts "CI js_tests"
puts Rainbow("PASSED").green
puts ""
rescue StandardError => e
puts e.to_s
puts Rainbow("FAILED").red
puts ""
raise(e)
end

namespace :ci do
desc "Run all audits and tests"
# rspec_tests must be before lint and js_tests to build the locale files
Expand Down

0 comments on commit ec78519

Please sign in to comment.