-
Notifications
You must be signed in to change notification settings - Fork 16
137 lines (117 loc) · 2.94 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
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@v2.3.4
- uses: dorny/paths-filter@v2
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@v2.3.4
- 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@v2.3.4
- 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@v2.3.4
- 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/mongodb-github-action@1.4.0
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