23
23
--health-timeout 5s
24
24
--health-retries 5
25
25
26
+ # Define environment variables for Postgres and Rails
26
27
env :
27
28
RAILS_ENV : test
28
29
DATABASE_URL : postgres://postgres:@localhost:5432/roadmap_test
34
35
# Install Ruby and run bundler
35
36
- uses : ruby/setup-ruby@v1
36
37
with :
37
- ruby-version : ' 3.0 '
38
+ ruby-version : ' 3.1.4 '
38
39
bundler-cache : true
39
40
40
41
# # - run: echo 'NODE_OPTIONS="--openssl-legacy-provider"' >> $GITHUB_ENV
@@ -46,84 +47,52 @@ jobs:
46
47
node-version : ' 16.6.0'
47
48
cache : ' yarn'
48
49
50
+ # Install the Postgres developer packages
49
51
- name : ' Install Postgresql Packages'
50
52
run : |
51
53
sudo apt-get update
52
54
sudo apt-get install libpq-dev
53
55
54
- - name : ' Determine Ruby and Bundler Versions from Gemfile.lock'
55
- run : |
56
- echo "RUBY_VERSION=`cat ./Gemfile.lock | grep -A 1 'RUBY VERSION' | grep 'ruby' | grep -oE '[0-9]\.[0-9]'`" >> $GITHUB_ENV
57
- echo "BUNDLER_VERSION=`cat ./Gemfile.lock | grep -A 1 'BUNDLED WITH' | grep -oE '[0-9]\.[0-9]'`" >> $GITHUB_ENV
58
-
59
- # Install Ruby - using the version found in the Gemfile.lock
60
- - name : ' Install Ruby'
61
- uses : ruby/setup-ruby@v1
62
- with :
63
- ruby-version : ${{ env.RUBY_VERSION }}
64
-
65
56
# Copy all of the example configs over
66
57
- name : ' Setup Default Configuration'
67
58
run : |
68
- # Make copies of all the example config files
69
59
cp config/database.yml.sample config/database.yml
70
60
cp config/initializers/contact_us.rb.example config/initializers/contact_us.rb
71
61
cp config/initializers/wicked_pdf.rb.example config/initializers/wicked_pdf.rb
72
62
cp .env.postgresql .env
73
63
74
- # Try to retrieve the gems from the cache
75
- - name : ' Cache Gems'
76
- uses : actions/cache@v2.1.5
77
- with :
78
- path : vendor/bundle
79
- key : ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }}
80
- restore-keys : |
81
- ${{ runner.os }}-gem-
82
-
83
- - name : ' Bundle Install'
84
- run : |
85
- gem install bundler -v ${{ env.BUNDLER_VERSION }}
86
- bundle config path vendor/bundle
87
- bundle install --jobs 4 --retry 3 --without mysql rollbar aws
88
-
64
+ # Stub out the Rails credentials file so that we can start the Rails app
89
65
- name : ' Setup Credentials'
90
66
run : |
91
67
# generate a default credential file and key
92
68
EDITOR='echo "$(cat config/credentials.yml.postgresql)" >' bundle exec rails credentials:edit
93
69
94
- # Try to retrieve the yarn JS dependencies from the cache
95
- - name : ' Cache Yarn Packages'
96
- uses : actions/cache@v2.1.5
97
- with :
98
- path : node_modules/
99
- key : ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
100
- restore-keys : |
101
- ${{ runner.os }}-build-${{ env.cache-name }}-
102
- ${{ runner.os }}-build-
103
- ${{ runner.os }}-yarn-
104
- ${{ runner.os }}-
105
-
70
+ # Set the path to the wkhtmltopdf executable
106
71
- name : ' Determine wkhtmltopdf location'
107
72
run : echo "WICKED_PDF_PATH=`bundle exec which wkhtmltopdf`" >> $GITHUB_ENV
108
73
74
+ # Run yarn install for JS dependencies
109
75
- name : ' Yarn Install'
110
76
run : |
111
77
yarn install
112
78
79
+ # Initialize the DB
113
80
- name : ' Setup Test DB'
114
81
run : |
115
82
bundle exec rails db:setup RAILS_ENV=test
116
83
bundle exec rails db:migrate RAILS_ENV=test
117
84
85
+ # Prebuild the CSS, JS and image assets
118
86
- name : ' Compile Assets'
119
87
run : bundle exec rails assets:precompile
120
88
89
+ # Run the unit and functional tests
121
90
- name : ' Run Rspec Unit and Functional Tests'
122
91
run : |
123
92
bundle exec rspec spec/models/ spec/policies/ spec/services/ spec/helpers/
124
93
bundle exec rspec spec/controllers/ spec/presenters/ spec/requests/ spec/views
125
94
bundle exec rspec spec/mixins/
126
95
127
- # Integration Tests are only run if PR or Push is to master or development branches
96
+ # Run the time consuming integration tests (using Chrome headless browser)
128
97
- name : ' Run Integration Tests'
129
- run : bundle exec rspec spec/features/
98
+ run : bundle exec rspec spec/features/
0 commit comments