forked from DMPRoadmap/roadmap
-
Notifications
You must be signed in to change notification settings - Fork 0
121 lines (100 loc) · 3.82 KB
/
postgres.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
name: Tests - PostgreSQL
on: [pull_request]
jobs:
postgresql:
runs-on: ubuntu-latest
services:
# Postgres installation
db:
image: postgres
env:
# Latest version of Postgres has increased security. We can use the default
# user/password in this testing scenario though so use the following env
# variable to bypass this changes:
# https://github.com/docker-library/postgres/issues/681
POSTGRES_HOST_AUTH_METHOD: trust
ports: ['5432:5432']
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
RAILS_ENV: test
DATABASE_URL: postgres://postgres:@localhost:5432/roadmap_test
steps:
# Checkout the repo
- uses: actions/checkout@v2
with:
fetch-depth: 1
- name: 'Install Postgresql Packages'
run: |
sudo apt-get update
sudo apt-get install libpq-dev
- name: 'Determine Ruby and Bundler Versions from Gemfile.lock'
run: |
echo "RUBY_VERSION=`cat ./Gemfile.lock | grep -A 1 'RUBY VERSION' | grep 'ruby' | grep -oE '[0-9]\.[0-9]'`" >> $GITHUB_ENV
echo "BUNDLER_VERSION=`cat ./Gemfile.lock | grep -A 1 'BUNDLED WITH' | grep -oE '[0-9]\.[0-9]'`" >> $GITHUB_ENV
# Install Ruby - using the version found in the Gemfile.lock
- name: 'Install Ruby'
uses: actions/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }}
# Copy all of the example configs over
- name: 'Setup Default Configuration'
run: |
# Make copies of all the example config files
cp config/database.yml.sample config/database.yml
cp config/initializers/contact_us.rb.example config/initializers/contact_us.rb
cp config/initializers/wicked_pdf.rb.example config/initializers/wicked_pdf.rb
# Try to retrieve the gems from the cache
- name: 'Cache Gems'
uses: actions/cache@v1
with:
path: vendor/bundle
key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gem-
- name: 'Bundle Install'
run: |
gem install bundler -v ${{ env.BUNDLER_VERSION }}
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3 --without mysql rollbar aws
- name: 'Setup Credentials'
run: |
# generate a default credential file and key
EDITOR='echo "$(cat config/credentials.yml.example)" >' bundle exec rails credentials:edit
# Try to retrieve the yarn JS dependencies from the cache
- name: 'Cache Yarn Packages'
uses: actions/cache@v1
with:
path: node_modules/
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-yarn-
${{ runner.os }}-
- name: 'Determine wkhtmltopdf location'
run: echo "WICKED_PDF_PATH=`bundle exec which wkhtmltopdf`" >> $GITHUB_ENV
- name: 'Yarn Install'
run: |
yarn install
- name: 'Setup Test DB'
run: bin/rails db:setup RAILS_ENV=test
- name: 'Migrate DB'
run: bin/rails db:migrate RAILS_ENV=test
- name: 'Compile Assets'
run: |
bin/rails webpacker:compile
bin/rails assets:precompile
- name: 'Run Karma Tests'
run: yarn test
- name: 'Run Rspec Unit and Functional Tests'
run: |
bin/rspec spec/models/ spec/policies/ spec/services/ spec/helpers/
bin/rspec spec/controllers/ spec/presenters/ spec/requests/ spec/views
bin/rspec spec/mixins/
# Integration Tests are only run if PR or Push is to master or development branches
- name: 'Run Integration Tests'
run: bin/rspec spec/features/