Skip to content

Commit

Permalink
Knapsack improvements (#3272)
Browse files Browse the repository at this point in the history
- use knapsack for all tests
- add new job for generating knapsack timings file
- add example code to merge timings file
- simplify existing workflow
- use node caching
- increase workers to 16
- compatibility fix for new chrome versions
  • Loading branch information
tbhi authored Dec 7, 2023
1 parent ffdefc9 commit c73f4a2
Show file tree
Hide file tree
Showing 5 changed files with 548 additions and 218 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/knapsack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: "Generate knapsack timings"
on:
workflow_dispatch:
jobs:
rspec:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:14
ports:
- "5432:5432"
env:
POSTGRES_DB: rails_test
POSTGRES_USER: rails
POSTGRES_PASSWORD: password
env:
RAILS_ENV: test
DATABASE_URL: "postgres://rails:password@localhost:5432/rails_test"
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 10.*
cache: yarn
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- run: bin/rails db:schema:load
- run: bundle exec rake assets:precompile
# Fail early if we have issues with translation keys
- run: bundle exec i18n-tasks health
- run: bundle exec rspec
env:
KNAPSACK_GENERATE_REPORT: true
- uses: actions/upload-artifact@v3
with:
name: knapsack_rspec_report
path: knapsack_rspec_report.json
70 changes: 11 additions & 59 deletions .github/workflows/rubyonrails.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,45 +5,7 @@ on:
pull_request:
branches: [ master, aws-eb-master ]
jobs:
test-core:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:14
ports:
- "5432:5432"
env:
POSTGRES_DB: rails_test
POSTGRES_USER: rails
POSTGRES_PASSWORD: password
env:
RAILS_ENV: test
DATABASE_URL: "postgres://rails:password@localhost:5432/rails_test"
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 10.*
- name: Checkout code
uses: actions/checkout@v3
# Add or replace dependency steps here
- name: Install Ruby and gems
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
# Add or replace database setup steps here
- name: Set up database schema
run: bin/rails db:schema:load
# Precompile assets
- name: Precompile assets
run: bundle exec rake assets:precompile
# Fail early if we have issues with translation keys
- name: Run i18n-tasks
run: bundle exec i18n-tasks health
# Add or replace test runners here
- name: Run tests
run: bundle exec rspec --exclude-pattern "spec/system/**/*_spec.rb"
test-system:
rspec:
runs-on: ubuntu-latest
services:
postgres:
Expand All @@ -57,36 +19,26 @@ jobs:
strategy:
fail-fast: false
matrix:
ci_node_total: [8]
ci_node_index: [0, 1, 2, 3, 4, 5, 6, 7]
ci_node_total: [16]
ci_node_index: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
env:
RAILS_ENV: test
DATABASE_URL: "postgres://rails:password@localhost:5432/rails_test"
# https://docs.knapsackpro.com/ruby/knapsack
CI_NODE_TOTAL: ${{ matrix.ci_node_total }}
CI_NODE_INDEX: ${{ matrix.ci_node_index }}
KNAPSACK_TEST_FILE_PATTERN: spec/system/**/*_spec.rb
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 10.*
- name: Checkout code
uses: actions/checkout@v3
# Add or replace dependency steps here
- name: Install Ruby and gems
uses: ruby/setup-ruby@v1
cache: yarn
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
# Add or replace database setup steps here
- name: Set up database schema
run: bin/rails db:schema:load
# Precompile assets
- name: Precompile assets
run: bundle exec rake assets:precompile
- run: bin/rails db:schema:load
- run: bundle exec rake assets:precompile
# Fail early if we have issues with translation keys
- name: Run i18n-tasks
run: bundle exec i18n-tasks health
# Add or replace test runners here
- name: Run tests
run: bundle exec rake knapsack:rspec
- run: bundle exec i18n-tasks health
# https://docs.knapsackpro.com/ruby/knapsack
# run this locally to update timing file - KNAPSACK_GENERATE_REPORT=true bundle exec rspec
- run: bundle exec rake knapsack:rspec
Loading

0 comments on commit c73f4a2

Please sign in to comment.