README.md in knapsack_pro-0.37.0 vs README.md in knapsack_pro-0.38.0

- old
+ new

@@ -94,10 +94,11 @@ - [Supported CI providers](#supported-ci-providers) - [Info for CircleCI users](#info-for-circleci-users) - [Info for Travis users](#info-for-travis-users) - [Info for semaphoreapp.com users](#info-for-semaphoreappcom-users) - [Info for buildkite.com users](#info-for-buildkitecom-users) + - [Info for Gitlab CI users](#info-for-gitlab-ci-users) - [Info for snap-ci.com users](#info-for-snap-cicom-users) - [Info for Jenkins users](#info-for-jenkins-users) - [FAQ](#faq) - [Common problems](#common-problems) - [Why I see API error commit_hash parameter is required?](#why-i-see-api-error-commit_hash-parameter-is-required) @@ -722,10 +723,44 @@ Here you can find article [how to set up a new pipeline for your project in Buildkite and configure Knapsack Pro](http://docs.knapsackpro.com/2017/auto-balancing-7-hours-tests-between-100-parallel-jobs-on-ci-buildkite-example) and 2 example repositories for Ruby/Rails projects: * [Buildkite Rails Parallel Example with Knapsack Pro](https://github.com/KnapsackPro/buildkite-rails-parallel-example-with-knapsack_pro) * [Buildkite Rails Docker Parallel Example with Knapsack Pro](https://github.com/KnapsackPro/buildkite-rails-docker-parallel-example-with-knapsack_pro) +#### Info for Gitlab CI users + +Gitlab CI does not provide parallel jobs environment variables so you will have to define `KNAPSACK_PRO_CI_NODE_TOTAL` and `KNAPSACK_PRO_CI_NODE_INDEX` for each parallel job running as part of the same `test` stage. Below is relevant part of `.gitlab-ci.yml` configuration for 2 parallel jobs. + +``` +# .gitlab-ci.yml +stages: + - test + +variables: + KNAPSACK_PRO_CI_NODE_TOTAL: 2 + +# first CI node running in parallel +test_ci_node_0: + stage: test + script: + - export KNAPSACK_PRO_CI_NODE_INDEX=0 + # Cucumber tests in Knapsack Pro Regular Mode (deterministic test suite split) + - bundle exec rake knapsack_pro:cucumber + # RSpec tests in Knapsack Pro Queue Mode (dynamic test suite split) + # It will autobalance bulid because it is executed after Cucumber tests. + - bundle exec rake knapsack_pro:queue:rspec + +# second CI node running in parallel +test_ci_node_1: + stage: test + script: + - export KNAPSACK_PRO_CI_NODE_INDEX=1 + - bundle exec rake knapsack_pro:cucumber + - bundle exec rake knapsack_pro:queue:rspec +``` + +Remember to add API tokens like `KNAPSACK_PRO_TEST_SUITE_TOKEN_CUCUMBER` and `KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC` to [Secret Variables](https://gitlab.com/help/ci/variables/README.md#secret-variables) in `Gitlab CI Settings -> CI/CD Pipelines -> Secret Variables`. + #### Info for snap-ci.com users Knapsack Pro supports snap-ci.com ENVs `SNAP_WORKER_TOTAL` and `SNAP_WORKER_INDEX`. The only thing you need to do is to configure number of workers for your project in configuration settings in order to enable parallelism. Next thing is to set below commands to be executed in your stage: # Step for RSpec @@ -1165,20 +1200,22 @@ * CI node 0 (first CI node): ``` export PARALLEL_TESTS_CONCURRENCY=2; # this must be export + RAILS_ENV=test \ KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC=xxx \ KNAPSACK_PRO_CI_NODE_TOTAL=$YOUR_CI_NODE_TOTAL \ KNAPSACK_PRO_CI_NODE_INDEX=$YOUR_CI_NODE_INDEX \ bundle exec parallel_test -n $PARALLEL_TESTS_CONCURRENCY -e './bin/parallel_tests' ``` * CI node 1 (second CI node): ``` export PARALLEL_TESTS_CONCURRENCY=2; # this must be export + RAILS_ENV=test \ KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC=xxx \ KNAPSACK_PRO_CI_NODE_TOTAL=$YOUR_CI_NODE_TOTAL \ KNAPSACK_PRO_CI_NODE_INDEX=$YOUR_CI_NODE_INDEX \ bundle exec parallel_test -n $PARALLEL_TESTS_CONCURRENCY -e './bin/parallel_tests' ``` @@ -1188,10 +1225,10 @@ ``` # circle.yml for CircleCI 1.0 # KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC=xxx can be set in CircleCI ENV settings test: override: - - export PARALLEL_TESTS_CONCURRENCY=2; KNAPSACK_PRO_CI_NODE_TOTAL=$CIRCLE_NODE_TOTAL KNAPSACK_PRO_CI_NODE_INDEX=$CIRCLE_NODE_INDEX bundle exec parallel_test -n $PARALLEL_TESTS_CONCURRENCY -e './bin/parallel_tests': + - export PARALLEL_TESTS_CONCURRENCY=2; RAILS_ENV=test KNAPSACK_PRO_CI_NODE_TOTAL=$CIRCLE_NODE_TOTAL KNAPSACK_PRO_CI_NODE_INDEX=$CIRCLE_NODE_INDEX bundle exec parallel_test -n $PARALLEL_TESTS_CONCURRENCY -e './bin/parallel_tests': parallel: true # Caution: there are 8 spaces indentation! ``` In summary, the `bin/parallel_tests` script will calculate a new values for `KNAPSAKC_PRO_*` environment variables and then run knapsack_pro command with them. To ensure everything works you can check output for each CI node.