-
Notifications
You must be signed in to change notification settings - Fork 16
154 lines (133 loc) · 3.35 KB
/
backend.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
name: backend
on:
push:
branches:
- main
- master
pull_request:
branches:
- main
- master
jobs:
changes:
runs-on: ubuntu-latest
outputs:
backend: ${{ steps.filter.outputs.backend }}
frontend: ${{ steps.filter.outputs.frontend }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
backend:
- 'backend/**'
- '.github/workflows/**'
frontend:
- 'frontend/**'
- '.github/workflows/**'
standardrb:
needs: changes
if: ${{ needs.changes.outputs.backend == 'true' }}
runs-on: ubuntu-latest
defaults:
run:
working-directory: backend
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
working-directory: backend
bundler-cache: true
- name: Build & Run
run: |
bundle exec standardrb
erb-lint:
needs: changes
if: ${{ needs.changes.outputs.backend == 'true' }}
runs-on: ubuntu-latest
defaults:
run:
working-directory: backend
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: ERB lint
run: |
gem install erb_lint
erblint --lint-all --autocorrect
rspec:
needs: changes
if: ${{ needs.changes.outputs.backend == 'true' }}
runs-on: ubuntu-latest
defaults:
run:
working-directory: backend
env:
MONGODB_HOST: localhost
MONGODB_PORT: 27017
POSTGRES_HOST: localhost
DATABASE_HOST: localhost
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_HOST_AUTH_METHOD: trust
POSTGRES_PORT: 5432
INTERCOM_SECRET: secret
BASE_URL: test.com
services:
redis:
image: redis:6.2.3-alpine
ports: ["6379:6379"]
options: --entrypoint redis-server
db:
image: postgres:12.8-alpine
env:
POSTGRES_PASSWORD: password
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- name: Install PostgreSQL client
run: |
sudo apt-get -yqq install libpq-dev
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
working-directory: backend
bundler-cache: true
- name: Start MongoDB
uses: supercharge/[email protected]
with:
mongodb-version: 4.4.9
- name: Load database schema
run: |
bundle exec rake db:create
bundle exec rake db:schema:load
- name: Run rspec
run: |
bundle exec rspec
brakeman:
name: Security Analysis
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
working-directory: backend
bundler-cache: true
- name: Brakeman
uses: reviewdog/action-brakeman@v2
with:
brakeman_version: gemfile
reporter: github-pr-review