diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 02fabffdd0..445f5257da 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,28 +1,270 @@ -# 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: Build on: + workflow_dispatch: push: - branches: [ $default-branch ] - pull_request: - branches: [ $default-branch ] jobs: - test: - + test-models: runs-on: ubuntu-18.04 - + services: + postgres: + image: postgres:10 + ports: ["5432:5432"] + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + env: + POSTGRES_DB: open_food_network_test + POSTGRES_USER: ofn + POSTGRES_PASSWORD: f00d steps: - - uses: actions/checkout@v2 - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - bundler-cache: true # runs 'bundle install' and caches installed gems automatically - - name: Run tests - run: bundle exec rspec spec/queries + - uses: actions/checkout@v2 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true # runs 'bundle install' and caches installed gems automatically + + - uses: actions/setup-node@v2 + with: + node-version: '14.15.5' + + - name: Install JS dependencies + run: yarn install --frozen-lockfile + + - name: Set up application.yml + run: cp config/application.yml.example config/application.yml + + - name: Set up database + run: | + bundle exec rake db:create RAILS_ENV=test + bundle exec rake db:schema:load RAILS_ENV=test + + - name: Run tests + run: bundle exec rspec spec/models + + test-admin-features: + runs-on: ubuntu-18.04 + services: + postgres: + image: postgres:10 + ports: ["5432:5432"] + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + env: + POSTGRES_DB: open_food_network_test + POSTGRES_USER: ofn + POSTGRES_PASSWORD: f00d + steps: + - uses: actions/checkout@v2 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true # runs 'bundle install' and caches installed gems automatically + + - uses: actions/setup-node@v2 + with: + node-version: '14.15.5' + + - name: Install JS dependencies + run: yarn install --frozen-lockfile + + - name: Set up application.yml + run: cp config/application.yml.example config/application.yml + + - name: Set up database + run: | + bundle exec rake db:create RAILS_ENV=test + bundle exec rake db:schema:load RAILS_ENV=test + + - name: Run admin feature tests + run: bundle exec rspec spec/features/admin/*_spec.rb + + test-admin-features-folders: + runs-on: ubuntu-18.04 + services: + postgres: + image: postgres:10 + ports: ["5432:5432"] + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + env: + POSTGRES_DB: open_food_network_test + POSTGRES_USER: ofn + POSTGRES_PASSWORD: f00d + steps: + - uses: actions/checkout@v2 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true # runs 'bundle install' and caches installed gems automatically + + - uses: actions/setup-node@v2 + with: + node-version: '14.15.5' + + - name: Install JS dependencies + run: yarn install --frozen-lockfile + + - name: Set up application.yml + run: cp config/application.yml.example config/application.yml + + - name: Set up database + run: | + bundle exec rake db:create RAILS_ENV=test + bundle exec rake db:schema:load RAILS_ENV=test + + - name: Run admin feature tests + run: bundle exec rspec --pattern "spec/features/admin/*/*_spec.rb" + + test-consumer-features: + runs-on: ubuntu-18.04 + services: + postgres: + image: postgres:10 + ports: ["5432:5432"] + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + env: + POSTGRES_DB: open_food_network_test + POSTGRES_USER: ofn + POSTGRES_PASSWORD: f00d + steps: + - uses: actions/checkout@v2 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true # runs 'bundle install' and caches installed gems automatically + + - uses: actions/setup-node@v2 + with: + node-version: '14.15.5' + + - name: Install JS dependencies + run: yarn install --frozen-lockfile + + - name: Set up application.yml + run: cp config/application.yml.example config/application.yml + + - name: Set up database + run: | + bundle exec rake db:create RAILS_ENV=test + bundle exec rake db:schema:load RAILS_ENV=test + + - name: Run consumer feature tests + run: bundle exec rspec spec/features/consumer + + test-controllers: + runs-on: ubuntu-18.04 + services: + postgres: + image: postgres:10 + ports: ["5432:5432"] + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + env: + POSTGRES_DB: open_food_network_test + POSTGRES_USER: ofn + POSTGRES_PASSWORD: f00d + steps: + - uses: actions/checkout@v2 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true # runs 'bundle install' and caches installed gems automatically + + - uses: actions/setup-node@v2 + with: + node-version: '14.15.5' + + - name: Install JS dependencies + run: yarn install --frozen-lockfile + + - name: Set up application.yml + run: cp config/application.yml.example config/application.yml + + - name: Set up database + run: | + bundle exec rake db:create RAILS_ENV=test + bundle exec rake db:schema:load RAILS_ENV=test + + - name: Run tests + run: bundle exec rspec spec/controllers + + test-other: + runs-on: ubuntu-18.04 + services: + postgres: + image: postgres:10 + ports: ["5432:5432"] + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + env: + POSTGRES_DB: open_food_network_test + POSTGRES_USER: ofn + POSTGRES_PASSWORD: f00d + steps: + - uses: actions/checkout@v2 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true # runs 'bundle install' and caches installed gems automatically + + - uses: actions/setup-node@v2 + with: + node-version: '14.15.5' + + - name: Install JS dependencies + run: yarn install --frozen-lockfile + + - name: Set up application.yml + run: cp config/application.yml.example config/application.yml + + - name: Set up database + run: | + bundle exec rake db:create RAILS_ENV=test + bundle exec rake db:schema:load RAILS_ENV=test + + - name: Run JS tests + run: RAILS_ENV=test bundle exec rake karma:run + + - name: Run all other tests + run: | + bundle exec rspec \ + spec/helpers/ \ + spec/initializers/ \ + spec/jobs/ \ + spec/lib/ \ + spec/mailers/ \ + spec/queries/ \ + spec/requests/ \ + spec/serializers/ \ + spec/services/ \ + spec/validators/ \ + spec/views + + - name: Run engines tests + run: bundle exec rake ofn:specs:engines:rspec