diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 790b039a75..896da4fb9f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Build +name: Build test-the-rest on: workflow_dispatch: @@ -9,7 +9,6 @@ on: env: DISABLE_KNAPSACK: true - DISABLE_KNAPSACK_PRO: false TIMEZONE: UTC COVERAGE: true RAILS_ENV: test @@ -34,17 +33,14 @@ jobs: POSTGRES_USER: ofn POSTGRES_PASSWORD: f00d strategy: - fail-fast: false matrix: - # [n] - where the n is a number of parallel jobs you want to run your tests on. - # Use a higher number if you have slow tests to split them between more parallel jobs. - # Remember to update the value of the `ci_node_index` below to (0..n-1). - ci_node_total: [50] - # Indexes for parallel jobs (starting from zero). - # E.g. use [0, 1] for 2 parallel jobs, [0, 1, 2] for 3 parallel jobs, etc. - ci_node_index: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, - 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, - 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49] + specs: + - "spec/models" + - "spec/lib" + - "spec/migrations" + - "spec/serializers" + - "engines/*/spec" + fail-fast: false steps: - uses: actions/checkout@v3 @@ -69,22 +65,8 @@ jobs: run: | bundle exec rake db:create bundle exec rake db:schema:load - - name: Run tests - env: - KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC: ${{ secrets.KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC }} - KNAPSACK_PRO_CI_NODE_TOTAL: ${{ matrix.ci_node_total }} - KNAPSACK_PRO_CI_NODE_INDEX: ${{ matrix.ci_node_index }} - KNAPSACK_PRO_LOG_LEVEL: info - # if you use Knapsack Pro Queue Mode you must set below env variable - # to be able to retry CI build and run previously recorded tests - # https://github.com/KnapsackPro/knapsack_pro-ruby#knapsack_pro_fixed_queue_split-remember-queue-split-on-retry-ci-node - KNAPSACK_PRO_FIXED_QUEUE_SPLIT: true - # RSpec split test files by test examples feature - it's optional - # https://knapsackpro.com/faq/question/how-to-split-slow-rspec-test-files-by-test-examples-by-individual-it - # KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES: true - run: | - bin/knapsack_pro_rspec + run: bundle exec rspec --profile -- ${{ matrix.specs }} - name: Archive failed tests screenshots if: failure() @@ -134,7 +116,6 @@ jobs: run: | bundle exec rake db:create bundle exec rake db:schema:load - - name: Run JS tests run: bundle exec rake karma:run diff --git a/.github/workflows/build_knapsack_controllers.yml b/.github/workflows/build_knapsack_controllers.yml new file mode 100644 index 0000000000..a95711339c --- /dev/null +++ b/.github/workflows/build_knapsack_controllers.yml @@ -0,0 +1,88 @@ +name: Build KnapSack Controllers + +on: + workflow_dispatch: + push: + branches-ignore: + - 'dependabot/**' + pull_request: + +env: + DISABLE_KNAPSACK: true + DISABLE_KNAPSACK_PRO: false + TIMEZONE: UTC + COVERAGE: true + RAILS_ENV: test + +permissions: + contents: read + +jobs: + rspec: + runs-on: ubuntu-20.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 + strategy: + fail-fast: false + matrix: + # [n] - where the n is a number of parallel jobs you want to run your tests on. + # Use a higher number if you have slow tests to split them between more parallel jobs. + # Remember to update the value of the `ci_node_index` below to (0..n-1). + ci_node_total: [10] + # Indexes for parallel jobs (starting from zero). + # E.g. use [0, 1] for 2 parallel jobs, [0, 1, 2] for 3 parallel jobs, etc. + ci_node_index: [1, 2, 3, 4, 5, 6, 7, 8, 9] + steps: + - uses: actions/checkout@v3 + + - name: Setup redis + uses: supercharge/redis-github-action@1.4.0 + with: + redis-version: 6 + + - 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@v3 + with: + node-version: 16 + + - name: Install JS dependencies + run: yarn install --frozen-lockfile + + - name: Set up database + run: | + bundle exec rake db:create + bundle exec rake db:schema:load + + - name: Run tests + + env: + KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC: ${{ secrets.KNAPSACK_PRO_CONTROLLERS_TOKEN_RSPEC }} + KNAPSACK_PRO_CI_NODE_TOTAL: ${{ matrix.ci_node_total }} + KNAPSACK_PRO_CI_NODE_INDEX: ${{ matrix.ci_node_index }} + KNAPSACK_PRO_LOG_LEVEL: info + # if you use Knapsack Pro Queue Mode you must set below env variable + # to be able to retry CI build and run previously recorded tests + # https://github.com/KnapsackPro/knapsack_pro-ruby#knapsack_pro_fixed_queue_split-remember-queue-split-on-retry-ci-node + KNAPSACK_PRO_FIXED_QUEUE_SPLIT: true + # RSpec split test files by test examples feature - it's optional + # https://knapsackpro.com/faq/question/how-to-split-slow-rspec-test-files-by-test-examples-by-individual-it + #KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES: true + + run: | + KNAPSACK_PRO_TEST_FILE_PATTERN="{spec/controllers/**{,/*/**}/*_spec.rb,spec/controllers/**{,/*/**}/*_spec.rb}" bundle exec rake knapsack_pro:rspec + diff --git a/.github/workflows/build_knapsack_system.yml b/.github/workflows/build_knapsack_system.yml new file mode 100644 index 0000000000..6ddaca3d31 --- /dev/null +++ b/.github/workflows/build_knapsack_system.yml @@ -0,0 +1,97 @@ +name: Build KnapSack System + +on: + workflow_dispatch: + push: + branches-ignore: + - 'dependabot/**' + pull_request: + +env: + DISABLE_KNAPSACK: true + DISABLE_KNAPSACK_PRO: false + TIMEZONE: UTC + COVERAGE: true + RAILS_ENV: test + +permissions: + contents: read + +jobs: + rspec: + runs-on: ubuntu-20.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 + strategy: + fail-fast: false + matrix: + # [n] - where the n is a number of parallel jobs you want to run your tests on. + # Use a higher number if you have slow tests to split them between more parallel jobs. + # Remember to update the value of the `ci_node_index` below to (0..n-1). + ci_node_total: [40] + # Indexes for parallel jobs (starting from zero). + # E.g. use [0, 1] for 2 parallel jobs, [0, 1, 2] for 3 parallel jobs, etc. + ci_node_index: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39] + steps: + - uses: actions/checkout@v3 + + - name: Setup redis + uses: supercharge/redis-github-action@1.4.0 + with: + redis-version: 6 + + - 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@v3 + with: + node-version: 16 + + - name: Install JS dependencies + run: yarn install --frozen-lockfile + + - name: Set up database + run: | + bundle exec rake db:create + bundle exec rake db:schema:load + + - name: Run tests + + env: + KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC: ${{ secrets.KNAPSACK_PRO_SYSTEM_TOKEN_RSPEC }} + KNAPSACK_PRO_CI_NODE_TOTAL: ${{ matrix.ci_node_total }} + KNAPSACK_PRO_CI_NODE_INDEX: ${{ matrix.ci_node_index }} + KNAPSACK_PRO_LOG_LEVEL: info + # if you use Knapsack Pro Queue Mode you must set below env variable + # to be able to retry CI build and run previously recorded tests + # https://github.com/KnapsackPro/knapsack_pro-ruby#knapsack_pro_fixed_queue_split-remember-queue-split-on-retry-ci-node + KNAPSACK_PRO_FIXED_QUEUE_SPLIT: true + # RSpec split test files by test examples feature - it's optional + # https://knapsackpro.com/faq/question/how-to-split-slow-rspec-test-files-by-test-examples-by-individual-it + #KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES: true + + run: | + KNAPSACK_PRO_TEST_FILE_PATTERN="{spec/system/**{,/*/**}/*_spec.rb,spec/system/**{,/*/**}/*_spec.rb}" bundle exec rake knapsack_pro:rspec + + - name: Archive failed tests screenshots + if: failure() + uses: actions/upload-artifact@v3 + with: + name: failed-tests-screenshots + path: tmp/capybara/screenshots/*.png + retention-days: 7 + if-no-files-found: ignore