-
Notifications
You must be signed in to change notification settings - Fork 7
159 lines (130 loc) · 3.92 KB
/
brain.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
155
156
157
158
name: brain
on:
push:
paths:
- brain/**
- .github/workflows/brain.yml
branches:
- main
pull_request:
paths:
- brain/**
- .github/workflows/brain.yml
branches:
- main
jobs:
test_ruby:
name: ruby tests
runs-on: ubuntu-latest
timeout-minutes: 20
services:
postgres:
image: postgres:12
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 5432:5432
# needed because the postgres container does not provide a healthcheck
# tmpfs makes DB faster by using RAM
options: >-
--mount type=tmpfs,destination=/var/lib/postgresql/data
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
RAILS_ENV: test
LEAGUEBOT_DB_HOST: localhost
LEAGUEBOT_DB_USER: postgres
LEAGUEBOT_DB_PASS: postgres
steps:
- uses: actions/checkout@v2
- name: set up ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
working-directory: brain
- name: set up db
run: bin/rails db:prepare
working-directory: brain
- name: run unit tests
run: bin/rspec --exclude-pattern "spec/features/**/*"
working-directory: brain
# not worth overhead of splitting feature specs out into separate job;
# unit tests take seconds. instead, defer feature spec setup which ensures
# speedy unit tests & avoids running feature tests if unit fails.
- name: set up chrome
uses: browser-actions/setup-chrome@latest
- name: set up chromedriver
uses: nanasess/setup-chromedriver@v2
- name: use node.js 16.x
uses: actions/setup-node@master
with:
node-version: 16.x
- name: cache packages
id: cache-packages
uses: actions/cache@v3
with:
path: brain/node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/yarn.lock') }}
- name: install packages
if: ${{ steps.cache-packages.outputs.cache-hit != 'true' }}
run: yarn install --frozen-lockfile --silent
working-directory: brain
- name: build assets
run: bin/rails assets:precompile
working-directory: brain
- name: run feature tests
run: bin/rspec spec/features
working-directory: brain
build_js:
name: build js
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: checkout
uses: actions/checkout@v2
- name: use node.js 16.x
uses: actions/setup-node@master
with:
node-version: 16.x
- name: cache packages
id: cache-packages
uses: actions/cache@v3
with:
path: brain/node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/yarn.lock') }}
- name: install packages
if: ${{ steps.cache-packages.outputs.cache-hit != 'true' }}
run: yarn install --frozen-lockfile --silent
working-directory: brain
test_js:
runs-on: ubuntu-latest
needs: build_js
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
step: [
{name: 'typecheck', command: 'typecheck'},
{name: 'lint', command: 'lint --quiet'},
{name: 'prettier', command: 'fmt:check'}
]
name: ${{ matrix.step.name }}
steps:
- name: checkout
uses: actions/checkout@v2
- name: use node.js 16.x
uses: actions/setup-node@master
with:
node-version: 16.x
- name: cache packages
uses: actions/cache@v3
with:
path: brain/node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/yarn.lock') }}
- name: ${{ matrix.step.name}}
run: yarn ${{ matrix.step.command }}
working-directory: brain