Skip to content

Commit

Permalink
Fix Postgres Workflow (1/2)
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronskiba committed Jun 21, 2024
1 parent 4faa69b commit aa0508a
Showing 1 changed file with 13 additions and 44 deletions.
57 changes: 13 additions & 44 deletions .github/workflows/postgres.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Tests - PostgreSQL

on: [push, pull_request]
on: [pull_request]

jobs:
postgresql:
Expand All @@ -23,6 +23,7 @@ jobs:
--health-timeout 5s
--health-retries 5
# Define environment variables for Postgres and Rails
env:
RAILS_ENV: test
DATABASE_URL: postgres://postgres:@localhost:5432/roadmap_test
Expand All @@ -34,7 +35,7 @@ jobs:
# Install Ruby and run bundler
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.1.4'
ruby-version: '3.0'
bundler-cache: true

## - run: echo 'NODE_OPTIONS="--openssl-legacy-provider"' >> $GITHUB_ENV
Expand All @@ -43,87 +44,55 @@ jobs:
# Install Node
- uses: actions/setup-node@v3
with:
node-version: '16.6.0'
node-version: 18
cache: 'yarn'

# Install the Postgres developer packages
- 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: ruby/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
cp .env.postgresql .env
# Try to retrieve the gems from the cache
- name: 'Cache Gems'
uses: actions/[email protected]
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
# Stub out the Rails credentials file so that we can start the Rails app
- name: 'Setup Credentials'
run: |
# generate a default credential file and key
EDITOR='echo "$(cat config/credentials.yml.postgresql)" >' bundle exec rails credentials:edit
# Try to retrieve the yarn JS dependencies from the cache
- name: 'Cache Yarn Packages'
uses: actions/[email protected]
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 }}-
# Set the path to the wkhtmltopdf executable
- name: 'Determine wkhtmltopdf location'
run: echo "WICKED_PDF_PATH=`bundle exec which wkhtmltopdf`" >> $GITHUB_ENV

# Run yarn install for JS dependencies
- name: 'Yarn Install'
run: |
yarn install
# Initialize the DB
- name: 'Setup Test DB'
run: |
bundle exec rails db:setup RAILS_ENV=test
bundle exec rails db:migrate RAILS_ENV=test
# Prebuild the CSS, JS and image assets
- name: 'Compile Assets'
run: bundle exec rails assets:precompile

# Run the unit and functional tests
- name: 'Run Rspec Unit and Functional Tests'
run: |
bundle exec rspec spec/models/ spec/policies/ spec/services/ spec/helpers/
bundle exec rspec spec/controllers/ spec/presenters/ spec/requests/ spec/views
bundle exec rspec spec/mixins/
# Integration Tests are only run if PR or Push is to master or development branches
# Run the time consuming integration tests (using Chrome headless browser)
- name: 'Run Integration Tests'
run: bundle exec rspec spec/features/
run: bundle exec rspec spec/features/

0 comments on commit aa0508a

Please sign in to comment.