-
Notifications
You must be signed in to change notification settings - Fork 1
62 lines (60 loc) · 1.91 KB
/
ruby.yml
File metadata and controls
62 lines (60 loc) · 1.91 KB
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
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
# 参考: https://hai3.net/blog/rails-rspec-postgres-github-action/
name: Ruby
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
test:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'ci skip')"
services:
postgres:
image: postgres
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: my_database
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v2
- name: Setup Ruby
uses: ruby/setup-ruby@v1.51.1
with:
ruby-version: 2.7.2
- name: Cache gems
uses: actions/cache@v1
with:
path: vendor/bundle
key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gem-
- name: Install dependencies
run: |
gem install bundler
bundle install --path vendor/bundle --without production
- name: Set env
run: |
echo 'RAILS_ENV=test' >> $GITHUB_ENV
echo 'DATABASE_URL=postgres://postgres:postgres@localhost:5432/my_database' >> $GITHUB_ENV
echo 'REDIS_URL=redis://localhost:6379' >> $GITHUB_ENV
- name: setup DB
run: |
bundle exec rails db:schema:load
- name: Start Redis
uses: supercharge/redis-github-action@1.1.0
- name: Run tests
run: bundle exec rails test