diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ed613820..61f27281 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,57 +1,53 @@ -name: CI -on: [pull_request] +# .github/workflows/ruby.yml +name: Ruby + +on: + push: + branches: [main] + pull_request: + branches: [main] + +env: + POSTGRES_DB: postgres + POSTGRES_USER: postgres + POSTGRES_PASSWORD: password + jobs: - build: + tests: + name: Tests runs-on: ubuntu-latest + services: postgres: image: postgres:12 - ports: - - 5432:5432 env: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + POSTGRES_PASSWORD: password + ports: ['5432:5432'] + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 steps: - - uses: actions/checkout@v1 + - name: Checkout code + uses: actions/checkout@v2 - - name: Setup Ruby and install gems + - name: Setup Ruby uses: ruby/setup-ruby@v1 with: + ruby-version: 3.2.2 bundler-cache: true - - name: Install dependent libraries - run: sudo apt-get install libpq-dev - - - name: Bundle install + - name: Install dependencies run: | - gem install bundler + sudo apt-get update && sudo apt-get -yqq install libpq-dev bundle install --jobs 4 --retry 3 - - - name: Install daisyui - run: npm i daisyui - - - name: Compile assets - run: bundle exec rake assets:precompile - - - name: Setup Database + - name: Run Tests + env: + RAILS_ENV: test + PGHOST: localhost + DISABLE_SPRING: 1 run: | - cp config/database.yml.github-actions config/database.yml - bundle exec rake db:create - bundle exec rake db:schema:load - env: - RAILS_ENV: test - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - - - name: Run RSpec - run: COVERAGE=true bundle exec rspec --require rails_helper - env: - RAILS_ENV: test - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - - - name: Simplecov Report - uses: aki77/simplecov-report-action@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} + cp config/database.ci.yml config/database.yml + bundle exec rails db:schema:load + bundle exec rspec --format progress diff --git a/config/database.ci.yml b/config/database.ci.yml new file mode 100644 index 00000000..c5ee5c9d --- /dev/null +++ b/config/database.ci.yml @@ -0,0 +1,8 @@ +# config/database.ci.yml +test: + adapter: postgresql + encoding: unicode + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + database: <%= ENV["POSTGRES_DB"] %> + username: <%= ENV['POSTGRES_USER'] %> + password: <%= ENV["POSTGRES_PASSWORD"] %> diff --git a/config/database.yml.github-actions b/config/database.yml.github-actions deleted file mode 100644 index ee9f7e08..00000000 --- a/config/database.yml.github-actions +++ /dev/null @@ -1,23 +0,0 @@ -default: &default - adapter: postgresql - encoding: unicode - database: <%= ENV['DATABASE_NAME'] %> - username: <%= ENV['DATABASE_USERNAME'] %> - password: <%= ENV['DATABASE_PASSWORD'] %> - port: <%= ENV['DATABASE_PORT'] || '5432' %> - host: <%= ENV['DATABASE_HOST'] %> - pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> - timeout: 5000 - -development: - <<: *default - database: solo_customer_template_development - -test: - <<: *default - database: solo_customer_template_test - -production: - <<: *default - database: solo_customer_template_production - url: <%= ENV['DATABASE_URL'] %>