From 7b715bf6c7e33994624e35fb9dfbd629e7e4b499 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Wed, 25 Feb 2026 15:07:52 +1100 Subject: [PATCH 1/5] Test current flakiness of spec --- .github/workflows/build.yml | 322 ++---------------------------------- 1 file changed, 11 insertions(+), 311 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 33f3663f33..d5bd9346ae 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,84 +17,6 @@ permissions: contents: read jobs: - controllers_and_models: - runs-on: ubuntu-22.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: [4] - # 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: [0, 1, 2, 3] - steps: - - uses: actions/checkout@v3 - - - name: Setup redis - uses: supercharge/redis-github-action@1.8.1 - 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 - - # JS is required in order for webpacker to compile, in order to render templates containing image urls - - uses: actions/setup-node@v3 - with: - node-version-file: .node-version - cache: yarn - - - name: Install JS dependencies - run: yarn install --frozen-lockfile - - - name: Set up database - run: | - bin/rails db:create db:schema:load - - - name: Run tests - env: - KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC: 864ef557d85ea8e603e086c0387d5154 - 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: false - # 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 - KNAPSACK_PRO_TEST_FILE_PATTERN: "{spec/controllers/**/*_spec.rb,spec/models/**/*_spec.rb}" - run: | - git show --no-patch # the commit being tested (which is often a merge due to actions/checkout@v3) - bin/rails assets:precompile knapsack_pro:rspec - - - name: Save SimpleCov file - uses: actions/upload-artifact@v4 - with: - name: simplecov-chunk-controllers-${{ matrix.ci_node_index }} - path: coverage/*.* - retention-days: 2 # doesn't need to be long, because it's the combined results that matter - if-no-files-found: ignore - include-hidden-files: true - system: runs-on: ubuntu-22.04 services: @@ -162,7 +84,17 @@ jobs: KNAPSACK_PRO_TEST_FILE_PATTERN: "{spec/system/admin/**/*_spec.rb,spec/system/consumer/**/*_spec.rb}" run: | - bin/rails assets:precompile knapsack_pro:queue:rspec + bin/rails assets:precompile + bin/rspec spec/system/admin/products_v3/actions_spec.rb:175 + bin/rspec spec/system/admin/products_v3/actions_spec.rb:175 + bin/rspec spec/system/admin/products_v3/actions_spec.rb:175 + bin/rspec spec/system/admin/products_v3/actions_spec.rb:175 + bin/rspec spec/system/admin/products_v3/actions_spec.rb:175 + bin/rspec spec/system/admin/products_v3/actions_spec.rb:175 + bin/rspec spec/system/admin/products_v3/actions_spec.rb:175 + bin/rspec spec/system/admin/products_v3/actions_spec.rb:175 + bin/rspec spec/system/admin/products_v3/actions_spec.rb:175 + bin/rspec spec/system/admin/products_v3/actions_spec.rb:175 - name: Save SimpleCov file uses: actions/upload-artifact@v4 @@ -181,235 +113,3 @@ jobs: path: tmp/capybara/screenshots/*.png retention-days: 7 if-no-files-found: ignore - - engines: - runs-on: ubuntu-22.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: [2] - # 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: [0, 1] - steps: - - uses: actions/checkout@v3 - - - name: Setup redis - uses: supercharge/redis-github-action@1.8.1 - 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 - - # JS is required in order for webpacker to compile, in order to render templates linking to mail.css - - uses: actions/setup-node@v3 - with: - node-version-file: .node-version - cache: yarn - - - name: Install JS dependencies - run: yarn install --frozen-lockfile - - - name: Set up database - run: | - bin/rails db:create db:schema:load - - - name: Run tests - - env: - KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC: d6ea7ceb766404ccd016c19aa2c81b1c - 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: false - # 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 - KNAPSACK_PRO_TEST_FILE_PATTERN: "{spec/lib/**/*_spec.rb,spec/migrations/**/*_spec.rb,spec/serializers/**/*_spec.rb,engines/**/*_spec.rb}" - - run: | - bin/rails assets:precompile knapsack_pro:rspec - - - name: Save SimpleCov file - uses: actions/upload-artifact@v4 - with: - name: simplecov-chunk-engines-${{ matrix.ci_node_index }} - path: coverage/*.* - retention-days: 2 # doesn't need to be long, because it's the combined results that matter - if-no-files-found: ignore - include-hidden-files: true - - test_the_rest: - runs-on: ubuntu-22.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: [3] - # 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: [0, 1, 2] - steps: - - uses: actions/checkout@v3 - - - name: Setup redis - uses: supercharge/redis-github-action@1.8.1 - 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 - - # JS is required in order for webpacker to compile, in order to render templates linking to mail.css - - uses: actions/setup-node@v3 - with: - node-version-file: .node-version - cache: yarn - - - name: Install JS dependencies - run: yarn install --frozen-lockfile - - - name: Set up database - run: | - bin/rails db:create db:schema:load - - - name: Run tests - env: - KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC: e3b8800198d2d89b70c7edbdd85f8fd8 - 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: false - # 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 - KNAPSACK_PRO_TEST_FILE_EXCLUDE_PATTERN: "{engines/**/*_spec.rb,spec/models/**/*_spec.rb,spec/controllers/**/*_spec.rb,spec/serializers/**/*_spec.rb,spec/lib/**/*_spec.rb,spec/migrations/**/*_spec.rb,spec/system/**/*_spec.rb}" - run: | - bin/rails assets:precompile knapsack_pro:rspec - - - name: Save SimpleCov file - uses: actions/upload-artifact@v4 - with: - name: simplecov-chunk-the-rest-${{ matrix.ci_node_index }} - path: coverage/*.* - retention-days: 2 # doesn't need to be long, because it's the combined results that matter - if-no-files-found: ignore - include-hidden-files: true - - non_knapsack_jest_karma: - runs-on: ubuntu-22.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@v3 - - # Rails is required for the Karma rake script - - 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-file: .node-version - cache: yarn - - - name: Install JS dependencies - run: yarn install --frozen-lockfile - - - name: Run JS tests - run: bin/rake karma:run - - - name: Run jest tests - run: yarn jest - - collate_simplecov_results: - runs-on: ubuntu-22.04 - needs: - - controllers_and_models - - engines - - system - - test_the_rest - steps: - - uses: actions/checkout@v3 - - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - bundler-cache: true # runs 'bundle install' and caches installed gems automatically - - - name: Download individual results from individual runners - uses: actions/download-artifact@v4 - with: - pattern: simplecov-chunk-* - path: tmp/simplecov - - - name: collate results from each of the workers - run: bundle exec rake 'simplecov:collate_results[tmp/simplecov]' - - - name: Upload collated results - uses: actions/upload-artifact@v4 - with: - name: combined-simplecov-report - path: coverage/**/*.* - retention-days: 7 - if-no-files-found: ignore - include-hidden-files: true - - name: Compare SimpleCov results with Undercover - run: | - git fetch --no-tags origin ${{ github.event.pull_request.base.ref }}:master - bundle exec undercover - if: ${{ github.ref != 'refs/heads/master' }} # Does not run on master, as we can't fetch master in the master branch From 6d17cf50fb4d1526238fbe9bd197c2a3e5858732 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Wed, 25 Feb 2026 15:08:50 +1100 Subject: [PATCH 2/5] Test impact of longer wait time on flakiness --- spec/system/admin/products_v3/actions_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/system/admin/products_v3/actions_spec.rb b/spec/system/admin/products_v3/actions_spec.rb index 8b09bf6b7b..ead18a3ac4 100644 --- a/spec/system/admin/products_v3/actions_spec.rb +++ b/spec/system/admin/products_v3/actions_spec.rb @@ -184,14 +184,14 @@ RSpec.describe 'As an enterprise user, I can manage my products' do ) tomselect_search_and_select(producer_to_select, from: "Producer") - sleep(0.1) + sleep(0.2) validate_tomselect_with_search!( page, "Category", categories_search_selector ) tomselect_search_and_select(category_to_select, from: "Category") - sleep(0.1) + sleep(0.2) validate_tomselect_with_search!( page, "Tax Category", tax_categories_search_selector From 560348722ce814211833b94e1e0e60d9e6555257 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Wed, 25 Feb 2026 15:18:39 +1100 Subject: [PATCH 3/5] Revert "Test current flakiness of spec" This reverts commit 7b715bf6c7e33994624e35fb9dfbd629e7e4b499. --- .github/workflows/build.yml | 322 ++++++++++++++++++++++++++++++++++-- 1 file changed, 311 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d5bd9346ae..33f3663f33 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,6 +17,84 @@ permissions: contents: read jobs: + controllers_and_models: + runs-on: ubuntu-22.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: [4] + # 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: [0, 1, 2, 3] + steps: + - uses: actions/checkout@v3 + + - name: Setup redis + uses: supercharge/redis-github-action@1.8.1 + 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 + + # JS is required in order for webpacker to compile, in order to render templates containing image urls + - uses: actions/setup-node@v3 + with: + node-version-file: .node-version + cache: yarn + + - name: Install JS dependencies + run: yarn install --frozen-lockfile + + - name: Set up database + run: | + bin/rails db:create db:schema:load + + - name: Run tests + env: + KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC: 864ef557d85ea8e603e086c0387d5154 + 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: false + # 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 + KNAPSACK_PRO_TEST_FILE_PATTERN: "{spec/controllers/**/*_spec.rb,spec/models/**/*_spec.rb}" + run: | + git show --no-patch # the commit being tested (which is often a merge due to actions/checkout@v3) + bin/rails assets:precompile knapsack_pro:rspec + + - name: Save SimpleCov file + uses: actions/upload-artifact@v4 + with: + name: simplecov-chunk-controllers-${{ matrix.ci_node_index }} + path: coverage/*.* + retention-days: 2 # doesn't need to be long, because it's the combined results that matter + if-no-files-found: ignore + include-hidden-files: true + system: runs-on: ubuntu-22.04 services: @@ -84,17 +162,7 @@ jobs: KNAPSACK_PRO_TEST_FILE_PATTERN: "{spec/system/admin/**/*_spec.rb,spec/system/consumer/**/*_spec.rb}" run: | - bin/rails assets:precompile - bin/rspec spec/system/admin/products_v3/actions_spec.rb:175 - bin/rspec spec/system/admin/products_v3/actions_spec.rb:175 - bin/rspec spec/system/admin/products_v3/actions_spec.rb:175 - bin/rspec spec/system/admin/products_v3/actions_spec.rb:175 - bin/rspec spec/system/admin/products_v3/actions_spec.rb:175 - bin/rspec spec/system/admin/products_v3/actions_spec.rb:175 - bin/rspec spec/system/admin/products_v3/actions_spec.rb:175 - bin/rspec spec/system/admin/products_v3/actions_spec.rb:175 - bin/rspec spec/system/admin/products_v3/actions_spec.rb:175 - bin/rspec spec/system/admin/products_v3/actions_spec.rb:175 + bin/rails assets:precompile knapsack_pro:queue:rspec - name: Save SimpleCov file uses: actions/upload-artifact@v4 @@ -113,3 +181,235 @@ jobs: path: tmp/capybara/screenshots/*.png retention-days: 7 if-no-files-found: ignore + + engines: + runs-on: ubuntu-22.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: [2] + # 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: [0, 1] + steps: + - uses: actions/checkout@v3 + + - name: Setup redis + uses: supercharge/redis-github-action@1.8.1 + 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 + + # JS is required in order for webpacker to compile, in order to render templates linking to mail.css + - uses: actions/setup-node@v3 + with: + node-version-file: .node-version + cache: yarn + + - name: Install JS dependencies + run: yarn install --frozen-lockfile + + - name: Set up database + run: | + bin/rails db:create db:schema:load + + - name: Run tests + + env: + KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC: d6ea7ceb766404ccd016c19aa2c81b1c + 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: false + # 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 + KNAPSACK_PRO_TEST_FILE_PATTERN: "{spec/lib/**/*_spec.rb,spec/migrations/**/*_spec.rb,spec/serializers/**/*_spec.rb,engines/**/*_spec.rb}" + + run: | + bin/rails assets:precompile knapsack_pro:rspec + + - name: Save SimpleCov file + uses: actions/upload-artifact@v4 + with: + name: simplecov-chunk-engines-${{ matrix.ci_node_index }} + path: coverage/*.* + retention-days: 2 # doesn't need to be long, because it's the combined results that matter + if-no-files-found: ignore + include-hidden-files: true + + test_the_rest: + runs-on: ubuntu-22.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: [3] + # 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: [0, 1, 2] + steps: + - uses: actions/checkout@v3 + + - name: Setup redis + uses: supercharge/redis-github-action@1.8.1 + 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 + + # JS is required in order for webpacker to compile, in order to render templates linking to mail.css + - uses: actions/setup-node@v3 + with: + node-version-file: .node-version + cache: yarn + + - name: Install JS dependencies + run: yarn install --frozen-lockfile + + - name: Set up database + run: | + bin/rails db:create db:schema:load + + - name: Run tests + env: + KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC: e3b8800198d2d89b70c7edbdd85f8fd8 + 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: false + # 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 + KNAPSACK_PRO_TEST_FILE_EXCLUDE_PATTERN: "{engines/**/*_spec.rb,spec/models/**/*_spec.rb,spec/controllers/**/*_spec.rb,spec/serializers/**/*_spec.rb,spec/lib/**/*_spec.rb,spec/migrations/**/*_spec.rb,spec/system/**/*_spec.rb}" + run: | + bin/rails assets:precompile knapsack_pro:rspec + + - name: Save SimpleCov file + uses: actions/upload-artifact@v4 + with: + name: simplecov-chunk-the-rest-${{ matrix.ci_node_index }} + path: coverage/*.* + retention-days: 2 # doesn't need to be long, because it's the combined results that matter + if-no-files-found: ignore + include-hidden-files: true + + non_knapsack_jest_karma: + runs-on: ubuntu-22.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@v3 + + # Rails is required for the Karma rake script + - 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-file: .node-version + cache: yarn + + - name: Install JS dependencies + run: yarn install --frozen-lockfile + + - name: Run JS tests + run: bin/rake karma:run + + - name: Run jest tests + run: yarn jest + + collate_simplecov_results: + runs-on: ubuntu-22.04 + needs: + - controllers_and_models + - engines + - system + - test_the_rest + steps: + - uses: actions/checkout@v3 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true # runs 'bundle install' and caches installed gems automatically + + - name: Download individual results from individual runners + uses: actions/download-artifact@v4 + with: + pattern: simplecov-chunk-* + path: tmp/simplecov + + - name: collate results from each of the workers + run: bundle exec rake 'simplecov:collate_results[tmp/simplecov]' + + - name: Upload collated results + uses: actions/upload-artifact@v4 + with: + name: combined-simplecov-report + path: coverage/**/*.* + retention-days: 7 + if-no-files-found: ignore + include-hidden-files: true + - name: Compare SimpleCov results with Undercover + run: | + git fetch --no-tags origin ${{ github.event.pull_request.base.ref }}:master + bundle exec undercover + if: ${{ github.ref != 'refs/heads/master' }} # Does not run on master, as we can't fetch master in the master branch From e4db20f86e7f04f46b498e954cef3c7e02b64741 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Thu, 26 Feb 2026 10:41:31 +1100 Subject: [PATCH 4/5] Remove unncessary expectation This assertion was confusing me. It was quite complex and the only thing it was asserting was the placeholder via a CSS selector. I don't think it's worth keeping. --- spec/support/products_helper.rb | 6 ------ spec/system/admin/products_v3/actions_spec.rb | 12 ------------ 2 files changed, 18 deletions(-) diff --git a/spec/support/products_helper.rb b/spec/support/products_helper.rb index dde11158ce..c941b4caea 100644 --- a/spec/support/products_helper.rb +++ b/spec/support/products_helper.rb @@ -79,12 +79,6 @@ module ProductsHelper end end - def validate_tomselect_with_search!(page, field_name, search_selector) - open_tomselect_to_validate!(page, field_name) do - expect(page).to have_selector(search_selector) - end - end - def random_producer(product) Enterprise.is_primary_producer .where.not(id: product.supplier.id) diff --git a/spec/system/admin/products_v3/actions_spec.rb b/spec/system/admin/products_v3/actions_spec.rb index ead18a3ac4..22078d5567 100644 --- a/spec/system/admin/products_v3/actions_spec.rb +++ b/spec/system/admin/products_v3/actions_spec.rb @@ -178,24 +178,12 @@ RSpec.describe 'As an enterprise user, I can manage my products' do tax_category_to_select = random_tax_category within row_containing_name(variant_a1.display_name) do - validate_tomselect_with_search!( - page, "Producer", - producer_search_selector - ) tomselect_search_and_select(producer_to_select, from: "Producer") sleep(0.2) - validate_tomselect_with_search!( - page, "Category", - categories_search_selector - ) tomselect_search_and_select(category_to_select, from: "Category") sleep(0.2) - validate_tomselect_with_search!( - page, "Tax Category", - tax_categories_search_selector - ) tomselect_search_and_select(tax_category_to_select, from: "Tax Category") end From fd178ee80b700705806f0a3313b808d719dfe6a9 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Thu, 26 Feb 2026 10:45:20 +1100 Subject: [PATCH 5/5] Use unique categories to avoid flakiness --- spec/system/admin/products_v3/actions_spec.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/spec/system/admin/products_v3/actions_spec.rb b/spec/system/admin/products_v3/actions_spec.rb index 22078d5567..383892ba86 100644 --- a/spec/system/admin/products_v3/actions_spec.rb +++ b/spec/system/admin/products_v3/actions_spec.rb @@ -167,7 +167,10 @@ RSpec.describe 'As an enterprise user, I can manage my products' do before do create_list(:supplier_enterprise, 11, users: [user]) create_list(:tax_category, 11) - create_list(:taxon, 11) + build_list(:taxon, 11).each_with_index do |taxon, i| + taxon.name += " #{i}" + taxon.save! + end visit admin_products_url end @@ -179,11 +182,7 @@ RSpec.describe 'As an enterprise user, I can manage my products' do within row_containing_name(variant_a1.display_name) do tomselect_search_and_select(producer_to_select, from: "Producer") - - sleep(0.2) tomselect_search_and_select(category_to_select, from: "Category") - - sleep(0.2) tomselect_search_and_select(tax_category_to_select, from: "Tax Category") end