-
Notifications
You must be signed in to change notification settings - Fork 3
81 lines (81 loc) · 2.13 KB
/
rubyonrails-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# This workflow will download a prebuilt Ruby version, install dependencies, and run linters
env:
RUBY_VERSION: 3.2
MYSQL_HOST: 127.0.0.1
MYSQL_DB: orte_test
MYSQL_USER: root
MYSQL_PASSWORD: root
name: Linters & Rspec
on:
push:
branches:
- main
- feature*
pull_request:
branches:
- main
- feature*
jobs:
run-lint:
name: Rubocop & Brakeman
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Ruby and install gems
uses: ruby/setup-ruby@v1
with:
bundler: default
bundler-cache: true
- name: Install rubocop/brakeman
run: |
gem install rubocop
gem install brakeman
- name: Run security checks
run: |
bundle exec bundle audit --update
brakeman -q -w2
- name: Run linters
run: |
rubocop --parallel
run-rspec:
name: RSpec
needs: run-lint
runs-on: ubuntu-latest
services:
mysql:
image: mysql:5.7
env:
MYSQL_HOST: 127.0.0.1
MYSQL_DB: orte_test
MYSQL_USER: root
MYSQL_PASSWORD: root
MYSQL_ROOT_PASSWORD: root
ports:
- "3306:3306"
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
bundler: default
bundler-cache: true
- name: Start & setup MySQL server
run: |
sudo /etc/init.d/mysql start
mysql --version
mysql -uroot -h127.0.0.1 -proot -e 'CREATE DATABASE IF NOT EXISTS orte_test;'
mysql -uroot -h127.0.0.1 -proot -e "CREATE USER 'orte'@'localhost' IDENTIFIED BY 'orte00';"
mysql -uroot -h127.0.0.1 -proot -e "GRANT ALL PRIVILEGES ON orte_test.* TO 'orte'@'localhost';"
- name: Run tests
env:
RAILS_ENV: test
COVERAGE: true
run: |
bin/rails db:setup
bundler exec rspec spec
- name: Upload coverage results
uses: actions/upload-artifact@master
if: always()
with:
name: coverage-report
path: coverage