-
Notifications
You must be signed in to change notification settings - Fork 1
100 lines (87 loc) · 2.75 KB
/
ruby.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
# 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
name: Ruby
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master", "develop" ]
permissions:
contents: read
jobs:
rubocop:
name: Rubocop
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.0.0
- name: rubocop
uses: reviewdog/action-rubocop@v2.6.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
rubocop_version: gemfile
reporter: github-pr-check
unit_tests:
name: Unit Tests
runs-on: ubuntu-latest
timeout-minutes: 10
services:
postgres:
image: postgres:14.9
env:
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports: ["5432:5432"]
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Ruby 3.0.2
id: ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.0.2
bundler-cache: true
- name: Install required package
run: |
sudo apt-get update
sudo apt-get -yqq install libpq-dev
- name: Create DB
env:
RACK_ENV: test
DATABASE_URL: postgres://postgres:postgres@127.0.0.1
run: |
cp database_template.yml config/database.yml
cp db/schema.rb db/schema.rb.bak
bundle exec rake db:migrate:reset
if ! cmp db/schema.rb db/schema.rb.bak >/dev/null 2>&1; then
echo 'Your db/schema.rb differs from the schema generated by the migrations.'
echo 'Use "DATABASE=migrations bundle exec rake db:migrate:reset" to regenerate the schema.'
diff db/schema.rb db/schema.rb.bak
exit 1
fi
- name: Run specs
run: |
cp config_template.yml config.yml
bundle exec rspec -f j -o tmp/rspec_results.json -f p
- name: RSpec Report
uses: SonicGarden/rspec-report-action@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
title: 'Unit tests'
json-path: tmp/rspec_results.json
if: always()