-
Notifications
You must be signed in to change notification settings - Fork 0
96 lines (86 loc) · 2.78 KB
/
test_suite.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
name: Template test suite
on: [push]
jobs:
build:
runs-on: ubuntu-22.04
services:
mysql:
image: mysql:8.0.40
env:
MYSQL_ROOT_PASSWORD: password
ports:
- 3306
options:
--health-cmd="mysqladmin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=3
redis:
image: redis
ports:
- 6379/tcp
volumes:
- 'redis:/app/data'
options: --entrypoint redis-server
# strategy:
# fail-fast: false
# matrix:
# # Set N number of parallel jobs you want to run tests on.
# # Use higher number if you have slow tests to split them on more parallel jobs.
# # Remember to update ci_node_index below to 0..N-1
# ci_node_total: [2]
# # set N-1 indexes for parallel jobs
# # When you run 2 parallel jobs then first job will have index 0, the second job will have index 1 etc
# ci_node_index: [0, 1]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Set up Ruby version
uses: ruby/setup-ruby@v1
with:
ruby-version: .ruby-version
- name: Setup cache key and directory for gems cache
uses: actions/cache@v4
with:
path: vendor/bundle
key: ${{ runner.os }}-gem-use-ruby-${{ hashFiles('**/Gemfile.lock') }}
restore-keys:
${{ runner.os }}-gems-
- name: Bundle install
env:
RAILS_ENV: test
DATABASE_HOST: 127.0.0.1
DATABASE_PORT: ${{ job.services.mysql.ports[3306] }}
DATABASE_USERNAME: root
DATABASE_PASSWORD: password
run: |
cp config/database.yml.github-actions config/database.yml
gem install bundler --version 2.6.1
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
- name: Create DB
env:
RAILS_ENV: test
DATABASE_HOST: 127.0.0.1
DATABASE_PORT: ${{ job.services.mysql.ports[3306] }}
DATABASE_USERNAME: root
DATABASE_PASSWORD: password
run: |
bundle exec rails db:prepare
- name: Prepare assets
env:
RAILS_ENV: test
run: bundle exec rails test:prepare
- name: Run rails tests
env:
RAILS_ENV: test
RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
DATABASE_HOST: 127.0.0.1
DATABASE_PORT: ${{ job.services.mysql.ports[3306] }} # get randomly assigned published port
DATABASE_USERNAME: root
DATABASE_PASSWORD: password
REDIS_URL: redis://127.0.0.1:${{ job.services.redis.ports[6379] }}/0
run: |
bundle exec rails test