FAQ / knapsack_pro / General questions for knapsack_pro gem

How to run knapsack_pro only on a few parallel CI nodes instead of all?

You may want to run knapsack_pro only on a few CI nodes when you would like to run a different job on other CI nodes.

For instance, you have 3 parallel CI nodes. You would like to run knapsack_pro only on two CI nodes. The last CI node you want to use for the different job like running linters etc.

In such case, you can override the number of total CI nodes available by your CI provider. For instance, Heroku CI provider exposes in ENV variables CI_NODE_TOTAL=3.

You can then run knapsack_pro command this way on the first and the second CI node:


KNAPSACK_PRO_CI_NODE_TOTAL=$((CI_NODE_TOTAL-1)) bundle exec rake knapsack_pro:rspec

We decrease the number of CI node total by 1 that knapsack_pro can see. This way you can run tests with knapsack_pro only on two CI nodes. On the 3rd CI node, you can run other things like linters etc.

If you would like to check what is the CI node total ENV variable name exposed by your CI provider you can check that in your CI provider environment variables docs or preview the ENV variables that knapsack_pro can read for supported CI providers.

If you use for instance Heroku CI that allows you to provide only one test command you can make a bash script to control what's executed on particular CI node:


#!/bin/bash
# add this file in bin/knapsack_pro_rspec_and_npm_test and change chmod
# $ chmod a+x bin/knapsack_pro_rspec_and_npm_test

# 15 is last CI node (index starts from 0, so in total we have 16 parallel Heroku dynos)
if [ "$CI_NODE_INDEX" == "15" ]; then
  # run npm tests on the last CI node
  npm test
else
  KNAPSACK_PRO_CI_NODE_TOTAL=$((CI_NODE_TOTAL-1)) bundle exec rake knapsack_pro:queue:rspec
fi

then in your Heroku CI config app.json set:


"scripts": {
  "test": "bin/knapsack_pro_rspec_and_npm_test"
}

# General questions for knapsack_pro gem
See questions outside of this category

Start using Knapsack Pro

Sign up and speed up your tests.