-
Notifications
You must be signed in to change notification settings - Fork 36
98 lines (87 loc) · 2.33 KB
/
rails-test.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
name: Rails Tests
on:
push:
branches:
- master
- develop
pull_request:
jobs:
build:
runs-on: ubuntu-latest
env:
DATABASE_HOST: 127.0.0.1
DATABASE_PORT: 5432
DATABASE_USERNAME: postgres
DATABASE_PASSWORD: postgres
RAILS_ENV: test
IMAGEMAGICK_SRC: 7.1.0-50.tar.gz
SLACK_API_TOKEN: xoxb-dummy
SLACK_MESSAGE_CHANNEL: '#test'
services:
db:
image: postgres:12
ports:
- 5432:5432
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: redis
ports:
- 6379/tcp
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- name: apt-get
run: |
sudo apt-get update -y
sudo apt-get -yqq install libpq-dev postgresql-client libfuse2
- name: check imagemagick
run: |
export PATH=${GITHUB_WORKSPACE}/vendor/imagemagick7/bin:${PATH}
which convert
convert -version
- name: Set up Ruby 3.0.6
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.0.6
bundler-cache: true
- name: setup Node
uses: actions/setup-node@v3
with:
node-version: 16.13.0
cache: 'yarn'
- name: install yarn
run: |
npm i -g yarn@1.22.15
yarn install --frozen-lockfile
- name: create assets precompile cache key
run: |
# use newest commit hash of precompile target files
git rev-parse $(git log --oneline -n 1 app/packs lib/assets Gemfile.lock yarn.lock | awk '{print $1}') > ASSETS_VERSION
- name: asset cache
uses: actions/cache@v3
with:
path: |
public/packs
public/assets
tmp/cache/assets
public/packs-test
key: asset-precompile-cache-${{ hashFiles('ASSETS_VERSION') }}
restore-keys: |
asset-precompile-cache-${{ hashFiles('ASSETS_VERSION') }}
asset-precompile-cache-
- name: Migrate DB
run: |
bundle exec rails db:create db:migrate
- name: Precompile assets
run: bundle exec rails assets:precompile
- name: Test with RSpec
run: |
bundle exec rails spec