diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 34434d92a7..f636dbbfa3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,7 +13,7 @@ env: RAILS_ENV: test jobs: - test-controllers-and-serializers: + rspec: runs-on: ubuntu-18.04 services: postgres: @@ -28,6 +28,21 @@ jobs: POSTGRES_DB: open_food_network_test POSTGRES_USER: ofn POSTGRES_PASSWORD: f00d + strategy: + matrix: + specs: + - "spec/controllers" + - "spec/models" + - "spec/features/admin/[a-o0-9]*_spec.rb" + - "spec/features/admin/[p-z]*_spec.rb" + - "spec/features/admin/*/*_spec.rb" + - "spec/features/consumer" + - "spec/lib" + - "spec/migrations" + - "spec/serializers" + - "spec/system" + - "engines/*/spec" + fail-fast: false steps: - uses: actions/checkout@v2 @@ -48,230 +63,11 @@ jobs: - name: Set up database run: | - bundle exec rake db:create RAILS_ENV=test - bundle exec rake db:schema:load RAILS_ENV=test + bundle exec rake db:create + bundle exec rake db:schema:load - name: Run controller tests - run: bundle exec rspec --profile -- spec/controllers spec/serializers - - 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 - - - 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 --profile -- spec/models - - test-admin-features-1: - 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 --profile -- spec/features/admin/[a-o0-9]*_spec.rb - - test-admin-features-2: - 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 --profile -- spec/features/admin/[p-z]*_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 --profile -- spec/features/consumer - - test-engines-etc: - 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 jest tests - run: yarn jest - - # Migration tests need to be run in a separate task. - # See: https://github.com/openfoodfoundation/openfoodnetwork/pull/6924#issuecomment-813056525 - - name: Run migration tests - run: bundle exec rspec --pattern "spec/{migrations}/**/*_spec.rb" - - - name: Run system tests - run: bundle exec rspec --profile -- spec/system - - - name: Run all other tests - run: bundle exec rake ofn:specs:run:excluding_folders["models,controllers,serializers,features,lib,migrations,system"] + run: bundle exec rspec --profile -- ${{ matrix.specs }} test-the-rest: runs-on: ubuntu-18.04 @@ -308,8 +104,14 @@ jobs: - name: Set up database run: | - bundle exec rake db:create RAILS_ENV=test - bundle exec rake db:schema:load RAILS_ENV=test + bundle exec rake db:create + bundle exec rake db:schema:load - - name: Run admin feature folders, engines, lib - run: bundle exec rspec --profile --pattern "engines/*/spec/{,/*/**}/*_spec.rb,spec/features/admin/*/*_spec.rb,spec/lib/{,/*/**}/*_spec.rb" + - name: Run JS tests + run: bundle exec rake karma:run + + - name: Run jest tests + run: yarn jest + + - name: Run all other tests + run: bundle exec rake ofn:specs:run:excluding_folders["models,controllers,serializers,features,lib,migrations,system"]